Author Topic: Simble OTA iOS app  (Read 1202 times)

blieber

  • RFduino Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Simble OTA iOS app
« 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

Thanks,
Ben

danlsk

  • RFduino Jr. Member
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Simble OTA iOS app
« Reply #1 on: November 03, 2016, 12:53:49 AM »
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.

Code: [Select]
void SimbleeBLE_onReceive(char *data, int len)
{
  // if the first byte is 0x01 / on / true
  if (data[0])
    ota_bootloader_start(); //begin OTA enable state
 
}
« Last Edit: November 03, 2016, 12:55:22 AM by danlsk »

blieber

  • RFduino Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Simble OTA iOS app
« Reply #2 on: November 09, 2016, 11:33:58 PM »
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
  • 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

2b. The Nordic DFU specification requires some init packet along with the application payload (e.g. read this). 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
Code: [Select]
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 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).
« Last Edit: November 10, 2016, 06:05:31 AM by blieber »

 

anything