Skip to content

Instantly share code, notes, and snippets.

@indraastra
indraastra / main.ino
Last active January 19, 2016 02:27
Returning Structs
#include "pumpstate.h"
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
delay(1000);
initPumpState();
@indraastra
indraastra / WifiMonitor.ino
Last active January 18, 2016 21:06
WifiMonitor.ino
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
#define UPDATE_IF_CHANGED(var, new_value, desc) {\
if ((new_value) != (var)) {\
(var) = (new_value);\
Serial.print((desc));\
Serial.print(": ");\
Serial.println((var));\
}\
@indraastra
indraastra / main.ino
Created December 15, 2015 18:42
Compiler error issue
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("Starting!");
}
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
delay(1000);
}
void manageConnection() {
if (!Particle.connected()) {
@indraastra
indraastra / listening.ino
Created October 19, 2015 22:16
Listening mode w/ hasCredentials blocking
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
bool _connectingToCloud = false;
void setup() {
Serial.begin(9600);
delay(2000);
}
@indraastra
indraastra / packet_test.py
Last active October 14, 2015 18:20
one or two packets
# REQUIRES PYTHON 3
#
# $ python3 packet_test.py 1
# sending 1 packet
# {'r': -1024}
# $ python3 packet_test.py 2
# sending 2 packets
# {'r': 0}
import socket
@indraastra
indraastra / WifiManual.ino
Last active October 13, 2015 17:56
Bring up and maintain wifi connection in MANUAL mode
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
delay(1000);
}
bool _connectingToCloud = false;
void manageConnection() {
@indraastra
indraastra / counting.ino
Created October 13, 2015 17:29
Count even while disconnected
#include "application.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
//Settings
String DeviceID = System.deviceID();
retained uint32_t value = 0;
int retry_count = 0;
@indraastra
indraastra / main.ino
Last active October 9, 2015 00:10
WiFi Status v2
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
delay(1000);
}
void loop() {
@indraastra
indraastra / main.ino
Created October 8, 2015 21:15
WiFi Status Monitor
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
#define UPDATE_IF_CHANGED(var, new_value, desc) {\
if ((new_value) != (var)) {\
(var) = (new_value);\
Serial.print((desc));\
Serial.print(": ");\
Serial.println((var));\
}\