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.0.1 to 1.0.2

28

lib/minew.js

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

const ACCELERATION_FRAME_LENGTH = 15;
const VIBRATION_FRAME_LENGTH = 14;
const MIN_INFO_FRAME_LENGTH = 9;

@@ -27,3 +28,6 @@ const FRAME_TYPE_OFFSET = 0;

const NAME_OFFSET = 9;
const TIMESTAMP_OFFSET = 3;
const VIBRATION_OFFSET = 7;
const VISIBLE_LIGHT_MASK = 0x01;
const VIBRATION_MASK = 0x01;
const MINEW_URI = "https://sniffypedia.org/Organization/Shenzhen_Minew_Technologies_Co_Ltd/";

@@ -59,2 +63,4 @@

return processInfo(buf);
case 0x18:
return processVibration(buf);
}

@@ -149,2 +155,24 @@

/**
* Process vibration service data.
* @param {Object} data The raw service data as a Buffer.
* @return {Object} The processed vibration data as JSON.
*/
function processVibration(data) {
let isInvalidLength = (data.length !== VIBRATION_FRAME_LENGTH);
if(isInvalidLength) {
return null;
}
let batteryPercentage = data.readUInt8(BATTERY_PERCENTAGE_OFFSET);
let timestamp = data.readUInt32BE(TIMESTAMP_OFFSET);
let isVibration = ((data.readUInt8(VIBRATION_OFFSET) & VIBRATION_MASK) ===
VIBRATION_MASK);
// TODO: Include timestamp? Units?
return { batteryPercentage: batteryPercentage,
isVibration: isVibration, uri: MINEW_URI };
}
module.exports.process = process;

2

package.json

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

],
"version": "1.0.1",
"version": "1.0.2",
"engines": {

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

@@ -54,3 +54,3 @@ advlib-ble-services

Copyright (c) 2015-2020 [reelyActive](https://www.reelyactive.com)
Copyright (c) 2015-2021 [reelyActive](https://www.reelyactive.com)

@@ -57,0 +57,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

/**
* Copyright reelyActive 2015-2020
* Copyright reelyActive 2015-2021
* We believe in an open Internet of Things

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

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

@@ -43,2 +44,7 @@

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

@@ -83,2 +89,8 @@

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

Sorry, the diff of this file is not supported yet

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