sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
464 stars 180 forks source link

Setting GAP address #273

Open jaybz opened 5 years ago

jaybz commented 5 years ago

I've made a fork and written in a dirty hack to be able to call sd_ble_gap_address_set() at the write time to set the GAP address on a BBC Micro:bit. The main problem I was having was that you could call it in setup() just fine, but you would have had to call it after BLEPeripheral::begin() to enable the softdevice first. This means that the device would advertise using it's original GAP address first and you would have to connect to it and then disconnect before it started advertising on the GAP address you've set using sd_ble_gap_address_set().

I've tested the code and it works just fine so far. But because this is a very dirty hack, I have no other devices to test with, and I'm very new to microcontroller programming, I'm not comfortable creating a pull request at this time. Instead, feel free to use my code as a reference, if you need it. Or close this issue if you think that's out of scope for your project. It would be nice if you can add proper support for sd_ble_gap_address_set() though so I wouldn't have to maintain a separate fork for this purpose.

This commit should have all the relevant changes.