How to check / flash firmware to Particle using Particle iOS SDK?


#1

So, I’m in the process of developing an iOS application (in Swift) to complement the firmware that I’m using on my Particle.

I’ve been looking for a way to programmatically check the Particle’s firmware, and update to my desired firmware OTA, if necessary, but haven’t found anything thus far in the documentation.

Has anyone managed to do this with their application? If so, would you mind providing some pointers?

Cheers!


#2

That’s sort of what products (in the console) are for. You upload your firmware, and it’ll make sure the devices get it as soon as possible.
As for the D.I.Y. solution, how about a simple variable with a number? Check that, and OTA if needed?


#3

I usually add a Particle.variable with the project’s name, which IDE was used to create it, and what the current version is.

char version[] = "Dev: CatDoorController2 2.1.0";

I put comments in the code for each new version, so I can keep track of what I’ve changed.


#4

I hadn’t even thought about using a Particle.variable @Ric - that’s a great idea! I’ll definitely implement that.

As far as flashing to the device OTA via the iOS SDK, I found what appears to be an Objective-C implementation in on the particle-sdk-ios GitHub page (see code below), but have not figured out how it should be, or whether it even can be implemented in Swift.

-(nullable NSURLSessionDataTask *)flashFiles:(NSDictionary *)filesDict completion:(nullable ParticleCompletionBlock)completion

Has anyone managed this? Thanks again for all of your help!


#5

I’m not sure I understand your work flow. Why do you want to flash the device from your phone? What advantage is there in doing it that way? Since you have to update the code using Dev or the web IDE, why not flash from there?