Simblee => iOS => Topic started by: blieber on October 26, 2016, 08:48:44 PM
Want an easy way to be able to update Simblee OTA from within an iOS app. The idea would be that whenever want to rev Simblee firmware, would just push a new version of the app which would then update the Simblee the next time it would be run. Is there an existing API to do this? Ideally would be something like
1. Search for peripheral of interest
2. Update Simblee, given peripheral and binary file to flash OTA
Otherwise it seems like the best option is to adapt the code under ~/Library/Arduino15/packages/Simblee/hardware/Simblee/1.1.0/iPhoneApps
I believe you can modify a button UI in the IOS app that passes the data to trigger OTA. Then, you can use SimbleBLE.h with function as below in Arduino sketch.
void SimbleeBLE_onReceive(char *data, int len)
// if the first byte is 0x01 / on / true
ota_bootloader_start(); //begin OTA enable state
Was able to get OTA working, here are the details involved in case may be helpful to folks in the future:
0. Following this approach you don't actually need to call "ota_bootloader_start()" from the Simblee firmware. What you need is to include "OTA_Bootloader.h” in your sketch (then you can force DFU)
1. From the iOS side you can use the most up to date Nordic iOS DFU Swift 3 library (https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library)
- Best way to get usage patterns is to go through the example project. Basically you need to supply the library with the central manager, peripheral, image file and declare a few configuration parameters.
2a. Build Arduino sketch to get a hex file. I bet there are more sophisticated ways to do this, but so far just been copying the output produced from building via Arduino IDE https://forum.arduino.cc/index.php?topic=131655.0 (https://forum.arduino.cc/index.php?topic=131655.0)
2b. The Nordic DFU specification requires some init packet along with the application payload (e.g. read this (https://github.com/NordicSemiconductor/Android-nRF-Connect/blob/master/init%20packet%20handling/How%20to%20generate%20the%20INIT%20file%20for%20DFU.pdf)). The easiest way have seen is to do this is to use nrfutil to make a zip image from the hex file. The following worked for me (copied from here (http://forum.rfduino.com/index.php?action=search2))
nrfutil dfu genpkg $1.zip --application $1.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe
2c. Getting the right package for nrfutil (https://github.com/NordicSemiconductor/pc-nrfutil) threw me off a bit. Simblee uses the Nordic legacy DFU mode.The most up to date nrfutil package won’t work, but a legacy compatible package is available (currently it’s 0.5.2).