# NRF beacon 設定 * 商品頁面介紹: https://youyouyou.pixnet.net/blog/post/119467351 * 中國廠商網頁: http://www.radioland-china.com/1730323-1730323_2575605.html * 修改參數的方法 (建議用iOS) * iOS請下載「RL Beacon APP」,可修改大部分參數:https://goo.gl/is7ab7 * 開啟RL beacon,並開啟掃描,找到要修改beacon後,點選beacon名稱,即可開啟修改視窗 * Android請下載「LightBlue Beacon」,僅能修改name:https://goo.gl/MGdcAG ---- ## 常見的修改變數 * Name (顯示名稱) * 直接修改為需要的名稱後,按write後,顯示OK * Power發射功率 * 數值高代表功率強(效果不明顯?), 要輸入HEX值, 可參考下方表格 * 改太小可能導致無法收到訊號而報廢, ex: 設定01 (-21dBm) * 預設通常是最大值 (此處為4dBm, 要設定12) | dBm | -21 | -18 | -15 | -12 | -9 | -6 | -3 | 0 | 1 | 2 | 3 | 4 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | Hex | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | * Interval:廣播頻率 * 預設值1000ms=1秒 * 以50ms為單位, 求出倍數, 再把該數字轉成16進位. * ex: 1000ms = 20倍. 20 = HEX的16. | ms | 50 | 100 | 500 | 1000 | 2000 | | -------- | -------- | -------- | -------- | -------- | -------- | | 倍數| 1 | 2 | 10 | 20 | 40 | | Hex | 01 | 02 | 0A | 14 | 28 | * UUID (16 bytes) * 可以隨便設: 0~9,a~f. 只是要補滿32字 (iBeacon protocol) * Major 與 Minor (各 2 bytes) * 隨便4個數字: 0~9. (iBeacon protocol) * RSSI (看起來應該是frame format的 TX power, 長度是1 byte) * 網站說: 建議使用預設值 CA = 202 = -54dbm * 這邊很神奇, 設定的時候要用HEX, 可是會用10進位顯示 XD * 根據這個網頁的介紹, 這個數值應該是 RSSI at 1 meter 的測量值 https://support.kontakt.io/hc/en-gb/articles/201621521-Transmission-power-Range-and-RSSI * 可以自己改其他數字, 要用Two's Complement去換算. ref: https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html * ex: -54的話, 先把54轉成二進位, 然後invert, 再加1. 54 = 0011 0110 –(invert)–> 1100 1001 –(加1)–> 1100 1010 = HEX的CA * 實測RSSI: * tx power=12 (4 dBm), RSSI = -51 ~ -54 都有可能, 感覺用預設值-54也可以!? ---- The radio in nRF51822 have -93dBm RX sensitivity in BLE mode(1Mbps). This means that -93dBm is the lowest signal level the receiver can detect the RF signal and demodulate the data reliably. The -98dBm you are measuring is caused by RSSI measuring inaccuracies. ---- * Transmission power, Range and RSSI * https://support.kontakt.io/hc/en-gb/articles/201621521-Transmission-power-Range-and-RSSI * Available transmission power values [dBm] | Hexadecimal value | TX Power level | Decimal value | RSSI @ 1 meter | Range (meters) | | --------| --------| --------| --------| -------- | | e2 | 0 | -30 dBm | -115 dBm | 2 | | ec | 1 | -20 dBm | -84 dBm | 4 | | f0 | 2 | -16 dBm | -81 dBm | 10 | | f4 | 3 | -12 dBm | -77 dBm | 20 | | f8 | 4 | -8 dBm | -72 dBm | 30 | | fc | 5 | -4 dBm | -69 dBm | 40 | | 00 | 6 | 0 dBm | -65 dBm | 60 | | 04 | 7 | 4 dBm | -59 dBm | 70 | ---- * What is the iBeacon Bluetooth Profile * https://stackoverflow.com/questions/18906988/what-is-the-ibeacon-bluetooth-profile * the transmitted BLE advertisement packet looks like this: ``` d6 be 89 8e 40 24 05 a2 17 6e 3d 71 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 52 ab 8d 38 a5 ``` * This packet can be broken down as follows: ``` d6 be 89 8e # Access address for advertising data (this is always the same fixed value) 40 # Advertising Channel PDU Header byte 0. Contains: (type = 0), (tx add = 1), (rx add = 0) 24 # Advertising Channel PDU Header byte 1. Contains: (length = total bytes of the advertising payload + 6 bytes for the BLE mac address.) 05 a2 17 6e 3d 71 # Bluetooth Mac address (note this is a spoofed address) 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 # Bluetooth advertisement 52 ab 8d 38 a5 # checksum ``` * The key part of that packet is the Bluetooth Advertisement, which can be broken down like this: ``` 02 # Number of bytes that follow in first AD structure 01 # Flags AD type 1A # Flags value 0x1A = 000011010 bit 0 (OFF) LE Limited Discoverable Mode bit 1 (ON) LE General Discoverable Mode bit 2 (OFF) BR/EDR Not Supported bit 3 (ON) Simultaneous LE and BR/EDR to Same Device Capable (controller) bit 4 (ON) Simultaneous LE and BR/EDR to Same Device Capable (Host) 1A # Number of bytes that follow in second (and last) AD structure FF # Manufacturer specific data AD type 4C 00 # Company identifier code (0x004C == Apple) 02 # Byte 0 of iBeacon advertisement indicator 15 # Byte 1 of iBeacon advertisement indicator e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 # iBeacon proximity uuid 00 00 # major 00 00 # minor c5 # The 2's complement of the calibrated Tx Power ```