My mistake, I forgot that USB is handled within the event loop.
So part 2.c was a mistake, you'll need the
main_body to be looping for USB to be responsive.
There are a few other ways to force an entry point into the smartconfig function. One is to expose a lua binding (it doesn't need to be compliant with the API) just for testing it. It's basically running through the same steps as #3 but with a test function like
wifi.testSmartConfig. Then you can upload a js script that consists of the following:
var wifi = require('wifi-cc3000');
And this will call the C function.
Another way is to add in a command to the CLI. That way you can issue something like
tessel wifi --smartconfig and have it enter smartconfig mode. Doing this will require that you:
- fork the CLI https://github.com/tessel/cli
- Add a new command that Tessel will listen for on incoming USB messages: https://github.com/tessel/firmware/blob/master/src/main.c#L173. Once that command gets called, make it call into the SmartConfig C function.
- Add the same command here in the CLI: https://github.com/tessel/cli/blob/master/src/commands.js#L67. Note that the CLI commands are in hex and the commands that Tessel checks for is in ASCII, though both are the same hex value.
- Add in a prototype function (like
prototype.smartconfig) on here that calls the CLI command: https://github.com/tessel/cli/blob/master/src/commands.js#L215
- Modify the wifi command to check for a
--smartconfig flag: https://github.com/tessel/cli/blob/master/bin/tessel-wifi.js#L58.
- Add on a check here: https://github.com/tessel/cli/blob/master/bin/tessel-wifi.js#L72 that calls into
client.smartconfig to issue the command over to Tessel. You can also put in a
client.listen(true); to catch all the TM_DEBUG messages in here.
- Link your cloned version of Tessel CLI to be called instead of the one you installed globally. cd into your forked repo and run
Another way is to test it without USB feedback/debug messages by just toggling LEDs... I don't really recommend this way.
You can restore/update new firmware by putting Tessel in boot mode and running
tessel update again.