Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

advlib-ble-services

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

advlib-ble-services - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

23

lib/minew.js

@@ -16,2 +16,3 @@ /**

const PIR_FRAME_LENGTH = 11;
const ILLUMINANCE_FRAME_LENGTH = 11;
const VIBRATION_FRAME_LENGTH = 14;

@@ -32,2 +33,3 @@ const MIN_INFO_FRAME_LENGTH = 9;

const VIBRATION_OFFSET = 7;
const ILLUMINANCE_OFFSET = 3;
const PIR_MASK = 0x0001;

@@ -70,2 +72,4 @@ const VISIBLE_LIGHT_MASK = 0x01;

return processVibration(buf);
case 0x19:
return processIlluminance(buf);
}

@@ -202,2 +206,21 @@

/**
* Process illuminance service data.
* @param {Object} data The raw service data as a Buffer.
* @return {Object} The processed illuminance data as JSON.
*/
function processIlluminance(data) {
let isInvalidLength = (data.length !== ILLUMINANCE_FRAME_LENGTH);
if(isInvalidLength) {
return null;
}
let batteryPercentage = data.readUInt8(BATTERY_PERCENTAGE_OFFSET);
let illuminance = data.readUInt16BE(ILLUMINANCE_OFFSET);
return { batteryPercentage: batteryPercentage, illuminance: illuminance,
uri: MINEW_URI };
}
module.exports.process = process;

2

package.json

@@ -18,3 +18,3 @@ {

],
"version": "1.3.2",
"version": "1.3.3",
"engines": {

@@ -21,0 +21,0 @@ "node": ">=6.0.0"

@@ -19,2 +19,3 @@ /**

const INPUT_DATA_VIBRATION = 'a118321234567801aabbccddeeff';
const INPUT_DATA_ILLUMINANCE = 'a119640ab4aabbccddeeff';

@@ -55,2 +56,7 @@

};
const EXPECTED_DATA_ILLUMINANCE = {
batteryPercentage: 100,
illuminance: 2740,
uri: "https://sniffypedia.org/Organization/Shenzhen_Minew_Technologies_Co_Ltd/"
};

@@ -107,2 +113,8 @@

// Test the process function with valid illuminance data
it('should handle valid illuminance data as input', function() {
assert.deepEqual(service.process(INPUT_DATA_ILLUMINANCE),
EXPECTED_DATA_ILLUMINANCE);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc