Skip to content

Commit f33a8cf

Browse files
author
Travis CI
committed
examples for the particle
1 parent 75fadac commit f33a8cf

File tree

3 files changed

+30
-235
lines changed

3 files changed

+30
-235
lines changed

particle/examples/local-compile/local-compile.ino

-211
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
// This #include statement was automatically added by the Spark IDE.
2-
#include "tentacle-particle/tentacle-particle.h"
2+
#include "tentacle-particle.h"
33

4-
// #define server "tentacle.octoblu.com"
5-
// #define port 80
4+
#define server "tentacle.octoblu.com"
5+
#define port 80
66

7+
// IPAddress server(192,168,100,9);
8+
// #define port 8111
79

8-
IPAddress server(192,168,0,112);
9-
#define port 8111
10-
11-
static const char uuid[] = "ff12c403-04c7-4e63-9073-2e3b1f8e4450";
12-
static const char token[] = "28d2c24dfa0a5289799a345e683d570880a3bc41";
10+
static const char uuid[] = "91f33395-847a-4d71-af25-fd3abe3371bc";
11+
static const char token[] = "24fefe99413b16283f41c7cf8c82d376211392f7";
1312

1413
TCPClient conn;
1514

1615
TentacleArduino tentacle;
1716
Pseudopod pseudopod(conn, conn, tentacle);
1817

18+
uint32_t lastPing = 0;
19+
1920
void setup() {
2021
Serial.begin(9600);
2122
Serial.println(F("The Day of the Tentacle has begun!"));
22-
waitForWifi();
2323
connectToServer();
2424
}
2525

2626
void loop() {
27-
if(!WiFi.ready()) {
28-
Serial.println(F("WiFi wasn't ready. waiting."));
29-
}
30-
if (!conn.connected()) {
27+
if (!isConnected()) {
3128
conn.stop();
3229
connectToServer();
3330
}
@@ -40,26 +37,36 @@ void loop() {
4037
Serial.print(configSize);
4138
Serial.print(F(" bytes written while broadcasting pins"));
4239
}
40+
4341
}
4442

45-
void readData() {
43+
bool isConnected() {
44+
if(!conn.connected()) {
45+
return false;
46+
}
47+
48+
//send keepalive every 5 seconds.
49+
if( (millis() - lastPing) > 5000) {
50+
Serial.println(F("Pinging the server"));
51+
Serial.flush();
52+
lastPing = millis();
53+
return pseudopod.isConnected();
54+
55+
}
56+
57+
return true;
58+
}
4659

60+
void readData() {
4761
while (conn.available()) {
4862
Serial.println(F("Received message"));
4963
Serial.flush();
5064

5165
if(pseudopod.readMessage() == TentacleMessageTopic_action) {
66+
Serial.println(F("Got an action message"));
5267
pseudopod.sendPins();
5368
}
5469
}
55-
56-
}
57-
58-
void waitForWifi() {
59-
while(!WiFi.ready()) {
60-
Serial.println(F("Waiting for wifi"));
61-
delay(200);
62-
}
6370
}
6471

6572
void connectToServer() {
@@ -77,5 +84,4 @@ void connectToServer() {
7784
size_t authSize = pseudopod.authenticate(uuid, token);
7885
Serial.print(authSize);
7986
Serial.println(F(" bytes written for authentication"));
80-
8187
}

particle/local-compile.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BASE_DIR=`pwd`
66
BUILD_DIR=$BASE_DIR/build/$PLATFORM
77
LIB_DIR=$BASE_DIR/deploy/$PLATFORM/firmware
88
BIN_DIR=$BUILD_DIR/bin
9-
SRC_FILE=$BASE_DIR/$PLATFORM/examples/local-compile/local-compile.ino
9+
SRC_FILE=$BASE_DIR/$PLATFORM/examples/tentacle-particle/tentacle-particle.ino
1010

1111
echo "Compiling locally for testing.\n\n"
1212
rm -rf $BIN_DIR

0 commit comments

Comments
 (0)