Skip to content

Commit 0e19f41

Browse files
Version 1.1.7 update
1 parent 3244a7b commit 0e19f41

File tree

10 files changed

+809
-8
lines changed

10 files changed

+809
-8
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright 2016, Temboo Inc.
2+
3+
#include <Process.h>
4+
5+
void setup() {
6+
// initialize the Bridge
7+
Bridge.begin();
8+
Serial.begin(9600);
9+
Process p;
10+
11+
//intro message
12+
Serial.println("**** Temboo Cloud Controls ****\n");
13+
14+
// update the package list
15+
Serial.print("Updating package listings...");
16+
p.runShellCommand("opkg update");
17+
int returnCode = p.exitValue();
18+
if (returnCode == 0) {
19+
Serial.println("Success!");
20+
} else {
21+
Serial.println("Failed. Make sure your device is connected to the internet properly.");
22+
while(p.available()) {
23+
char c = p.read();
24+
Serial.print(c);
25+
}
26+
return;
27+
}
28+
Serial.println();
29+
// upgrade the Temboo package
30+
Serial.print("Updating Temboo...");
31+
p.runShellCommand("opkg install http://downloads.arduino.cc/openwrtyun/1/packages/temboo_1.3.1-1_ar71xx.ipk");
32+
returnCode = p.exitValue();
33+
if (returnCode == 0) {
34+
Serial.println("Success!");
35+
} else {
36+
Serial.println("Failed.");
37+
while(p.available()) {
38+
char c = p.read();
39+
Serial.print(c);
40+
}
41+
return;
42+
}
43+
Serial.println();
44+
45+
// install python openssl to allow for for ssl connections
46+
Serial.print("Installing python-openssl...");
47+
p.runShellCommand("opkg install python-openssl");
48+
returnCode = p.exitValue();
49+
if (returnCode == 0) {
50+
Serial.println("Success!");
51+
} else {
52+
Serial.println("Failed.");
53+
while(p.available()) {
54+
char c = p.read();
55+
Serial.print(c);
56+
}
57+
return;
58+
}
59+
Serial.println();
60+
61+
// Installing twisted web to work with CoAP gateway
62+
Serial.print("Installing twisted-web...");
63+
p.runShellCommand("opkg install twisted-web");
64+
returnCode = p.exitValue();
65+
if (returnCode == 0) {
66+
Serial.println("Success!");
67+
} else {
68+
Serial.println("Failed.");
69+
while(p.available()) {
70+
char c = p.read();
71+
Serial.print(c);
72+
}
73+
return;
74+
}
75+
Serial.println();
76+
77+
// Configuring zope
78+
Serial.print("Configuring zope...");
79+
p.runShellCommand("touch /usr/lib/python2.7/site-packages/zope/__init__.py");
80+
returnCode = p.exitValue();
81+
if (returnCode == 0) {
82+
Serial.println("Success!");
83+
} else {
84+
Serial.println("Failed.");
85+
while(p.available()) {
86+
char c = p.read();
87+
Serial.print(c);
88+
}
89+
return;
90+
}
91+
92+
Serial.println("Update Complete - your Yun is ready for Cloud Controls!");
93+
}
94+
95+
void loop() {
96+
// do nothing
97+
}

keywords.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ setCredential KEYWORD2
3333
setSavedInputs KEYWORD2
3434
addInput KEYWORD2
3535
addOutputFilter KEYWORD2
36+
addSensorInput KEYWORD2
37+
addInputExpression KEYWORD2
38+
setDeviceName KEYWORD2
39+
setDeviceType KEYWORD2
3640
setSettingsFileToWrite KEYWORD2
3741
setSettingsFileToRead KEYWORD2
3842
setGatewayAddress KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ paragraph=Use this library to connect your Arduino or Genuino board to Temboo, m
66
category=Communication
77
url=http://www.temboo.com/arduino
88
architectures=*
9-
version=1.1.6
9+
version=1.1.7
1010
core-dependencies=arduino (>=1.5.0)

src/Temboo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ class TembooChoreo : public Process {
4848
void setSettingsFileToWrite(const String& filePath) { addParameter("-w" + filePath);}
4949
void setSettingsFileToRead(const String& filePath) { addParameter("-r" + filePath);}
5050
void setGatewayAddress(const String& addr) { addParameter("-s" + addr);}
51-
52-
51+
void addInputExpression(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
52+
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
53+
void addSensorInput(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
54+
void addSensorInput(const String& sensorName, long sensorValue, const String& rawLow, const String& rawHigh, const String& scaleLow, const String& scaleHigh) {addParameter("-m" + sensorName + ":" + String(sensorValue) + ":" + rawLow+ ":" + rawHigh+ ":" + scaleLow+ ":" + scaleHigh);}
55+
void setDeviceName(const String& deviceName) {addParameter("-d" + deviceName);}
56+
void setDeviceType(const String& deviceType) {addParameter("-t" + deviceType);}
5357
};
5458

5559
#else //ARDUINO_AVR_YUN

src/TembooCoAPEdgeDevice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const char HTTP_CODE_PREFIX[] = "HTTP_CODE\x0A\x1F";
4141
const char HTTP_CODE_SUFFIX[] = "\x0A\x1E";
4242
const char TembooCoAPClient::URI_PATH[] = "exec";
4343
const char TIME_URI_PATH[] = "time";
44+
static char HEADER_TIME[] = "x-temboo-time:";
4445

4546
uint16_t TembooCoAPChoreo::s_nextRequestId = 0;
4647

@@ -54,8 +55,8 @@ TembooCoAPClient::TembooCoAPClient(TembooCoAPIPStack& ipStack, IPAddress gateway
5455
m_blockSize(MAX_BLOCK_SIZE),
5556
m_lastError(NO_ERROR),
5657
m_dataLen(0),
57-
m_respLen(0),
5858
m_txIndex(0),
59+
m_respLen(0),
5960
m_txByteCount(0),
6061
m_respHttpCode(0) {
6162

@@ -551,7 +552,6 @@ bool TembooCoAPClient::moreBlocksToSend() {
551552

552553
TembooCoAPClient::Result TembooCoAPClient::sendChoreoRequest() {
553554
uint16_t payloadLength = 0;
554-
int16_t blockNum = 0;
555555

556556
generateToken();
557557

@@ -828,7 +828,7 @@ int TembooCoAPChoreo::run(uint16_t timeoutSecs) {
828828

829829
//Unauthroized, need to update the time
830830
if (httpCode == 401 && i == 0) {
831-
find("x-temboo-time:");
831+
find(HEADER_TIME);
832832
TembooCoAPSession::setTime((unsigned long)this->parseInt());
833833
} else {
834834
TEMBOO_TRACE("DBG: ");
@@ -922,7 +922,7 @@ int TembooCoAPChoreo::read() {
922922
}
923923

924924

925-
size_t TembooCoAPChoreo::write(uint8_t data) {
925+
size_t TembooCoAPChoreo::write(uint8_t __attribute__ ((unused)) data) {
926926
return 0;
927927
}
928928

0 commit comments

Comments
 (0)