Worst Case Scenario : Control Spark Using Smart Config

Imagine a scenario where my Spark is the only thing that controls the light in my room. Its late in the night and I don’t want my mom to know that I’m playing Minecraft all night so I need to switch Off the light, but the router fails before I get to switch it Off. I really need to switch this damn light Off.

Keeping in mind the highly probable scenario, is there a way to hack the Smart Config code on the Spark so that I could control things. This is how I’d like to go about it:

  1. Put the :spark: in Smart Config mode automatically when there’s no access to the internet by setting the flag WLAN_SMART_CONFIG_START = 1;
  2. On the Smart Config App, I would like to send the SSID - “controlLight” and PASSWORD - “false”.
  3. On the Spark Firmware:
  • Write a function controlLight() which controls the state of the digitalpin
  • Read the SSID as a string or char array and compare it to “controlLight”.
  • If true; Read the Password as a string and char array and compare it to “true” or “false”.
  • If true; Call the function controlLight(false) which turns the light Off.

So can someone tell me if its possible to do. If so, in which file(s) of the firmware would I have too make changes in to make it happen?

Thanks :smile:

Or you could add a button that you can press to toggle the light?

Alternate Suggestion: Use a damn light switch you lazy bastard! XD (Kidding, of course!)

@timb Haha! I forgot to mention that its a hypothetical scenario where I don’t have switches on the Spark or on the wall for the lights :smile:

I know it won’t be a generalized solution accepted by Spark since it solves very few problems. I was wondering which files I would need to edit to get this happening. It would be cool to have some minimal control over the Spark during emergencies if all else fails.

I think the idea would be to add multiple wifi profiles which should/can be done with the :spark: core.

If it fails to connect to one, look for another to connect.

Maybe adding a wifi profile to your phone AP then on it when the other is down.

@kennethlimcp I’m not sure if you got what I was aiming for.

What I want to do is, send a command to the Spark to turn on/off a light using the Smart Config App. I want to do this using the SSID and Password that I enter on the App.

The Spark checks for an incoming SSID & Password while it is in the Smart Config mode. If the SSID matches the string “controlLight” then I want it to bypass adding the Wifi Profile and instead call a function called “controlLight” (or any other function). And I want the Password to be treated as the parameters for that function call.

I hope I was clearer now :disappointed:

The thing is… if your router is down, the credentials you send wont reach the core.

App --> router —> wifi signal --> core picks up

If ‘router failed’ means power cut off, then what I mentioned above happens.

If ‘router failed’ means connection lost… I’m not sure if your app can send the credentials successfully through the router.

Cos if the router and core connection recovers, it just connects back :slight_smile:

Only when the failsafe modes of Spark.io are nuclear arsenal Fukushima ready will I be satisfied. I’m with the original poster on this :smile:

HI @nitnut

I hope you will take this in a positive way, but the reason you are not getting a lot of answers here is that your request is very out of the ordinary. In more physical terms, it is like you are asking, “I want to use my front-door lock to turn on and off the lights in my house and I want the key that I use (any key) to control which light is switched.”

Now I am sure that something like this could be built, but you have to realize you are not using the lock or the keys in the way that was intended. If you asked an electrician how to do this, you would get some very puzzled looks.

So in order to make this work, you are going to have to learn a lot about how locks and keys and lighting all work at a very low level of detail. There is not a lot of help for you because no one else has thought to use locks and keys like this and frankly no one else may want to use their lock as a light controller. Certainly the folks that designed the lock didn’t think people would want to use it in this way.

I understand your intention and that the Spark core is far from perfect, but I think you have a lot of work in front of you. Fortunately all the source code is out there on github and with a lot of time and research you might be able to get this to work, but it is a big challenge. Just don’t be surprised if people here say they don’t know how to help you.

1 Like

@kennethlimcp You just blew my mind! I had run into the CC3000 about a year ago and for some reason I had planted this idea in my mind that the phone sends data to the cc3000 via some adhoc data transfer.

I just went in search of some answers and found this:
http://electronics.stackexchange.com/questions/61704/how-does-ti-cc3000-wifi-smart-config-work .
&
http://crypto.stackexchange.com/questions/10977/encoding-information-in-packet-lengths-to-actively-sidestep-encryption/11170#1117 .
It’s a really weird technique they use to make Smart Config work :smiley:

@bko Your post came in right before I posted. I totally get that its a highly custom solution I’m looking for so I’m going to make my question be more about pointing me in the right direction than expecting a solution. Thank you :smile:

Updated Question : Can anyone tell me in which file can I access the SSID & Password that are decrypted, parsed and available as strings but still haven’t been added to the wifi profile yet? I can take over from there :blush:

1 Like

I would also love to know where it gets stored :smiley:

Looked through the core-firmware and see them using stuff like memset but not exactly sure what it doing :smiley:

OK, I am glad you appreciate the slog you are in for. :smiley:

I don’t think that the SSID and password ever get sent to the ARM host with Smart Config–it all happens inside the TI CC3000 as I see it. Here is a TI Wiki that shows the flow control.

http://processors.wiki.ti.com/index.php/CC3000_Smart_Config

Certainly on the adding a Wifi profile from the driver, like when you use USB to store SSID and password profile on the Spark, there is a write profile function but not a read profile function.

So just because there is no driver call to access SSID/password does not mean you cannot get to it, but you have some detective work to do.

I'm guessing you don't really want to do this, but you really just want to use the SmartConfig as an ADHOC data transfer method. As BKO pointed out, that's not going to happen since the CC3000 decodes the encoded SSID/PASSWORD internally. You could only really key off of the fact that you now have a connection, where as before you didn't. That's going to be too slow of a "switch" in my opinion.

So let's get back to your "problem"... what do you really want to do? We'll engineer a "good" solution for you :wink:

2 Likes

@nitnut

There is a point in the CC3000 code where the profile info is readable (in the clear) see I imagine you could add a weak callouts to the app at strategic points in that routine to get the contents of the smartconfig payload, and then abort or erase the bogus profile. Good luck with it,

1 Like

@bko Ahh I guess that’s another revelation for me, that the SSID & Password are completely handled by the CC3000 and currently out of my reach it seems. I was under the impression that Wifi Profiles were stored somewhere which is accessible by the micro-controller.

@BDub Adhoc Data transfer is what I really want! :disappointed: … I didn’t mind having to create a temporary AP on my phone (which is just two clicks on any smart phone hence not a burden on the User). I understand that since I have an AP I might as well use the Spark in the usual intended way, but this adhoc data transfer is something I wanted to explore :smile:

@david_s5 Perhaps a little beyond my level but I will definitely look into this and try to extract something if possible over the weekend!..

Until then I suppose I should close the topic. I apologize for wasting any time. Thanks you all of the help! :smile:

1 Like