This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Modifying the nRF51822 firmware for Apple's iBeacon

I'm trying to update the 51822 beacon example to work with iOS8 (iBeacon).

So far, I have registered to get iBeacon license from Apple, and setup the tools for compilation. (devzone.nordicsemi.com/.../)

I also could build an Beacon example to get the HEX file, but I have some questions to ask.

Question 1 : Firmware modification

I'm not 100% sure, but I guess ble_app_beacon/pca10028/s110 is the source to modify. I could open the source in Keil's uVision to build the original source code to get the HEX file.

From the document, I have to make a packet of 30 bytes with the following contents. I removed some of the contents to be shown as ??.

Total 30 Bytes
0 - 2 : 0x??/0x??/0x??
3 (Length) : 0x1A
4 (Type) : 0x??
5-6 (Company ID) : 0x????
7-8 (Beacon Type) : 0x????
9-24 (Proximity UUID)
25-26 (Major)
27-28 (Minor)
29 (Measured Power)

However, the source code (main.c) does not exactly match the packet format. For example, the beacon info length is 23 (0x17), not 30. And there is no way to make the first three bytes as prescribed.

#define APP_BEACON_INFO_LENGTH          0x17                              /**< Total length of information advertised by the Beacon. */
#define APP_ADV_DATA_LENGTH             0x15                              /**< Length of manufacturer specific data in the advertisement. */
#define APP_DEVICE_TYPE                 0x02                              /**< 0x02 refers to Beacon. */
#define APP_MEASURED_RSSI               0xC3                              /**< The Beacon's measured RSSI at 1 meter distance in dBm. */
#define APP_COMPANY_IDENTIFIER          0x0059                            /**< Company identifier for Nordic Semiconductor ASA. as per www.bluetooth.org. */

Edit

This is what I have done to make the nRF51822 beacon can trigger the nRFBeacons iOS app.

  1. Contact Apple to get iBeacon license.
  2. Bought jlink programming connector for firmware programming.

image description

  1. Download the nFRgo studio to download the hex file with the jlink.

image description

  1. Modify the beacon example from the nRF51822 Beacon v1.1.0. I modified the beacon.h in C:\Nordic Semiconductor\nRF51822 Beacon v1.1.0\Source Code\nrf51_beacon\common\beacon directory line 29

From: #define APP_DEFAULT_COMPANY_IDENTIFIER 0x0059 To: 0x0059 -> 0x00?? (The Apple ID).

image description

No error in compliation, get the hex file, no error in downloading the hex file into the nRF51822 beaon.

Reset the device after the programming, and scan to register the device.

  • Yes that's the right source, as I said in the other thread. Yes the fields are correct, you just need to change the manufacturer id, the UUID, the major/minor and the RSSI (if you want to change that, I left it alone).

    The first 3 bytes are the advertising flags which are set in the code and sent out at the start of the packet, the 5th byte is just a flag for manufacturer-specific data which the softdevice will add because you set the p_manuf_specific_data field of the ble_advdata_t and it will calculate and add in the total length as well which is the 4th byte.

    The apple document points you to the core BTLE spec, Volume 3, Appendix C section 18.1 which explains the first 7 bytes in the packet. That leaves 23 bytes (0x17) so everything is fine.

    Yes it's confusing that one document says 0x0215 is the beacon id and the code splits that up into two pieces 0x02 for an ID and 0x15 which is the remaining length of the data, the net effect however is the same (and it is actually 0x02 + length as far as I'm aware).

  • I just wanted to make sure you see the blog post on making the beacon code iOS8 compatible: devzone.nordicsemi.com/.../

Related