Using Spark Core in a standalone product changing wifi credentials?

Thanks @zachary
I’m trying to think the simplest way for the end user to configure the product. Is this approach possible?:

  1. Product with the Spark Core inside is shipped to consumer (no firmware installed or wifi credentials setup yet, same state as you ship Cores?, or do they come with tinker on?)
  2. The mobile app (similiar to smart config app) is used to save the wifi credentials on the Core.
  3. The Core is then somehow linked/claimed by the product suppliers spark login (not sure if this is possible?)
  4. Something detects a new core added on the suppliers account and flashes the custom firmware. If detection isn’t possible then perhaps the mobile app can trigger a web service when the app knows the device ID?

A reset button is installed on which will run some bespoke code to put the core back into ‘awaiting wifi credentials mode’ so the mobile app can see it again.

I know there is the usb serial option but I prefer the mobile app approach I think it is cleaner and more user friendly. This is not to say the product couldn’t offer both options.

I’m new to the arduino code base as you might have guessed :), I’m just trying to understand the basics of how intial setup would work.

Something like that is definitely possible @Brungle. From a product creator’s perspective, there are many ways to bring a product with the Spark Core to market. Right now we’re working with entrepreneurs and companies individually to create the user experience that’s right for them, balancing strategy and timing with the experience of their tech team.

A normal Spark Core has Tinker programmed at the factory. Depending on the user experience you want, your product firmware can either be programmed at your factory at product assembly time (meaning the user may not have to wait for a firmware update when first setting up the product) or the product can get your custom firmware sent to it when the user sets it up.

This last solution simply requires some signal that this Core needs your firmware as opposed to the latest Tinker. It could be that we have the list of device IDs pre-flagged in our database, or your mobile app could send this signal. It also depends on the extent to which you want your product to be hacker-friendly. For example, should the user be able to switch the Core in your product to run Tinker one day and then switch it back to your product code? These are just some of the decisions one has to make on the way to market. Step 1: get a solid prototype built and coded. :smile:

Hope that answers your questions. Cheers!

1 Like

thanks for the info @Zachary

TI provides the SmartConfig libraries for you to build your own iOS/Android/Mac/PC app that can implement the SmartConfig setup. Simply have a small button on your product that put it in SmartConfig mode and have the user download and run your setup app.

That’s the beauty of the CC3000, no fiddling with typing in an AP password on a printer’s “keypad”, no worrying if the user has a special AP with a button on it, no need to connect via USB first, no need to join a temporary ADHOC network first, no hassles! They just download an app and they’re on the network.

If you don’t want to build an app yourself, TI has a Mac/PC Java app available and an iOS/Android app in the App Store/Google Play that your user can download and use in the same fashion.

IMHO, this is the only way you should be doing it, as it’s the easiest for your customers.

1 Like

This is somewhat of a different question within the same topic/thread so I’ll post it here.

I understand the options for allowing an end user to initially setup wifi credentials, but if the spark core is ‘embedded’ within my product how can the user trigger the core to go back to SmartConfig mode. Let’s say my product can be easily moved to another network. I know it can be done using the tiny mode button on the core, but my product will not allow the user easy access to the physical button.

Ultimately, what I envision is a inset ‘wifi reset’ button on the bottom or side of my product (we have all see these…think resetting your router) that the user presses as he or she powers on the unit. Can this be wired to a GPIO pin or do I need to hack the core by soldering to the existing Mode button? If this can be done using a GPIO pin, how would the code be implemented to put the core in config mode as it is being powered on? Finally, would this process leave the existing firmware in tack or would it be overwritten by the default ‘tinker’ firmware?

Thanks,
Pete

Hi @pkucera,

Good question! You could totally add your own “mode” button using one of the gpio pins. In your code, you’d simply check to see if your pin had been up/down for some amount of time (we use 3 seconds), and then you could just re-use the code we’re using to throw the core into listening mode, you can see our implementation here:

https://github.com/spark/core-firmware/blob/master/src/main.cpp#L269

Essentially it’s just setting a flag: WLAN_SMART_CONFIG_START = 1;

Thanks,
David

1 Like

Thanks @Dave, I’ll give that a try this evening and post some results.

-Pete

1 Like

I feel I need to save this snippet somewhere

Can I do with software

  1. switch to USB serial mode,
  2. reset firmware (suicide :smiley: )
  3. set wifi credentials (like with some Spark.function with args)

as well?

Hey @ryotsuke , Yes. All of this should be doable via software. I’m thinking the best place to find out precisely how to do #2 “reset firmware” is to review the bootloader code to understand how it goes about reseting firmware:

then selectively use bits and pieces of this code in your own code. Caveat: Here be dragons, be careful you don’t brick your core! :smile:

Regarding #1, a similar approach using the core-firmware repo, should be helpful.

For #3, not sure at this point. I’m thinking the CLI tool that we’ll be releasing within the next week or two should be helpful in automating this.

If understand all this correctly, I should be able to use the Smart Config android app proviced by TI to discover my device if I just set it in smart config mode (flashing blue) Is that correct?

Yes, you can use the TI Smart Config app, as long as you set the encryption key in the app to “sparkdevices2013”. If you use the Spark app, this key is set by default.

Any updates on adding a spark.set_wifi_credentails(ssid, password) or similar to the API? Will it be available for the Photon?

HI @waspinator

Are you looking for more than this:

http://docs.spark.io/firmware/#wifi-setcredentials

1 Like

Yes, that looks like what I need. Thanks. Still no option to set a static IP though is there?

Is that what they mean by “Hard Code Credentials”

http://docs.spark.io/connect/#appendix-coming-soon-hard-code-credentials

Love this function just not sure how to best apply it. I shipped a device, no app is handy how do we set the credentials with this?

Hi @Herner

If you cannot hard-code the credentials then your device must come up in manual mode and ask the user in some way. LCD front panel etc.

Photon will be very different but given the current limitations of the TI CC3000, this is about a good as it is going to get I think.

And @waspinator

You can set a static IP by calling the TI driver directly but you will likely need to be in manual mode the whole time.

http://processors.wiki.ti.com/index.php/CC3000_Basic_Wi-Fi_example_application_for_MSP430#Static_IP_Configuration

A better approach might be to have your DHCP server give out the same address based on the MAC address of the core–some people call this by the unlikely name of “static dynamic” IP address, but I prefer “reserved DHCP” IP address.

Sounds like you have a new tutorial to write on the LCD route :smile:

1 Like

@bko

I guess DHCP will be good enough. I’m still not clear on what “coming soon” Hard-code credentials feature is going to be. Do the current API functions you linked to only store credentials until the device is rebooted?

This was my idea for makers who want to integrate the spark core into their hardware and have the user flash the core with what is needed :

I used the TI app in iOS. Just to clarify, I had to not only type in the encryption key (sparkdevices2013) but also check off the box at the end of the key field in the app. I didn’t even notice the check box for the longest time. Until I did that, I could not get the wifi configured this way.

1 Like