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.1.0 to 1.2.0

2

lib/advlibbleservices.js

@@ -44,2 +44,4 @@ /**

return gatt.process(data, uuid);
case '2afb':
return gatt.process(data, uuid);
case 'ffe1':

@@ -46,0 +48,0 @@ return minew.process(data);

@@ -26,2 +26,4 @@ /**

const MFD3D_STRUCT_LENGTH = 6;
const ILLUMINANCE_STRUCT_LENGTH = 3;
const ILLUMINANCE_UNKNOWN_VALUE = 167772.15;

@@ -55,2 +57,4 @@

return processMagneticFluxDensity3D(buf);
case '2afb':
return processIlluminance(buf);
}

@@ -249,2 +253,23 @@

/**
* Process illuminance 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_STRUCT_LENGTH);
if(isInvalidLength) {
return null;
}
let illuminance = data.readUIntLE(0, 3) / 100;
if(illuminance === ILLUMINANCE_UNKNOWN_VALUE) {
return null;
}
return { illuminance: illuminance };
}
module.exports.process = process;

2

package.json

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

],
"version": "1.1.0",
"version": "1.2.0",
"engines": {

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

@@ -47,2 +47,3 @@ advlib-ble-services

| 0x2aa1 | Magnetic flux density 3D | gatt.js |
| 0x2afb | Illuminance | gatt.js |
| 0xfd6f | Exposure Notification | exposurenotification.js |

@@ -49,0 +50,0 @@ | 0xfeaa | Eddystone (Google) | eddystone.js |

@@ -33,2 +33,5 @@ /**

const INPUT_UUID_MFD3D = '2aa1';
const INPUT_DATA_ILLUMINANCE_UNKNOWN = 'ffffff';
const INPUT_DATA_ILLUMINANCE = 'a08601';
const INPUT_UUID_ILLUMINANCE = '2afb';

@@ -64,2 +67,4 @@

const EXPECTED_DATA_MFD3D_NEGATIVE = { magneticField: [ -0.5, -0.001, -1 ] };
const EXPECTED_DATA_ILLUMINANCE_UNKNOWN = null;
const EXPECTED_DATA_ILLUMINANCE = { illuminance: 1000 };

@@ -168,2 +173,15 @@

// Test the process function with unknown illuminance data
it('should handle unknown illuminance data as input', function() {
assert.deepEqual(service.process(INPUT_DATA_ILLUMINANCE_UNKNOWN,
INPUT_UUID_ILLUMINANCE),
EXPECTED_DATA_ILLUMINANCE_UNKNOWN);
});
// Test the process function with illuminance data
it('should handle illuminance data as input', function() {
assert.deepEqual(service.process(INPUT_DATA_ILLUMINANCE,
INPUT_UUID_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