Author Topic: Does Oak have AP mode/server support?  (Read 3270 times)

davehayden

  • Newbie
  • *
  • Posts: 2
Does Oak have AP mode/server support?
« on: January 19, 2017, 11:07:02 pm »
I'm throwing together a wifi-enabled led strip, to be controlled point-to-point, not over WAN. (Y'know, to put on a fez. Like you do.) Digging for parts I ran across the Oaks I got that went into the "cool Kickstarter stuff I never got around to using" pile. I know the ESP8266 can run in AP mode, which would let me connect my phone to it and tell it to change color, run an animation, whatever. I don't see anything in the Oak docs about AP mode but I think I read that that I can use the ESP8266 Arduino library directly, though it can break the cloud stuff. I'm wondering if I add a switch/button to a random GPIO and check for that, can I get my wifi server but keep uploading over wifi too? Is there something I should do to turn off "cloud mode" if i'm running in "server mode"?

..Or will it be easier just wiring an ESP8266 module to a Teensy?
« Last Edit: January 19, 2017, 11:11:05 pm by davehayden »

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Does Oak have AP mode/server support?
« Reply #1 on: January 20, 2017, 12:15:14 am »
As long as you don't mind power cycling the Oak and holding down a button or something whilst doing so to put into config mode to allow for OTA programming, it should be easy-peasy.... or as easy-peasy as things can be in Oak land (it sometimes trips you on what appears to be the simplest of desires, but that just enrages um... encourages you to work it out and triumph over the beast!) :-O  ;D

Basically, I would put the oak into SYSTEM_MODE(MANUAL) [just put that at the very top of your sketch... not in setup or a function... you can put it right on the first line of the sketch if you wish. This will tell the Oak that you want to be the boss of the WiFi and Particle connectivity, and you can manage it all then. You can then (hopefully) go about setting up the AP. If you want, put it into STA+AP mode so it can still make an internet/particle connection and enable particle if you so desire, or don't bother connecting to particle at all. When you do want to upload a new program OTA, all you do is pull the power, connect P1 to GND, power the Oak up again, and after 2-3 seconds release the P1-GND connection. It will now be doing the triple blink config mode jig, and will connect to it's previously configured AP and try to get the Particle connection so it can be programmed as normal.

Now, that was the easy bit... getting the AP mode working... you're on your own for that one! :-P I haven't had any need to play with that side of things yet, so I don't know how co-operative the Oaks WiFi config set is on that front. It may very well just work out of the box...  8)

One setting in the Arduino IDE I would recommend changing regardless is changing the config mode of the Oak from automatic safe mode to manual config mode only... this will prevent the Oak from auto-rebooting when the wifi/internet connection is iffy and it thinks a reboot will fix that problem. Depending onyour application, that setting is fine, but for the stuff I'm doing, I prefer to be the boss and tell IT when to reboot if needed... not find out three days later that it is in safe mode and doing nothing whatsoever!

digi_guy

  • Jr. Member
  • **
  • Posts: 87
Re: Does Oak have AP mode/server support?
« Reply #2 on: January 20, 2017, 06:44:08 pm »
Using the Oak in AP mode is pretty easy, check out this thread for an example I wrote that had two Oaks talking to eachother.

https://digistump.com/board/index.php/topic,2171.msg10125.html#msg10125


davehayden

  • Newbie
  • *
  • Posts: 2
Re: Does Oak have AP mode/server support?
« Reply #3 on: January 22, 2017, 09:35:20 pm »
PeterF: Thanks for the confirmation that this is doable, or at least tryable! I think I'm starting to get what you mean about the system [dis|en]couraging you: I spent a couple hours on Friday just trying to flash the thing from Particle (gave up on the local server after reading that it's not very well supported) and never got out of config mode. Tried again tonight, no problem. Sending code 900 miles away to put it on the device that's right next to me still seems totally wrong, but hey, it worked! I didn't know about changing SYSTEM_MODE or using P1 to boot into config yet. Thanks! Looks like all the puzzle pieces are in place, just need to fit them together.

digi_guy: Awesome, thanks so much! Looks like you've saved me at least a couple of hours of googling and digging through API reference. :)

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Does Oak have AP mode/server support?
« Reply #4 on: January 24, 2017, 06:14:36 pm »
Only 900 miles away!!! You're lucky then! Assuming the servers are in the US, it is 7,500 miles each way for mine to get reprogrammed.... so 15,000 round trip, to reach the Oak a metre from where I'm standing! ;) (and even further for the poor Aussie cousins....)