Comparing version 0.0.0 to 0.0.1
@@ -5,1 +5,24 @@ /** | ||
*/ | ||
var identifier = require('./common/util/identifier.js'); | ||
var address = require('./address/index.js'); | ||
var header = require('./header/index.js'); | ||
var data = require('./data/index.js'); | ||
/** | ||
* Process a raw Bluetooth Low Energy radio payload into semantically | ||
* meaningful information. | ||
* address. Note that the payload is LSB first. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @return {AdvA48} Advertiser address identifier. | ||
*/ | ||
function process(payload) { | ||
var advA48 = address.process(payload.substr(4,12)); | ||
advA48.advHeader = header.process(payload.substr(0,4)); | ||
advA48.advData = data.process(payload.substr(16)); | ||
return advA48; | ||
} | ||
module.exports.process = process; |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"engines": { | ||
@@ -16,0 +16,0 @@ "node": "^0.10.0" |
376
README.md
@@ -21,3 +21,3 @@ advlib | ||
var rawHexPacket = '421655daba50e1fe0201050c097265656c794163746976650100'; | ||
var rawHexPacket = '421655daba50e1fe0201050c097265656c79416374697665'; | ||
var processedPacket = advlib.ble.process(rawHexPacket); | ||
@@ -57,5 +57,14 @@ | ||
* [Address](#address) | ||
* [Data](#data) | ||
* [Generic Access Profile (GAP)](#generic-access-profile-gap) | ||
* [Data](#data-generic-access-profile) | ||
* [Flags](#flags) | ||
* [UUID](#uuid) | ||
* [Local Name](#local-name) | ||
* [Tx Power](#tx-power) | ||
* [Slave Connection Interval Range](#slave-connection-interval-range) | ||
* [Solicitation](#solicitation) | ||
* [Service Data](#service-data) | ||
* [Manufacturer Specific Data](#manufacturer-specific-data) | ||
* [Generic Data](#generic-data) | ||
### Header | ||
@@ -73,5 +82,5 @@ | ||
| 14 | TxAdd: 0 = public, 1 = random | | ||
| 13-12 | RFU *(currently ignored)* | | ||
| 13-12 | Reserved for Future Use (RFU) | | ||
| 11-8 | Type (see table below) | | ||
| 7-6 | RFU *(currently ignored)* | | ||
| 7-6 | Reserved for Future Use (RFU) | | ||
| 5-0 | Payload length in bytes | | ||
@@ -81,11 +90,11 @@ | ||
| Type | Packet | | ||
|-----:|------------------| | ||
| 0 | ADV_IND | | ||
| 1 | ADV_DIRECT_IND | | ||
| 2 | ADV_NONCONN_IND | | ||
| 3 | SCAN_REQ | | ||
| 4 | SCAN_RSP | | ||
| 5 | CONNECT_REQ | | ||
| 6 | ADV_DISCOVER_IND | | ||
| Type | Packet | Purpose | | ||
|-----:|------------------|----------------------------------------| | ||
| 0 | ADV_IND | Connectable undirected advertising | | ||
| 1 | ADV_DIRECT_IND | Connectable directed advertising | | ||
| 2 | ADV_NONCONN_IND | Non-connectable undirected advertising | | ||
| 3 | SCAN_REQ | Scan for more info from advertiser | | ||
| 4 | SCAN_RSP | Response to scan request from scanner | | ||
| 5 | CONNECT_REQ | Request to connect | | ||
| 6 | ADV_DISCOVER_IND | Scannable undirected advertising | | ||
@@ -108,11 +117,342 @@ For example: | ||
Description to come | ||
Process a 48-bit address (as a hexadecimal string) with the following command: | ||
### Data | ||
advlib.ble.address.process(rawHexAddress); | ||
#### Generic Access Profile (GAP) | ||
For reference, the 48-bit header is as follows (reading the hexadecimal string from left to right): | ||
Description to come | ||
| Bit(s) | Address component | | ||
|-------:|-------------------| | ||
| 47-40 | xx:xx:xx:xx:xx:## | | ||
| 39-32 | xx:xx:xx:xx:##:xx | | ||
| 31-24 | xx:xx:xx:##:xx:xx | | ||
| 23-16 | xx:xx:##:xx:xx:xx | | ||
| 15-8 | xx:##:xx:xx:xx:xx | | ||
| 7-0 | ##:xx:xx:xx:xx:xx | | ||
This is best illustrated with an example: | ||
advlib.ble.address.process('0123456789ab'); | ||
Would yield: | ||
{ | ||
type: "ADVA-48", | ||
value: "ab8967452301" | ||
} | ||
which can alternatively be represented as ab:89:67:45:23:01. | ||
### Data (Generic Access Profile) | ||
Process GAP data (as a hexadecimal string) with the following command: | ||
advlib.ble.data.process(rawHexData); | ||
For reference, the structure of the data is as follows: | ||
| Byte(s) | Data component | | ||
|------------:|-------------------------------------------------------| | ||
| 0 | Length of the data in bytes (including type and data) | | ||
| 1 | GAP Data Type (see table below) | | ||
| 2 to length | Type-specifc data | | ||
The Generic Access Profile Data Types are listed on the [Bluetooth GAP Assigned Numbers website](https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile). The following table lists the Data Types, their names and the section in this document in which they are described. | ||
| Data Type | Data Type Name | See advlib section | | ||
|----------:|--------------------------------------|--------------------| | ||
| 0x01 | Flags | Flags | | ||
| 0x02 | Incomplete List of 16-bit UUIDs | UUID | | ||
| 0x03 | Complete List of 16-bit UUIDs | UUID | | ||
| 0x04 | Incomplete List of 32-bit UUIDs | UUID | | ||
| 0x05 | Complete List of 32-bit UUIDs | UUID | | ||
| 0x06 | Incomplete List of 128-bit UUIDs | UUID | | ||
| 0x07 | Complete List of 128-bit UUIDs | UUID | | ||
| 0x08 | Shortened Local Name | Local Name | | ||
| 0x09 | Complete Local Name | Local Name | | ||
| 0x0a | Tx Power Level | Tx Power | | ||
| 0x0d | Class of Device | Generic Data | | ||
| 0x0e | Simple Pairing Hash C-192 | Generic Data | | ||
| 0x0f | Simple Pairing Randomizer R-192 | Generic Data | | ||
| 0x10 | Security Manager TK Value | Generic Data | | ||
| 0x11 | Security Manager OOB Flags | Generic Data | | ||
| 0x12 | Slave Connection Interval Range | SCIR | | ||
| 0x14 | 16-bit Solicitation UUIDs | Solicitation | | ||
| 0x15 | 128-bit Solicitation UUIDs | Solicitation | | ||
| 0x16 | Service Data 16-bit UUID | Service Data | | ||
| 0x17 | Public Target Address | Generic Data | | ||
| 0x18 | Random Target Address | Generic Data | | ||
| 0x19 | Public Target Address | Generic Data | | ||
| 0x1a | Advertising Interval | Generic Data | | ||
| 0x1b | LE Bluetooth Device Address | Generic Data | | ||
| 0x1c | LE Bluetooth Role | Generic Data | | ||
| 0x1d | Simple Pairing Hash C-256 | Generic Data | | ||
| 0x1e | Simple Pairing Hash Randomizer C-256 | Generic Data | | ||
| 0x1f | 32-bit Solicitation UUIDs | Solicitation | | ||
| 0x20 | Service Data 32-bit UUID | Service Data | | ||
| 0x21 | Service Data 128-bit UUID | Service Data | | ||
| 0x3d | 3-D Information Data | Generic Data | | ||
| 0xff | Manufacturer Specific Data | Mfr. Specific Data | | ||
#### UUID | ||
Process a UUID assigned to the device with any of the following commands: | ||
advlib.ble.data.gap.uuid.nonComplete16BitUUIDs(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.uuid.complete16BitUUIDs(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.uuid.nonComplete128BitUUIDs(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.uuid.complete128BitUUIDs(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
var payload = '16074449555520657669746341796c656572'; | ||
advlib.ble.data.gap.uuid.complete128BitUUIDs(payload, 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:---------------------------------|:----------------------------------------| | ||
| 0 | 16 | Length, in bytes, of type and data | | ||
| 1 | 07 | GAP Data Type for Complete 128-bit UUID | | ||
| 2 to 16 | 4449555520657669746341796c656572 | reelyActive's 128-bit UUID | | ||
Which would add the following property to advData: | ||
complete128BitUUIDs: "7265656c794163746976652055554944" | ||
#### Local Name | ||
Process the device's local name, complete or shortened, with the following commands, respectively: | ||
advlib.ble.data.gap.localname.completeLocalName(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.localname.shortenedLocalName(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.localname.completeLocalName('12097265656c79416374697665', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------------------|:----------------------------------------| | ||
| 0 | 12 | Length, in bytes, of type and data | | ||
| 1 | 09 | GAP Data Type for Complete Local Name | | ||
| 2 to 12 | 7265656c79416374697665 | ASCII representation of 'reelyActive' | | ||
Which would add the following property to advData: | ||
completeLocalName: "reelyActive" | ||
#### Flags | ||
Process the flags with the following command: | ||
advlib.ble.data.gap.flags.process(payload, cursor, advertiserData); | ||
For reference, the flags are as follows: | ||
| Bit | Description | | ||
|----:|----------------------------------------------------------------| | ||
| 0 | LE Limited Discoverable Mode | | ||
| 1 | LE General Discoverable Mode | | ||
| 2 | BR/EDR Not Supported | | ||
| 3 | Simultaneous LE and BR/EDR to Same Device Capable (Controller) | | ||
| 4 | Simultaneous LE and BR/EDR to Same Device Capable (Host) | | ||
| 5 | Reserved | | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.flags.process('020104', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte | Hex String | Description | | ||
|-----:|:------------|:------------------------------------| | ||
| 0 | 02 | Length, in bytes, of type and data | | ||
| 1 | 01 | GAP Data Type for flags | | ||
| 2 | 04 | See table above | | ||
Which would add the following property to advData: | ||
flags: [ "BR/EDR Not Supported" ] | ||
#### Manufacturer Specific Data | ||
Process manufacturer specific data with the following command: | ||
advlib.ble.data.gap.manufacturerspecificdata.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.manufacturerspecificdata.process('03ff8c00', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------|:------------------------------------------------| | ||
| 0 | 03 | Length, in bytes, of type and data | | ||
| 1 | ff | GAP Data Type for manufacturer specific data | | ||
| 2-3 | 8c00 | Gimbal company identifier code (bytes reversed) | | ||
Which would add the following property to advData: | ||
manufacturerSpecificData: { | ||
companyIdentifierCode: "008c", | ||
data: "" | ||
} | ||
##### iBeacon | ||
A specific case of manufacturer specific data is the iBeacon: | ||
var payload = '26ff4c000215b9407f30f5f8466eaff925556b57fe6d294c903974'; | ||
advlib.ble.data.gap.manufacturerspecificdata.process(payload, 0, {}); | ||
For reference, the iBeacon payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:---------------------------------|:-------------------------------| | ||
| 0 | 26 | Length, in bytes, of type and data | | ||
| 1 | ff | GAP Data Type for manufacturer specific data | | ||
| 2-3 | 4c00 | Apple company identifier code (bytes reversed) | | ||
| 4-5 | 0215 | Identifier code for iBeacon | | ||
| 6-21 | b9407f30f5f8466eaff925556b57fe6d | UUID (assigned by Apple) | | ||
| 21-22 | 294c | Major | | ||
| 23-24 | 9039 | Minor | | ||
| 25 | 74 | TxPower (see TxPower section) | | ||
Which would add the following property to advData: | ||
manufacturerSpecificData: { | ||
iBeacon: { | ||
uuid: "b9407f30f5f8466eaff925556b57fe6d", | ||
major: "294c", | ||
minor: "9039", | ||
txPower: "116dBm" | ||
} | ||
} | ||
#### TX Power Level | ||
Process Tx Power Level with the following command: | ||
advlib.ble.data.gap.txpower.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.txpower.process('020a7f', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------|:------------------------------------| | ||
| 0 | 02 | Length, in bytes, of type and data | | ||
| 1 | 0a | GAP Data Type for TxPower | | ||
| 2 | 7f | TxPower (see table below) | | ||
TxPower is a two's complement value which is interpreted as follows: | ||
| Hex String | Power dBm | | ||
|------------:|-----------| | ||
| 7f | 127 dBm | | ||
| 00 | 0 dBm | | ||
| ff | -128 dBm | | ||
Which would add the following property to advData: | ||
manufacturerSpecificData: { | ||
iBeacon: { | ||
txPower: "127dBm" | ||
} | ||
} | ||
#### Slave Connection Interval Range | ||
Process the Slave Connection Interval Range with the following command: | ||
advlib.ble.data.gap.slaveconnectionintervalrange.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.slaveconnectionintervalrange.process('061200060c80', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------|:--------------------------------------------------| | ||
| 0 | 06 | Length, in bytes, of type and data | | ||
| 1 | 12 | GAP Data Type for Slave Connection Interval Range | | ||
| 2-6 | 00060c80 | Min and max intervals (see table below) | | ||
And the intervals are intepreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------|:------------------------------------------| | ||
| 0-1 | 0006 | Min interval = 6 x 1.25 ms = 7.5 ms | | ||
| 2-3 | 0c80 | Max interval = 12128 x 1.25 ms = 15160 ms | | ||
Which would add the following property to advData: | ||
slaveConnectionIntervalRange: "00060c80" | ||
#### Service Solicitation | ||
Process a Service Solicitation UUID with any of the following commands: | ||
advlib.ble.data.gap.solicitation.solicitation16BitUUIDs(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.solicitation.solicitation128BitUUIDs(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.uuid.solicitation16BitUUIDs('0314d8fe', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-----------|:-----------------------------------------------------| | ||
| 0 | 03 | Length, in bytes, of type and data | | ||
| 1 | 14 | GAP Data Type for 16-bit Service Solicitation UUID | | ||
| 2-3 | d8fe | Google's UriBeacon UUID (bytes reversed) | | ||
Which would add a property to advData as follows: | ||
solicitation16BitUUIDs: "fed8" | ||
#### Service Data | ||
Process service data assigned to the device. | ||
advlib.ble.data.gap.servicedata.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.servicedata.process('09160a181204eb150000', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:-------------|:------------------------------------| | ||
| 0 | 09 | Length, in bytes, of type and data | | ||
| 1 | 16 | GAP Data Type for service data | | ||
| 2-3 | 0a18 | UUID (bytes reversed) | | ||
| 4-9 | 1204eb150000 | Service Data | | ||
Which would add the following property to advData: | ||
serviceData: { | ||
uuid : "180a", | ||
data : "1204eb150000" | ||
} | ||
reelyActive RFID Library | ||
@@ -119,0 +459,0 @@ ------------------------ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
79333
38
1030
485
1