williamtran29/react-native-ibeacon-simulator

Feature request: broadcast Scan-Response Packet

pashute opened this issue · 0 comments

When broadcasting I would like to broadcast with extra information beyond the "identifier".

Please see my [SO question and the comments I made there].(https://stackoverflow.com/questions/52206936/how-to-simulate-kontakt-ibeacon-unique-identifier)

I wish to broadcast the Scan-Response Packet along with the beacon information. This is used by Kontakt.io beacons to detect the four letter BeaconID (in Kontakt called the Unique ID). From other questions asked on SO it seems others use this as well. As far as I can see this is different from the "identifier" which is the "device name" of the beacon i.e. 'Kontakt'.

See here in the Kontakt docs, but this is correct for all iBeacons.

In particular: I would like something like:

scanResponsePacket = { 
       deviceName:  'myName', // i.e. 'Kontakt' 
       trxPower: 3, // 3 meters
       Beacon ID: 'B6VA',
       Firmware version: '31', // two chars. not sure about this, I think 31 would stand for 3.1
       Battery level: 5  // single digit
}

You have to broadcast on the bluetooth with the following bytes: All values are listed in hex:

deviceNameDatalen | byte 1 |  devicename data-length –  min 01, max 15, default 08
devicenameDatatype | byte 2 | fixed constant: 09 do not change
deviceName | bytes min: 3-4 max: 3-17  | example: 4b 6f 6e 74 61 6b 74  (kontakt)

txPwrDataLen | byte after devicename (e.g. 10) | fixed constant value: 02, do not change
txPwrDataType | byte after txPwrDataLen (e.g. 11) | fixed constant value: 0a, do not change
txPwr | byte after txPwrDataType (e.g. 12) | txPowerValue. Default to f4? // not sure about default

srvDataLen | byte after txPwrVal (e.g. 13) | fixed constant: 0a (meaning 10 bytes), do not change
srvDataType | byte after srvDataLen (e.g. 14) | fixed constant value: 0x16 , do not change

uuid | 2 bytes after srvDataType (e.g. 15-16) | example: 0d d0 // perhaps this is a constant? not sure.
beaconId  | 4 bytes after uuid (e.g. 17-20) |  'xxxx' (chars) e.g. 'B167' 
firmwareVersion | 2 bytes after beaconId4 (e.g. 21-22) | 'xx' (chars) e.g. '31' for 3.1 // not sure about this 
batteryLevel | byte after firmwareVersion (e.g. 23) | 'x' (char) e.g. '5'

If you understand what 'writing to characteristic' is (in this thread) and explain what I need to do in your code, I will gladly do it. I'm a seasoned Java programmer and can complete the Objective C as well.