Skip to content

Commit eafa909

Browse files
author
Renaud Vincent
committed
Added eddystone UID module
1 parent d1edba0 commit eafa909

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

modules/ble_eddystone_uid.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright (c) 2019 Renaud Vincent See the file LICENSE for copying permission.
3+
* usage: require("ble_eddystone_uid").advertise([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
4+
*/
5+
exports.get = function(namespace, instance) {
6+
// UID encodings https://github.com/google/eddystone/tree/master/eddystone-uid
7+
// Setup the frame format
8+
var d = [
9+
0x03, // Service UUID length
10+
0x03, // Service UUID data type value
11+
0xaa, // 16-bit Eddystone UUID
12+
0xfe, // 16-bit Eddystone UUID
13+
0x24, // Service Data length
14+
0x16, // Service Data data type value
15+
0xaa, // 16-bit Eddystone UUID
16+
0xfe, // 16-bit Eddystone UUID
17+
0x00, // Eddystone-uid frame type
18+
0xf8, // txpower, use max but lower with NRF api
19+
];
20+
21+
d = d.concat(namespace);
22+
d = d.concat(instance);
23+
24+
// Necessary to adjust lenght
25+
d[4] = d.length - 5;
26+
27+
return d;
28+
};
29+
30+
exports.advertise = function(namespace, instance, interval) {
31+
NRF.setAdvertising(
32+
exports.get(namespace, instance),
33+
{
34+
interval: interval
35+
}
36+
);
37+
};

0 commit comments

Comments
 (0)