New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ble-packet

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ble-packet - npm Package Compare versions

Comparing version 0.0.3 to 0.2.0

lib/bleObject.js

9

lib/blePacket.js

@@ -0,1 +1,2 @@

/* jshint node: true */
'use strict';

@@ -6,4 +7,3 @@

var charMeta = require('./defs/charMeta'),
charFramer = require('./charBuilder'),
charParser = require('./charDiscriminator');
BleObject = require('./bleObject');

@@ -13,8 +13,7 @@ var blePacket = {};

blePacket.frame = function (uuid, data) {
return charFramer(uuid).transToValObj(data).getCharBuf();
return new BleObject(uuid).frame(data);
};
blePacket.parse = function (uuid, bBuf, callback) {
charParser(uuid).getCharValPacket(bBuf, callback);
return new BleObject(uuid).parse(bBuf, callback);
};

@@ -21,0 +20,0 @@

@@ -1,8 +0,2 @@

'use strict';
var _ = require('busyman'),
bipso = require('bipso');
var hciCharMeta = {
module.exports = {
'0x2800' : {

@@ -1085,3 +1079,3 @@ params : ['uuid'],

types : ['uint32', 'uint32'],
bufLen: 4
bufLen: 8
},

@@ -1100,49 +1094,2 @@ '0x2abe' : {

}
};
var ipsoCharUuids = [
0xcc00, 0xcc01, 0xcc02, 0xcc03, 0xcc04, 0xcc05, 0xcc06, 0xcc07,
0xcc08, 0xcc09, 0xcc0a, 0xcc0b, 0xcc0c, 0xcc0d, 0xcc0e, 0xcc0f,
0xcc10, 0xcc11, 0xcc12, 0xcc13, 0xcc14, 0xcc15, 0xcc16, 0xcc17,
0xcc18, 0xcc19, 0xcc1a, 0xcc1b, 0xcc1c, 0xcc1d, 0xcc1e, 0xcc1f,
0xcc20, 0xcc21, 0xcc22, 0xcc23, 0xcc24, 0xcc25, 0xcc26, 0xcc27,
0xcc28, 0xcc29, 0xcc2a, 0xcc2b, 0xcc2c, 0xcc2d, 0xcc2e, 0xcc2f,
0xcc30, 0xcc31, 0xcc32
];
_.forEach(ipsoCharUuids, function (uuid) {
var newUuid = '0x' + uuid.toString(16),
charSpec = bipso.spec(newUuid),
paramObj = {
params: [],
types: [],
depends: {
params: [],
types: []
}
};
_.forEach(charSpec.fields.mandatory, function (entry) {
paramObj.params.push(entry.name);
paramObj.types.push(transType(entry.type));
});
_.forEach(charSpec.fields.optional, function (entry) {
paramObj.depends.params.push(entry.name);
paramObj.depends.types.push(transType(entry.type));
});
hciCharMeta[newUuid] = paramObj;
});
function transType (type) {
if (type === 'float')
type = 'floatle';
else if (type === 'buffer')
type = 'bufferPreLenUint8';
else if (type === 'string')
type = 'stringPreLenUint8';
return type;
}
module.exports = hciCharMeta;
};
{
"name": "ble-packet",
"version": "0.0.3",
"description": "",
"version": "0.2.0",
"description": "ble-packet is a framer and parser for BLE attributes on node.js",
"main": "index.js",

@@ -20,6 +20,6 @@ "scripts": {

"dependencies": {
"bipso": "0.0.6",
"busyman": "^0.1.1",
"bipso": "^1.2.0",
"busyman": "^0.2.0",
"concentrate": "^0.2.3",
"dissolve-chunks": "^1.0.2"
"dissolve-chunks": "^1.2.0"
},

@@ -26,0 +26,0 @@ "devDependencies": {

@@ -1,9 +0,7 @@

ble-packet
========================
# ble-packet
**ble-packet** is a framer and parser for BLE attributes on node.js
**ble-packet** is a framer and parser for BLE attributes defined by GATT Specifications
[![NPM](https://nodei.co/npm/ble-packet.png?downloads=true)](https://nodei.co/npm/ble-packet/)
[![Build Status](https://img.shields.io/travis/bluetoother/ble-packet/master.svg?maxAge=2592000)](https://travis-ci.org/bluetoother/ble-packet)
[![Build Status](https://travis-ci.org/bluetoother/ble-packet.svg?branch=master)](https://travis-ci.org/bluetoother/ble-packet)
[![npm](https://img.shields.io/npm/v/ble-packet.svg?maxAge=2592000)](https://www.npmjs.com/package/ble-packet)

@@ -16,3 +14,3 @@ [![npm](https://img.shields.io/npm/l/ble-packet.svg?maxAge=2592000)](https://www.npmjs.com/package/ble-packet)

1. [Overview](#Overview)
1.1 [GATT Specifications](#GATT)
1.1 [GATT Specifications](#GATT)
1.2 [Installation](#Installation)

@@ -24,3 +22,4 @@ 1.3 [Usage](#Usage)

3.2 [GATT Declarations](#Declarations)
3.3 [GATT Descriptors](#Descriptors)
3.3 [GATT Descriptors](#Descriptors)
3.4 [BIPSO Characteristics](#BCharacteristics)
4. [License](#License)

@@ -34,3 +33,3 @@

The **ble-packet** is the packet builder and parser used for process BLE attributes if they are [_GATT Specifications-defined_](https://www.bluetooth.com/specifications/GATT) ones.
The **ble-packet** is the packet builder and parser used for process BLE attributes if they are [_GATT Specifications-defined_](https://www.bluetooth.com/specifications/GATT) ones or [_BIPSO Specifications-defined_](https://github.com/bluetoother/bipso/blob/master/doc/spec.md) ones.

@@ -63,3 +62,3 @@ <br />

* Build a raw buffer of Characteristic Value
* Build a Characteristic raw buffer

@@ -69,7 +68,7 @@ ```js

minConnInterval: 100,
maxConnInterval: 500.
maxConnInterval: 500,
latency: 0,
timeout: 2000
},
charBuf = blePacket.frame('0x2a04', {});
charBuf = blePacket.frame('0x2a04', connParamsVal);
```

@@ -100,8 +99,8 @@

Generate the raw packet of a GATT-defined attribute value.
Generate the raw packet of a GATT-defined or BIPSO-defined attribute value.
**Arguments: **
**Arguments:**
1. `uuid` (_String_ | _Number_): UUID defined in [GATT Specifications](https://www.bluetooth.com/specifications/GATT).
2. `value` (_Object_): A GATT-defined attribute value.
1. `uuid` (_String_ | _Number_): UUID defined in [GATT Specifications](https://www.bluetooth.com/specifications/GATT) or [BIPSO Specification](https://github.com/bluetoother/bipso/blob/master/doc/spec.md).
2. `value` (_Object_): A GATT-defined or BIPSO-defined attribute value.

@@ -133,9 +132,9 @@ **Returns**

Parse a raw buffer into a GATT-defined attribute value.
Parse a raw buffer into a GATT-defined or BIPSO-defined attribute value.
**Arguments: **
**Arguments:**
1. `uuid` (_String_ | _Number_): UUID defined in [GATT Specifications](https://www.bluetooth.com/specifications/GATT).
1. `uuid` (_String_ | _Number_): UUID defined in [GATT Specifications](https://www.bluetooth.com/specifications/GATT) or [BIPSO Specification](https://github.com/bluetoother/bipso/blob/master/doc/spec.md).
2. `buf` (_Buffer_): Raw buffer to be parsed.
3. `callback` (_Function_): `function(err, result) {...}`. Get called when the buffer is parsed.
3. `callback` (_Function_): `function(err, result) {...}`. Get called when the raw buffer is parsed.

@@ -150,3 +149,3 @@ **Returns**

var dayDateUuid = '0x2a0a',
rawBuf = new Buffer([ 99, 07, 07, 13, 09, 00, 00, 02 ]);
rawBuf = new Buffer([ 153, 7, 07, 19, 09, 00, 00, 02 ]);

@@ -436,3 +435,10 @@ blePacket.parse(dayDateUuid, rawBuf, function(err, result) {

<a name="BCharacteristics"></a>
### 3.4 BIPSO Characteristics
* In BIPSO, an IPSO Smart Object will be mapped to a BLE Characteristic with a well-defined Characteristic Value.
* Here is the [document](https://github.com/bluetoother/bipso/blob/master/doc/spec.md#bipso-characteristics) that show you all BIPSO-defined Characteristics.
<br />
<a name="License"></a>

@@ -462,2 +468,2 @@ ## 4. License

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
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