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.1 to 1.3.2

27

lib/minew.js

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

const ACCELERATION_FRAME_LENGTH = 15;
const PIR_FRAME_LENGTH = 11;
const VIBRATION_FRAME_LENGTH = 14;

@@ -28,4 +29,6 @@ const MIN_INFO_FRAME_LENGTH = 9;

const NAME_OFFSET = 9;
const PIR_OFFSET = 3;
const TIMESTAMP_OFFSET = 3;
const VIBRATION_OFFSET = 7;
const PIR_MASK = 0x0001;
const VISIBLE_LIGHT_MASK = 0x01;

@@ -63,2 +66,4 @@ const VIBRATION_MASK = 0x01;

return processInfo(buf);
case 0x11:
return processPassiveInfrared(buf);
case 0x18:

@@ -110,3 +115,3 @@ return processVibration(buf);

return { batteryPercentage: batteryPercentage,
isContactDetected: !isVisibleLight, uri: MINEW_URI };
isContactDetected: [ !isVisibleLight ], uri: MINEW_URI };
}

@@ -157,2 +162,22 @@

/**
* Process passive infrared (PIR) service data.
* @param {Object} data The raw service data as a Buffer.
* @return {Object} The processed infrared data as JSON.
*/
function processPassiveInfrared(data) {
let isInvalidLength = (data.length !== PIR_FRAME_LENGTH);
if(isInvalidLength) {
return null;
}
let batteryPercentage = data.readUInt8(BATTERY_PERCENTAGE_OFFSET);
let isInfraredDetected = ((data.readUInt16BE(PIR_OFFSET) & PIR_MASK) ===
PIR_MASK);
return { batteryPercentage: batteryPercentage,
isMotionDetected: [ isInfraredDetected ], uri: MINEW_URI };
}
/**
* Process vibration service data.

@@ -159,0 +184,0 @@ * @param {Object} data The raw service data as a Buffer.

2

package.json

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

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

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

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

const INPUT_DATA_NAME = 'a10801aabbccddeeff504c5553';
const INPUT_DATA_PIR = 'a111320001aabbccddeeff';
const INPUT_DATA_VIBRATION = 'a118321234567801aabbccddeeff';

@@ -31,3 +32,3 @@

batteryPercentage: 69,
isContactDetected: false,
isContactDetected: [ false ],
uri: "https://sniffypedia.org/Organization/Shenzhen_Minew_Technologies_Co_Ltd/"

@@ -45,2 +46,7 @@ };

};
const EXPECTED_DATA_PIR = {
batteryPercentage: 50,
isMotionDetected: [ true ],
uri: "https://sniffypedia.org/Organization/Shenzhen_Minew_Technologies_Co_Ltd/"
};
const EXPECTED_DATA_VIBRATION = {

@@ -90,2 +96,8 @@ batteryPercentage: 50,

// Test the process function with valid passive infrared data
it('should handle valid passive infrared data as input', function() {
assert.deepEqual(service.process(INPUT_DATA_PIR),
EXPECTED_DATA_PIR);
});
// Test the process function with valid vibration data

@@ -92,0 +104,0 @@ it('should handle valid vibration data as input', function() {

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