User Tools

Site Tools


oak:tutorials:api_reference

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
oak:tutorials:api_reference [2016/04/08 13:07]
digistump [SoftAP Protocol]
oak:tutorials:api_reference [2017/01/30 14:00] (current)
weaslyd [Particle API]
Line 3: Line 3:
 ===== Particle API ===== ===== Particle API =====
  
-There is a [[https://​docs.particle.io/​reference/​firmware/​photon/#​cloud-functions|comprehensive user guide]] over on the Particle.io site, which provides ​detail ​descriptions and examples of the different built-in functions that you can use.+There is a [[https://​docs.particle.io/​reference/​firmware/​photon/#​cloud-functions|comprehensive user guide]] over on the Particle.io site, which provides ​detailed ​descriptions and examples of the different built-in functions that you can use.
  
 The following Particle Cloud Function APIs are working, whilst the remainder are not available for use (yet). Please note that there is a [[https://​community.particle.io/​t/​doing-something-wrong-with-particle-publish-subscribe/​14926/​10|known]] [[https://​community.particle.io/​t/​particle-subscribe-unique-device-id-not-returning-correct-values/​18422/​5|bug]] in the Particle.subscribe() function, where specifying a unique device ID to subscribe to has no effect. This is a bug on their side, and the current workaround is the specify the MY_DEVICES constant instead, in order to limit the subscription to just the devices you own, rather than including all public events also. The following Particle Cloud Function APIs are working, whilst the remainder are not available for use (yet). Please note that there is a [[https://​community.particle.io/​t/​doing-something-wrong-with-particle-publish-subscribe/​14926/​10|known]] [[https://​community.particle.io/​t/​particle-subscribe-unique-device-id-not-returning-correct-values/​18422/​5|bug]] in the Particle.subscribe() function, where specifying a unique device ID to subscribe to has no effect. This is a bug on their side, and the current workaround is the specify the MY_DEVICES constant instead, in order to limit the subscription to just the devices you own, rather than including all public events also.
Line 18: Line 18:
   * Particle.syncTime() - though time is not yet connected to anything   * Particle.syncTime() - though time is not yet connected to anything
  
 +
 +==== Controlling connection to Particle ====
 +
 +You can use the ''​SYSTEM_MODE()''​ function at the top of your sketch to control your Oak's connection to the Particle cloud, and can choose between three modes (Automatic, Semi-automatic and Manual). The default mode is Automatic, and your Oak will automatically attempt to connect to it's configured Wifi AP, and then try to establish a connection with the Particle cloud. You don't have to specify or do anything to make it do this. 
 +
 +''​SYSTEM_MODE(SEMI_AUTOMATIC)''​ will prevent the Oak from auto connecting to Particle (or auto attempting) - you'll need to call ''​Particle.connect()''​ to connect. It will however still attempt to establish a wifi connection, but that is all - it will not connect to Particle unless you explicitly tell it to. 
 +
 +''​SYSTEM_MODE(MANUAL)''​ will prevent the auto connect to Particle AND not automatically check particle for new data each loop when connected. This means you will need to use ''​Particle.process()''​ function reguarly in order maintain the connection to the Particle cloud, but means you have full control over your Oak, and can ensure that time-sensitive code is handled properly. ​
 +
 +Check out the [[https://​docs.particle.io/​support/​troubleshooting/​mode-switching/​photon/#​semi-automatic-mode|Particle guide on mode switching]] for more details.
 ===== ESP8266 API ===== ===== ESP8266 API =====
  
Line 23: Line 33:
 All of the [[http://​esp8266.github.io/​Arduino/​versions/​2.0.0/​doc/​libraries.html|ESP8266 2.0.0 APIs are available]] All of the [[http://​esp8266.github.io/​Arduino/​versions/​2.0.0/​doc/​libraries.html|ESP8266 2.0.0 APIs are available]]
  
-Some ESP8266 libraries that change the WiFi connection settings or state may break your Oak. So be prepared to break out a 3.3v USB to Serial adapter, and follow the recovery instructions to [[https://​github.com/​digistump/​OakRestore|restore your Oak]] if you mess with thouse!+Some ESP8266 libraries that change the WiFi connection settings or state may break your Oak, or simply prevent your code from compiling (if you are lucky!)Be prepared to break out a 3.3v USB to Serial adapter, and follow the recovery instructions to [[https://​github.com/​digistump/​OakRestore|restore your Oak]] if you mess with those!
  
  
Line 33: Line 43:
  
 bool Oak.connected(void) - returns true if wifi is connected (even if particle is not) bool Oak.connected(void) - returns true if wifi is connected (even if particle is not)
 +
 bool Oak.waitForConnection(void) - loops until wifi connects or 15 seconds pass, returns true if connected at end bool Oak.waitForConnection(void) - loops until wifi connects or 15 seconds pass, returns true if connected at end
  
oak/tutorials/api_reference.1460146078.txt.gz · Last modified: 2016/04/08 13:07 by digistump