Comparing version 0.0.31 to 0.1.0
@@ -263,6 +263,8 @@ var companyNames = { | ||
"fdfb": "Tandem Diabetes Care", | ||
"fdfa": "Tandem Diabetes Care" | ||
"fdfa": "Tandem Diabetes Care", | ||
"fdf9": "INIA", | ||
"fdf8": "Onvocal", | ||
"fdf7": "HP Inc." | ||
}; | ||
module.exports.companyNames = companyNames; |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -17,8 +17,6 @@ */ | ||
* Parse BLE advertiser data flags. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* @param {string} data The raw flag data as a hexadecimal-string. | ||
*/ | ||
function process(payload, cursor, advertiserData) { | ||
var flags = parseInt(payload.substr(cursor+4,2),16); | ||
function process(data) { | ||
var flags = parseInt(data, 16); | ||
var result = []; | ||
@@ -43,3 +41,3 @@ if(flags & 0x01) { | ||
} | ||
advertiserData.flags = result; | ||
return result; | ||
} | ||
@@ -46,0 +44,0 @@ |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
*/ | ||
var pdu = require('../../common/util/pdu.js'); | ||
/** | ||
* Parse BLE advertiser data non-complete shortened local name. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function shortenedLocalName(payload, cursor, advertiserData) { | ||
var hexName = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var result = ""; | ||
for(var cChar = 0; cChar < hexName.length; cChar += 2) | ||
result += String.fromCharCode(parseInt(hexName.substr(cChar,2),16)); | ||
advertiserData.shortenedLocalName = result; | ||
} | ||
/** | ||
* Parse BLE advertiser data complete local name. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* Parse BLE advertiser data non-complete shortened local name. | ||
* @param {string} data The raw name data as a hexadecimal-string. | ||
*/ | ||
function completeLocalName(payload, cursor, advertiserData) { | ||
var hexName = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var result = ""; | ||
for(var cChar = 0; cChar < hexName.length; cChar += 2) | ||
result += String.fromCharCode(parseInt(hexName.substr(cChar,2),16)); | ||
advertiserData.completeLocalName = result; | ||
function process(data) { | ||
var result = ''; | ||
for(var cChar = 0; cChar < data.length; cChar += 2) { | ||
result += String.fromCharCode(parseInt(data.substr(cChar,2),16)); | ||
} | ||
return result; | ||
} | ||
module.exports.shortenedLocalName = shortenedLocalName; | ||
module.exports.completeLocalName = completeLocalName; | ||
module.exports.process = process; |
/** | ||
* Copyright reelyActive 2015-2017 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -21,9 +21,9 @@ */ | ||
* Parse BLE advertiser data manufacturer specific data. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {string} data The raw manufacturer data as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function process(payload, cursor, advertiserData) { | ||
var companyIdentifierCode = payload.substr(cursor+6, 2); | ||
companyIdentifierCode += payload.substr(cursor+4, 2); | ||
function process(data) { | ||
var companyIdentifierCode = data.substr(2,2); | ||
companyIdentifierCode += data.substr(0,2); | ||
@@ -35,13 +35,15 @@ var companyName = companyIdentifierCodes.companyNames[companyIdentifierCode]; | ||
var data = payload.substr(cursor+8, pdu.getTagDataLength(payload, cursor)-4); | ||
// NOTE: this is for legacy compatibility | ||
var advertiserData = { | ||
manufacturerSpecificData: { | ||
companyName : companyName, | ||
companyIdentifierCode: companyIdentifierCode, | ||
data: data.substr(4) | ||
} | ||
}; | ||
advertiserData.manufacturerSpecificData = { | ||
companyName : companyName, | ||
companyIdentifierCode: companyIdentifierCode, | ||
data: data }; | ||
// Handle the unique case of AltBeacon | ||
if(altbeacon.isAltBeacon(advertiserData)) { | ||
altbeacon.process(advertiserData); | ||
return; | ||
return advertiserData.manufacturerSpecificData; | ||
} | ||
@@ -54,16 +56,17 @@ | ||
apple.process(advertiserData); | ||
break; | ||
return advertiserData.manufacturerSpecificData; | ||
case '00f9': | ||
sticknfind.process(advertiserData); | ||
break; | ||
return advertiserData.manufacturerSpecificData; | ||
case '015d': | ||
estimote.process(advertiserData); | ||
break; | ||
return advertiserData.manufacturerSpecificData; | ||
case '0274': | ||
motsai.process(advertiserData); | ||
break; | ||
return advertiserData.manufacturerSpecificData; | ||
case '0583': | ||
codebluecommunications.process(advertiserData); | ||
break; | ||
return advertiserData.manufacturerSpecificData; | ||
default: | ||
return advertiserData.manufacturerSpecificData; | ||
} | ||
@@ -70,0 +73,0 @@ } |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -7,3 +7,2 @@ */ | ||
var pdu = require('../../common/util/pdu.js'); | ||
var gattservices = require('../gatt/services/index.js'); | ||
@@ -14,14 +13,18 @@ | ||
* Parse BLE advertiser service data. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* @param {string} data The raw service data as a hexadecimal-string. | ||
*/ | ||
function process(payload, cursor, advertiserData) { | ||
var serviceData = payload.substr(cursor + 4, | ||
pdu.getTagDataLength(payload, cursor)); | ||
var uuid = serviceData.substr(2,2) + serviceData.substr(0,2); | ||
var data = serviceData.substr(4); | ||
advertiserData.serviceData = { uuid: uuid, data: data }; | ||
function process(data) { | ||
var uuid = data.substr(2,2) + data.substr(0,2); | ||
// NOTE: this is for legacy compatibility | ||
var advertiserData = { | ||
serviceData: { | ||
uuid: uuid, | ||
data: data.substr(4) | ||
} | ||
}; | ||
gattservices.process(advertiserData); | ||
return advertiserData.serviceData; | ||
} | ||
@@ -28,0 +31,0 @@ |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
*/ | ||
var pdu = require('../../common/util/pdu.js'); | ||
/** | ||
* Parse BLE advertiser data service solicitation 16-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function solicitation16BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var solicitation16BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.solicitation16BitUUIDs = solicitation16BitUUIDs; | ||
} | ||
/** | ||
* Parse BLE advertiser data service solicitation 128-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* Parse BLE advertiser solicitation UUIDs. | ||
* @param {string} data The raw solicitation data as a hexadecimal-string. | ||
*/ | ||
function solicitation128BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var solicitation128BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.solicitation128BitUUIDs = solicitation128BitUUIDs; | ||
function process(data) { | ||
// NOTE: eventually this will become an array | ||
return pdu.reverseBytes(data); | ||
} | ||
module.exports.solicitation16BitUUIDs = solicitation16BitUUIDs; | ||
module.exports.solicitation128BitUUIDs = solicitation128BitUUIDs; | ||
module.exports.process = process; |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
*/ | ||
var pdu = require('../../common/util/pdu.js'); | ||
/** | ||
* Parse BLE advertiser TX power. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* @param {string} data The raw txPower data as a hexadecimal-string. | ||
*/ | ||
function process(payload, cursor, advertiserData) { | ||
advertiserData.txPower = pdu.convertTxPower(payload.substr(cursor+4,2)); | ||
function process(data) { | ||
return pdu.convertTxPower(data); | ||
} | ||
module.exports.process = process; |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
*/ | ||
var pdu = require('../../common/util/pdu.js'); | ||
/** | ||
* Parse BLE advertiser non-complete 16-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function nonComplete16BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var nonComplete16BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.nonComplete16BitUUIDs = nonComplete16BitUUIDs; | ||
} | ||
/** | ||
* Parse BLE advertiser complete 16-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
* Parse BLE advertiser UUIDs. | ||
* @param {string} data The raw UUID data as a hexadecimal-string. | ||
*/ | ||
function complete16BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var complete16BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.complete16BitUUIDs = complete16BitUUIDs; | ||
function process(data) { | ||
// NOTE: eventually this will become an array | ||
return pdu.reverseBytes(data); | ||
} | ||
/** | ||
* Parse BLE advertiser non-complete 128-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function nonComplete128BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var nonComplete128BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.nonComplete128BitUUIDs = nonComplete128BitUUIDs; | ||
} | ||
/** | ||
* Parse BLE advertiser complete 128-bit UUIDs. | ||
* @param {string} payload The raw payload as a hexadecimal-string. | ||
* @param {number} cursor The start index within the payload. | ||
* @param {Object} advertiserData The object containing all parsed data. | ||
*/ | ||
function complete128BitUUIDs(payload, cursor, advertiserData) { | ||
var data = payload.substr(cursor+4, pdu.getTagDataLength(payload, cursor)); | ||
var complete128BitUUIDs = pdu.reverseBytes(data); | ||
advertiserData.complete128BitUUIDs = complete128BitUUIDs; | ||
} | ||
module.exports.nonComplete16BitUUIDs = nonComplete16BitUUIDs; | ||
module.exports.complete16BitUUIDs = complete16BitUUIDs; | ||
module.exports.nonComplete128BitUUIDs = nonComplete128BitUUIDs; | ||
module.exports.complete128BitUUIDs = complete128BitUUIDs; | ||
module.exports.process = process; |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -7,12 +7,3 @@ */ | ||
var flags = require('./gap/flags.js'); | ||
var uuid = require('./gap/uuid.js'); | ||
var localname = require('./gap/localname.js'); | ||
var txpower = require('./gap/txpower.js'); | ||
var slaveconnectionintervalrange = | ||
require('./gap/slaveconnectionintervalrange.js'); | ||
var solicitation = require('./gap/solicitation.js'); | ||
var servicedata = require('./gap/servicedata.js'); | ||
var genericdata = require('./gap/genericdata.js'); | ||
var manufacturerspecificdata = require('./gap/manufacturerspecificdata.js'); | ||
var gap = require('./gap/index.js'); | ||
@@ -28,122 +19,6 @@ | ||
function process(payload) { | ||
var advertiserDataLength = payload.length; | ||
var cursor = 0; | ||
var advertiserData = {}; | ||
while(cursor < advertiserDataLength) { | ||
var length = (parseInt(payload.substr(cursor,2),16) + 1) * 2; | ||
var tag = payload.substr(cursor + 2, 2); | ||
switch(tag) { | ||
case("01"): | ||
flags.process(payload, cursor, advertiserData); | ||
break; | ||
case("02"): | ||
uuid.nonComplete16BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("03"): | ||
uuid.complete16BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("04"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"nonComplete32BitUUIDs"); | ||
break; | ||
case("05"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"complete32BitUUIDs"); | ||
break; | ||
case("06"): | ||
uuid.nonComplete128BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("07"): | ||
uuid.complete128BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("08"): | ||
localname.shortenedLocalName(payload, cursor, advertiserData); | ||
break; | ||
case("09"): | ||
localname.completeLocalName(payload, cursor, advertiserData); | ||
break; | ||
case("0a"): | ||
txpower.process(payload, cursor, advertiserData); | ||
break; | ||
case("0d"): | ||
genericdata.process(payload, cursor, advertiserData, "classOfDevice"); | ||
break; | ||
case("0e"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"simplePairingHashC"); | ||
break; | ||
case("0f"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"simplePairingRandomizerR"); | ||
break; | ||
case("10"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"securityManagerTKValue"); | ||
break; | ||
case("11"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"securityManagerOOBFlags"); | ||
break; | ||
case("12"): | ||
slaveconnectionintervalrange.process(payload, cursor, advertiserData); | ||
break; | ||
case("14"): | ||
solicitation.solicitation16BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("15"): | ||
solicitation.solicitation128BitUUIDs(payload, cursor, advertiserData); | ||
break; | ||
case("16"): | ||
servicedata.process(payload, cursor, advertiserData); | ||
break; | ||
case("17"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"publicTargetAddress"); | ||
break; | ||
case("18"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"randomTargetAddress"); | ||
break; | ||
case("19"): | ||
genericdata.process(payload, cursor, advertiserData, "appearance"); | ||
break; | ||
case("1a"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"advertisingInterval"); | ||
break; | ||
case("1b"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"leBluetoothDeviceAddress"); | ||
break; | ||
case("1c"): | ||
genericdata.process(payload, cursor, advertiserData, "leRole"); | ||
break; | ||
case("1d"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"simplePairingHashC256"); | ||
break; | ||
case("1e"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"simplePairingRandomizerR256"); | ||
break; | ||
case("1f"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"solicitation32BitUUIDs"); | ||
break; | ||
case("3d"): | ||
genericdata.process(payload, cursor, advertiserData, | ||
"informationData3D"); | ||
break; | ||
case("ff"): | ||
manufacturerspecificdata.process(payload, cursor, advertiserData); | ||
break; | ||
default: | ||
//console.log("Unhandled BLE tag " + tag); | ||
} | ||
cursor += length; | ||
} | ||
return advertiserData; | ||
return gap.process(payload); | ||
} | ||
module.exports.process = process; | ||
module.exports.flags = flags; | ||
module.exports.gap = gap; |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "0.0.31", | ||
"version": "0.1.0", | ||
"engines": { | ||
@@ -16,0 +16,0 @@ "node": ">=0.10.0" |
243
README.md
@@ -206,2 +206,12 @@ advlib | ||
| 0x21 | Service Data 128-bit UUID | Service Data | | ||
| 0x22 | LE Secure Con. Confirmation Value | Generic Data | | ||
| 0x23 | LE Secure Connections Random Value | Generic Data | | ||
| 0x24 | URI | Generic Data | | ||
| 0x25 | Indoor Positioning | Generic Data | | ||
| 0x26 | Transport Discovery Data | Generic Data | | ||
| 0x27 | LE Supported Features | Generic Data | | ||
| 0x28 | Channel Map Update Indication | Generic Data | | ||
| 0x29 | PB-ADV | Generic Data | | ||
| 0x2a | Mesh Message | Generic Data | | ||
| 0x2b | Mesh Beacon | Generic Data | | ||
| 0x3d | 3-D Information Data | Generic Data | | ||
@@ -213,39 +223,34 @@ | 0xff | Manufacturer Specific Data | Mfr. Specific Data | | ||
Process a UUID assigned to the device with any of the following commands: | ||
The following example illustrates the processing of a UUID: | ||
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); | ||
var payload = '17074449555520657669746341796c656572'; | ||
advlib.ble.data.process(payload); | ||
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 | | ||
| Byte(s) | Hex String | Description | | ||
|--------:|:---------------------------------|:-------------------------------| | ||
| 0 | 17 | Length, in bytes, of type and data | | ||
| 1 | 07 | GAP Data Type for Complete 128-bit UUIDs | | ||
| 2 to 17 | 4449555520657669746341796c656572 | reelyActive's 128-bit UUID | | ||
Which would add the following property to advData: | ||
Which would return: | ||
complete128BitUUIDs: "7265656c794163746976652055554944" | ||
{ complete128BitUUIDs: "7265656c794163746976652055554944" } | ||
It is also possible to process just the UUID: | ||
var uuid = '4449555520657669746341796c656572'; | ||
advlib.ble.data.gap.uuid.process(uuid); | ||
Which would simply return "7265656c794163746976652055554944". | ||
#### Local Name | ||
Process the device's local name, complete or shortened, with the following commands, respectively: | ||
The following example illustrates the processing of a local name: | ||
advlib.ble.data.gap.localname.completeLocalName(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.localname.shortenedLocalName(payload, cursor, advertiserData); | ||
var payload = '12097265656c79416374697665'; | ||
advlib.ble.data.process(payload); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.localname.completeLocalName('12097265656c79416374697665', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
@@ -259,14 +264,34 @@ | ||
Which would add the following property to advData: | ||
Which would return: | ||
completeLocalName: "reelyActive" | ||
{ completeLocalName: "reelyActive" } | ||
It is also possible to process just the local name: | ||
var name = '7265656c79416374697665'; | ||
advlib.ble.data.gap.localname.process(name); | ||
Which would simply return "reelyActive". | ||
#### Flags | ||
Process the flags with the following command: | ||
The following example illustrates the processing of flags: | ||
advlib.ble.data.gap.flags.process(payload, cursor, advertiserData); | ||
var payload = '020104'; | ||
advlib.ble.data.process(payload); | ||
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 | Flags byte (see table below) | | ||
Which would return: | ||
{ flags: [ 'BR/EDR Not Supported' ] } | ||
For reference, the flags are as follows: | ||
For reference, the bits of the flags byte are as follows: | ||
@@ -282,28 +307,16 @@ | Bit | Description | | ||
This is best illustrated with an example: | ||
It is also possible to process just the flags byte: | ||
advlib.ble.data.gap.flags.process('020104', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
var flags = '04'; | ||
advlib.ble.data.gap.flags.process(flags); | ||
| 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 simply return [ 'BR/EDR Not Supported' ]. | ||
Which would add the following property to advData: | ||
flags: [ "BR/EDR Not Supported" ] | ||
#### Manufacturer Specific Data | ||
Process manufacturer specific data with the following command: | ||
The following example illustrates the processing of manufacturer specific data: | ||
advlib.ble.data.gap.manufacturerspecificdata.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.manufacturerspecificdata.process('03ff8c00', 0, {}); | ||
var payload = '03ff2805'; | ||
advlib.ble.data.process(payload); | ||
@@ -318,20 +331,36 @@ For reference, the example payload is interpreted as follows: | ||
Which would add the following property to advData: | ||
Which would return: | ||
manufacturerSpecificData: { | ||
companyIdentifierCode: "008c", | ||
data: "" | ||
{ | ||
manufacturerSpecificData: { | ||
companyName: 'Lunera Inc.', | ||
companyIdentifierCode: '2805', | ||
data: '' | ||
} | ||
} | ||
The proprietary data of some manufacturers can be further processed. The data for those supported will automatically be processed. See the [Manufacturers](#manufacturers) section for the list of all supported manufacturers. | ||
It is also possible to process just the manufacturer specific data: | ||
var data = '2805'; | ||
advlib.ble.data.gap.manufacturerspecificdata.process(data); | ||
Which would return the following: | ||
{ | ||
companyName: 'Lunera Inc.', | ||
companyIdentifierCode: '0528', | ||
data: '' | ||
} | ||
#### TX Power Level | ||
Process Tx Power Level with the following command: | ||
The following example illustrates the processing of TX power level: | ||
advlib.ble.data.gap.txpower.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.txpower.process('020a7f', 0, {}); | ||
var payload = '020a7f'; | ||
advlib.ble.data.process(payload); | ||
@@ -354,5 +383,12 @@ For reference, the example payload is interpreted as follows: | ||
Which would add the following property to advData: | ||
Which would return: | ||
txPower: "127dBm" | ||
{ txPower: "127dBm" } | ||
It is also possible to process just the TX power level: | ||
var power = '7f'; | ||
advlib.ble.data.gap.txpower.process(power); | ||
Which would return "127dBm". | ||
@@ -362,9 +398,6 @@ | ||
Process the Slave Connection Interval Range with the following command: | ||
The following example illustrates the processing of slave connection interval range: | ||
advlib.ble.data.gap.slaveconnectionintervalrange.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.slaveconnectionintervalrange.process('061200060c80', 0, {}); | ||
var payload = '051200060c80'; | ||
advlib.ble.data.process(payload); | ||
@@ -375,7 +408,7 @@ For reference, the example payload is interpreted as follows: | ||
|--------:|:-----------|:--------------------------------------------------| | ||
| 0 | 06 | Length, in bytes, of type and data | | ||
| 0 | 05 | 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) | | ||
| 2-5 | 00060c80 | Min and max intervals (see table below) | | ||
And the intervals are intepreted as follows: | ||
The intervals would be intepreted as follows: | ||
@@ -387,5 +420,5 @@ | Byte(s) | Hex String | Description | | ||
Which would add the following property to advData: | ||
Which would return: | ||
slaveConnectionIntervalRange: "00060c80" | ||
{ slaveConnectionIntervalRange: "00060c80" } | ||
@@ -395,11 +428,7 @@ | ||
Process a Service Solicitation UUID with any of the following commands: | ||
The following example illustrates the processing of a service solicitation UUID: | ||
advlib.ble.data.gap.solicitation.solicitation16BitUUIDs(payload, cursor, advertiserData); | ||
advlib.ble.data.gap.solicitation.solicitation128BitUUIDs(payload, cursor, advertiserData); | ||
var payload = '0314d8fe'; | ||
advlib.ble.data.process(payload); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.uuid.solicitation16BitUUIDs('0314d8fe', 0, {}); | ||
For reference, the example payload is interpreted as follows: | ||
@@ -413,16 +442,20 @@ | ||
Which would add a property to advData as follows: | ||
Which would return: | ||
solicitation16BitUUIDs: "fed8" | ||
{ solicitation16BitUUIDs: "fed8" } | ||
It is also possible to process just the UUID: | ||
var uuid = 'd8fe'; | ||
advlib.ble.data.gap.solicitation.process(uuid); | ||
Which would simply return "fed8". | ||
#### Service Data | ||
Process service data assigned to the device. | ||
The following example illustrates the processing of service data: | ||
advlib.ble.data.gap.servicedata.process(payload, cursor, advertiserData); | ||
This is best illustrated with an example: | ||
advlib.ble.data.gap.servicedata.process('09160a181204eb150000', 0, {}); | ||
var payload = '09160a181204eb150000'; | ||
advlib.ble.data.process(payload); | ||
@@ -438,8 +471,10 @@ For reference, the example payload is interpreted as follows: | ||
Which would add the following properties to advData: | ||
Which would return: | ||
serviceData: { | ||
uuid : "180a", | ||
data : "1204eb150000", | ||
specificationName: "Device Information" | ||
{ | ||
serviceData: { | ||
uuid : "180a", | ||
data : "1204eb150000", | ||
specificationName: "Device Information" | ||
} | ||
} | ||
@@ -451,18 +486,20 @@ | ||
It is also possible to process just the service data: | ||
### Data (Generic Attribute Profile) | ||
var data = '0a181204eb150000'; | ||
advlib.ble.data.gap.servicedata.process(data); | ||
Process GATT service data (as a hexadecimal string) with the following command: | ||
Which would simply return: | ||
advlib.ble.data.gatt.process(advData); | ||
{ | ||
uuid: '180a', | ||
data: '1204eb150000', | ||
specificationName: 'Device Information' | ||
} | ||
Where advData contains a serviceData object (see [Service Data](#service-data)), for instance: | ||
advData: { | ||
serviceData: { | ||
uuid: "fed8", | ||
data: "00f2027265656c7961637469766507" | ||
} | ||
} | ||
### Data (Generic Attribute Profile) | ||
GATT service data is automatically processed when the Service Data GAP Type is present (see [Service Data](#service-data)). | ||
Based on the UUID, the serviceData will be parsed as either a [member service](#member-services) or a [standard service](#standard-services), as applicable. Note that not all services are yet implemented. | ||
@@ -1296,3 +1333,3 @@ | ||
Copyright (c) 2015-2017 reelyActive | ||
Copyright (c) 2015-2018 reelyActive | ||
@@ -1299,0 +1336,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: |
@@ -9,21 +9,17 @@ /** | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA_LE_LIMITED = '020101'; | ||
var INPUT_DATA_LE_GENERAL = '020102'; | ||
var INPUT_DATA_BR_OR_EDR_NOT_SUPPORTED = '020104'; | ||
var INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER = '020108'; | ||
var INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST = '020110'; | ||
var INPUT_DATA_LE_LIMITED = '01'; | ||
var INPUT_DATA_LE_GENERAL = '02'; | ||
var INPUT_DATA_BR_OR_EDR_NOT_SUPPORTED = '04'; | ||
var INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER = '08'; | ||
var INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST = '10'; | ||
// Expected outputs for the scenario | ||
var EXPECTED_DATA_LE_LIMITED = 'LE Limited Discoverable Mode'; | ||
var EXPECTED_DATA_LE_GENERAL = 'LE General Discoverable Mode'; | ||
var EXPECTED_DATA_BR_OR_EDR_NOT_SUPPORTED = 'BR/EDR Not Supported'; | ||
var EXPECTED_DATA_LE_LIMITED = [ 'LE Limited Discoverable Mode' ]; | ||
var EXPECTED_DATA_LE_GENERAL = [ 'LE General Discoverable Mode' ]; | ||
var EXPECTED_DATA_BR_OR_EDR_NOT_SUPPORTED = [ 'BR/EDR Not Supported' ]; | ||
var EXPECTED_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER = | ||
'Simultaneous LE and BR/EDR to Same Device Capable (Controller)'; | ||
[ 'Simultaneous LE and BR/EDR to Same Device Capable (Controller)' ]; | ||
var EXPECTED_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST = | ||
'Simultaneous LE and BR/EDR to Same Device Capable (Host)'; | ||
[ 'Simultaneous LE and BR/EDR to Same Device Capable (Host)' ]; | ||
@@ -33,10 +29,10 @@ describe('ble data flags', function() { | ||
// Test the process function | ||
it('should convert a hexadecimal payload to Le Limited', function() { | ||
flags.process(INPUT_DATA_LE_LIMITED, CURSOR, ADVERTISER_DATA); | ||
assert.equal(ADVERTISER_DATA.flags[0], EXPECTED_DATA_LE_LIMITED); | ||
it('should convert a hexadecimal payload to LE Limited', function() { | ||
assert.deepEqual(flags.process(INPUT_DATA_LE_LIMITED), | ||
EXPECTED_DATA_LE_LIMITED); | ||
}); | ||
it('should convert a hexadecimal payload to LE General', function() { | ||
flags.process(INPUT_DATA_LE_GENERAL, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.flags[0], EXPECTED_DATA_LE_GENERAL); | ||
assert.deepEqual(flags.process(INPUT_DATA_LE_GENERAL), | ||
EXPECTED_DATA_LE_GENERAL); | ||
}); | ||
@@ -46,4 +42,3 @@ | ||
function() { | ||
flags.process(INPUT_DATA_BR_OR_EDR_NOT_SUPPORTED, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.flags[0], | ||
assert.deepEqual(flags.process(INPUT_DATA_BR_OR_EDR_NOT_SUPPORTED), | ||
EXPECTED_DATA_BR_OR_EDR_NOT_SUPPORTED); | ||
@@ -54,5 +49,4 @@ }); | ||
Same Device Capable (Controller', function() { | ||
flags.process(INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER, | ||
CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.flags[0], | ||
assert.deepEqual(flags.process( | ||
INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER), | ||
EXPECTED_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_CONTROLLER); | ||
@@ -63,7 +57,6 @@ }); | ||
Same Device Capable (Host)', function() { | ||
flags.process(INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST, | ||
CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.flags[0], | ||
assert.deepEqual(flags.process( | ||
INPUT_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST), | ||
EXPECTED_DATA_SIMULTANEOUS_LE_AND_BR_OR_EDR_TO_SDC_HOST); | ||
}); | ||
}); | ||
}); |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -9,13 +9,7 @@ */ | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA_SHORTENED_LOCAL_NAME = '06087265656c79'; | ||
var INPUT_DATA_COMPLETE_LOCAL_NAME = '12097265656c79416374697665' | ||
var INPUT_DATA_LOCAL_NAME = '7265656c79416374697665' | ||
// Expected outputs for the scenario | ||
var EXPECTED_DATA_SHORTENED_LOCAL_NAME ='reely'; | ||
var EXPECTED_DATA_COMPLETE_LOCAL_NAME ='reelyActive'; | ||
var EXPECTED_DATA_LOCAL_NAME ='reelyActive'; | ||
@@ -25,18 +19,8 @@ describe('ble data localname', function() { | ||
// Test the process function | ||
it('should convert ble advertiser data to a shortened local name', | ||
function() { | ||
localname.shortenedLocalName(INPUT_DATA_SHORTENED_LOCAL_NAME, CURSOR, | ||
ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.shortenedLocalName, | ||
EXPECTED_DATA_SHORTENED_LOCAL_NAME); | ||
it('should convert ble advertiser data to a local name', function() { | ||
assert.deepEqual(localname.process(INPUT_DATA_LOCAL_NAME), | ||
EXPECTED_DATA_LOCAL_NAME); | ||
}); | ||
it('should convert ble advertiser data to a complete local name', | ||
function() { | ||
localname.completeLocalName(INPUT_DATA_COMPLETE_LOCAL_NAME, CURSOR, | ||
ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.completeLocalName, | ||
EXPECTED_DATA_COMPLETE_LOCAL_NAME); | ||
}); | ||
}); | ||
/** | ||
* Copyright reelyActive 2015-2017 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -9,30 +9,25 @@ */ | ||
var assert = require('assert'); | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA_COMPANY_ONLY = '03ff0800'; | ||
var INPUT_DATA_COMPANY_ONLY = '0800'; | ||
var INPUT_DATA_IBEACON_ESTIMOTE = | ||
'26ff4c000215b9407f30f5f8466eaff925556b57fe6d294c903974'; | ||
'4c000215b9407f30f5f8466eaff925556b57fe6d294c903974'; | ||
var INPUT_DATA_IBEACON_UNKNOWN = | ||
'26ff4c000215000000000000000000000000000000001234567800'; | ||
var INPUT_DATA_AIRDROP = '17ff4c0005120000000000000000011bc238fa0000000000'; | ||
var INPUT_DATA_AIRPODS = '1eff4c00071901022021880f00000049bcba4477206b0447472c771e53bbeb'; | ||
var INPUT_DATA_SERVICE_08 = '0dff4c000807ffffff00000045'; | ||
var INPUT_DATA_AIRPLAY_DESTINATION = '0cff4c0009060200c0a80030'; | ||
var INPUT_DATA_AIRPLAY_SOURCE = '06ff4c000a0100'; | ||
var INPUT_DATA_HANDOFF = '14ff4c000c0e0000041b59594de21ab6fbbb5cf6'; | ||
var INPUT_DATA_NEARBY = '08ff4c0010020100'; | ||
'4c000215000000000000000000000000000000001234567800'; | ||
var INPUT_DATA_AIRDROP = '4c0005120000000000000000011bc238fa0000000000'; | ||
var INPUT_DATA_AIRPODS = '4c00071901022021880f00000049bcba4477206b0447472c771e53bbeb'; | ||
var INPUT_DATA_SERVICE_08 = '4c000807ffffff00000045'; | ||
var INPUT_DATA_AIRPLAY_DESTINATION = '4c0009060200c0a80030'; | ||
var INPUT_DATA_AIRPLAY_SOURCE = '4c000a0100'; | ||
var INPUT_DATA_HANDOFF = '4c000c0e0000041b59594de21ab6fbbb5cf6'; | ||
var INPUT_DATA_NEARBY = '4c0010020100'; | ||
var INPUT_DATA_HANDOFF_AND_NEARBY = | ||
'17ff4c000c0e0026487bd5d243b3614ae30fddeb10020b00'; | ||
'4c000c0e0026487bd5d243b3614ae30fddeb10020b00'; | ||
var INPUT_DATA_ALTBEACON = | ||
'1bff1801beac00010203040506070809101112131415161718190069'; | ||
var INPUT_DATA_SNF_SINGLE = '17fff9000177665544332211004500000004991800123456'; | ||
var INPUT_DATA_SNS_MOTION = | ||
'18fff90042450000003099001122334455012345aabbccabc0'; | ||
var INPUT_DATA_MOTSAI = '09ff7402000015000040'; | ||
var INPUT_DATA_NORBLE = '11ff830501cc1234567881f87faabbccdd17'; | ||
var INPUT_DATA_PUCKYACTIVE = '10ff8305022b1f736f9d03eab70a1b04e2'; | ||
'1801beac00010203040506070809101112131415161718190069'; | ||
var INPUT_DATA_SNF_SINGLE = 'f9000177665544332211004500000004991800123456'; | ||
var INPUT_DATA_SNS_MOTION = 'f90042450000003099001122334455012345aabbccabc0'; | ||
var INPUT_DATA_MOTSAI = '7402000015000040'; | ||
var INPUT_DATA_NORBLE = '830501cc1234567881f87faabbccdd17'; | ||
var INPUT_DATA_PUCKYACTIVE = '8305022b1f736f9d03eab70a1b04e2'; | ||
@@ -153,5 +148,3 @@ // Expected outputs for the scenario | ||
data', function() { | ||
manufacturerspecificdata.process(INPUT_DATA_COMPANY_ONLY, CURSOR, | ||
ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.manufacturerSpecificData, | ||
assert.deepEqual(manufacturerspecificdata.process(INPUT_DATA_COMPANY_ONLY), | ||
EXPECTED_DATA_COMPANY_ONLY); | ||
@@ -162,6 +155,4 @@ }); | ||
specificdata', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_IBEACON_ESTIMOTE, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.iBeacon, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_IBEACON_ESTIMOTE).iBeacon, | ||
EXPECTED_DATA_IBEACON_ESTIMOTE); | ||
@@ -171,6 +162,4 @@ }); | ||
it('should convert ble advertiser data for unknown iBeacon', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_IBEACON_UNKNOWN, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.iBeacon, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_IBEACON_UNKNOWN).iBeacon, | ||
EXPECTED_DATA_IBEACON_UNKNOWN); | ||
@@ -180,6 +169,4 @@ }); | ||
it('should convert ble advertiser data for AirDrop', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_AIRDROP, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.airdrop, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_AIRDROP).airdrop, | ||
EXPECTED_DATA_AIRDROP); | ||
@@ -189,6 +176,4 @@ }); | ||
it('should convert ble advertiser data for AirPods', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_AIRPODS, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.airpods, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_AIRPODS).airpods, | ||
EXPECTED_DATA_AIRPODS); | ||
@@ -198,6 +183,4 @@ }); | ||
it('should convert ble advertiser data for Apple service 0x08', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_SERVICE_08, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.service, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_SERVICE_08).service, | ||
EXPECTED_DATA_SERVICE_08); | ||
@@ -207,6 +190,4 @@ }); | ||
it('should convert ble advertiser data for AirPlay destination', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_AIRPLAY_DESTINATION, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.airplay, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_AIRPLAY_DESTINATION).airplay, | ||
EXPECTED_DATA_AIRPLAY_DESTINATION); | ||
@@ -216,6 +197,4 @@ }); | ||
it('should convert ble advertiser data for AirPlay source', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_AIRPLAY_SOURCE, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.airplay, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_AIRPLAY_SOURCE).airplay, | ||
EXPECTED_DATA_AIRPLAY_SOURCE); | ||
@@ -225,6 +204,4 @@ }); | ||
it('should convert ble advertiser data for Apple handoff', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_HANDOFF, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.handoff, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_HANDOFF).handoff, | ||
EXPECTED_DATA_HANDOFF); | ||
@@ -234,6 +211,4 @@ }); | ||
it('should convert ble advertiser data for Apple nearby', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_NEARBY, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.nearby, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_NEARBY).nearby, | ||
EXPECTED_DATA_NEARBY); | ||
@@ -243,6 +218,4 @@ }); | ||
it('should convert ble advertiser data for two Apple services', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_HANDOFF_AND_NEARBY, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.nearby, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_HANDOFF_AND_NEARBY).nearby, | ||
EXPECTED_DATA_HANDOFF_AND_NEARBY); | ||
@@ -252,6 +225,4 @@ }); | ||
it('should convert ble advertiser data for AltBeacon', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_ALTBEACON, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.altBeacon, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_ALTBEACON).altBeacon, | ||
EXPECTED_DATA_ALTBEACON); | ||
@@ -262,6 +233,4 @@ }); | ||
specificdata', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_SNF_SINGLE, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.snfBeacon, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_SNF_SINGLE).snfBeacon, | ||
EXPECTED_DATA_SNF_SINGLE); | ||
@@ -272,6 +241,4 @@ }); | ||
specificdata', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_SNS_MOTION, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.snfBeacon, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_SNS_MOTION).snfBeacon, | ||
EXPECTED_DATA_SNS_MOTION); | ||
@@ -281,6 +248,4 @@ }); | ||
it('should convert ble advertiser data for Motsai', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_MOTSAI, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.sensors, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_MOTSAI).sensors, | ||
EXPECTED_DATA_MOTSAI); | ||
@@ -290,6 +255,4 @@ }); | ||
it('should convert ble advertiser data for NorBLE', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_NORBLE, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.norble, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_NORBLE).norble, | ||
EXPECTED_DATA_NORBLE); | ||
@@ -299,8 +262,6 @@ }); | ||
it('should convert ble advertiser data for puckyActive', function() { | ||
var advertiserData = { manufacturerSpecificData: {} }; | ||
manufacturerspecificdata.process(INPUT_DATA_PUCKYACTIVE, CURSOR, | ||
advertiserData); | ||
assert.deepEqual(advertiserData.manufacturerSpecificData.puckyActive, | ||
assert.deepEqual(manufacturerspecificdata.process( | ||
INPUT_DATA_PUCKYACTIVE).puckyActive, | ||
EXPECTED_DATA_PUCKYACTIVE); | ||
}); | ||
}); |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -9,28 +9,19 @@ */ | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA = '09164c001204eb150000'; | ||
var INPUT_DATA_COMPANY_NAME = '1216d8fe00f2027265656c7961637469766507'; | ||
var INPUT_DATA = '4c001204eb150000'; | ||
var INPUT_DATA_COMPANY_NAME = 'd8fe00f2027265656c7961637469766507'; | ||
// Expected outputs for the scenario | ||
var EXPECTED_DATA = { | ||
serviceData: { | ||
uuid: "004c", | ||
data: "1204eb150000" | ||
} | ||
uuid: "004c", | ||
data: "1204eb150000" | ||
}; | ||
var EXPECTED_DATA_COMPANY_NAME = { | ||
serviceData: { | ||
uuid: "fed8", | ||
data: "00f2027265656c7961637469766507", | ||
companyName: "Google", | ||
uriBeacon: { | ||
invisibleHint: false, | ||
txPower: "-14dBm", | ||
url: "http://reelyactive.com" | ||
} | ||
uuid: "fed8", | ||
data: "00f2027265656c7961637469766507", | ||
companyName: "Google", | ||
uriBeacon: { | ||
invisibleHint: false, | ||
txPower: "-14dBm", | ||
url: "http://reelyactive.com" | ||
} | ||
@@ -44,12 +35,9 @@ }; | ||
it('should parse BLE advertiser data service data', function() { | ||
var advertiserData = {}; | ||
servicedata.process(INPUT_DATA, CURSOR, advertiserData); | ||
assert.deepEqual(advertiserData, EXPECTED_DATA); | ||
assert.deepEqual(servicedata.process(INPUT_DATA), EXPECTED_DATA); | ||
}); | ||
it('should parse BLE advertiser data service data with companyName', | ||
function() { | ||
var advertiserData = {}; | ||
servicedata.process(INPUT_DATA_COMPANY_NAME, CURSOR, advertiserData); | ||
assert.deepEqual(advertiserData, EXPECTED_DATA_COMPANY_NAME); | ||
assert.deepEqual(servicedata.process(INPUT_DATA_COMPANY_NAME), | ||
EXPECTED_DATA_COMPANY_NAME); | ||
}); | ||
}); |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -8,10 +8,6 @@ */ | ||
var assert = require('assert'); | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA_16_BIT_UUID = '0314d8fe'; | ||
var INPUT_DATA__128_BIT_UUID = '261516074449555520657669746341796c656572'; | ||
var INPUT_DATA_16_BIT_UUID = 'd8fe'; | ||
var INPUT_DATA__128_BIT_UUID = '16074449555520657669746341796c656572'; | ||
@@ -26,16 +22,12 @@ // Expected outputs for the scenario | ||
it('should parse BLE advertiser data service solicitation 16-bit UUIDs', | ||
function() { | ||
solicitation.solicitation16BitUUIDs(INPUT_DATA_16_BIT_UUID, CURSOR, | ||
ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.solicitation16BitUUIDs, | ||
EXPECTED_DATA_16_BIT_UUID); | ||
function() { | ||
assert.deepEqual(solicitation.process(INPUT_DATA_16_BIT_UUID), | ||
EXPECTED_DATA_16_BIT_UUID); | ||
}); | ||
it('should parse BLE advertiser data service solicitation 128-bit UUIDs', | ||
function() { | ||
solicitation.solicitation128BitUUIDs(INPUT_DATA__128_BIT_UUID, CURSOR, | ||
ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.solicitation128BitUUIDs, | ||
EXPECTED_DATA_128_BIT_UUID); | ||
function() { | ||
assert.deepEqual(solicitation.process(INPUT_DATA__128_BIT_UUID), | ||
EXPECTED_DATA_128_BIT_UUID); | ||
}); | ||
}); |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -9,8 +9,4 @@ */ | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA = '020a7f'; | ||
var INPUT_DATA = '7f'; | ||
@@ -24,5 +20,5 @@ // Expected outputs for the scenario | ||
it('should parse BLE advertiser TX power', function() { | ||
txpower.process(INPUT_DATA, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.txPower, EXPECTED_DATA); | ||
assert.deepEqual(txpower.process(INPUT_DATA), EXPECTED_DATA); | ||
}); | ||
}); |
/** | ||
* Copyright reelyActive 2015 | ||
* Copyright reelyActive 2015-2018 | ||
* We believe in an open Internet of Things | ||
@@ -9,11 +9,7 @@ */ | ||
// Constants for the scenario | ||
var CURSOR = 0; | ||
var ADVERTISER_DATA = {}; | ||
// Inputs for the scenario | ||
var INPUT_DATA_NC_16 = '0314d8fe'; | ||
var INPUT_DATA_C_16 = '0314d8fe'; | ||
var INPUT_DATA_NC_128 = '16074449555520657669746341796c656572'; | ||
var INPUT_DATA_C_128 = '16074449555520657669746341796c656572'; | ||
var INPUT_DATA_NC_16 = 'd8fe'; | ||
var INPUT_DATA_C_16 = 'd8fe'; | ||
var INPUT_DATA_NC_128 = '4449555520657669746341796c656572'; | ||
var INPUT_DATA_C_128 = '4449555520657669746341796c656572'; | ||
@@ -30,21 +26,16 @@ // Expected outputs for the scenario | ||
it('should parse BLE advertiser non-complete 16-bit UUIDs', function() { | ||
uuid.nonComplete16BitUUIDs(INPUT_DATA_NC_16, CURSOR, ADVERTISER_DATA); | ||
assert.equal(ADVERTISER_DATA.nonComplete16BitUUIDs, EXPECTED_DATA_NC_16); | ||
assert.equal(uuid.process(INPUT_DATA_NC_16), EXPECTED_DATA_NC_16); | ||
}); | ||
it('should parse BLE advertiser complete 16-bit UUIDs', function() { | ||
uuid.complete16BitUUIDs(INPUT_DATA_C_16, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.complete16BitUUIDs, EXPECTED_DATA_C_16); | ||
assert.deepEqual(uuid.process(INPUT_DATA_C_16), EXPECTED_DATA_C_16); | ||
}); | ||
it('should parse BLE advertiser non-complete 128-bit UUIDs.', function() { | ||
uuid.nonComplete128BitUUIDs(INPUT_DATA_NC_128, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.nonComplete128BitUUIDs, | ||
EXPECTED_DATA_NC_128); | ||
assert.deepEqual(uuid.process(INPUT_DATA_NC_128), EXPECTED_DATA_NC_128); | ||
}); | ||
it('should parse BLE advertiser complete 128-bit UUIDs', function() { | ||
uuid.complete128BitUUIDs(INPUT_DATA_C_128, CURSOR, ADVERTISER_DATA); | ||
assert.deepEqual(ADVERTISER_DATA.complete128BitUUIDs, EXPECTED_DATA_C_128); | ||
assert.deepEqual(uuid.process(INPUT_DATA_C_128), EXPECTED_DATA_C_128); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1333
285796
131
5948