Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions examples/ArduinoYun/CloudControlsConfig/CloudControlsConfig.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright 2016, Temboo Inc.

#include <Process.h>

void setup() {
// initialize the Bridge
Bridge.begin();
Serial.begin(9600);
Process p;

//intro message
Serial.println("**** Temboo Cloud Controls ****\n");

// update the package list
Serial.print("Updating package listings...");
p.runShellCommand("opkg update");
int returnCode = p.exitValue();
if (returnCode == 0) {
Serial.println("Success!");
} else {
Serial.println("Failed. Make sure your device is connected to the internet properly.");
while(p.available()) {
char c = p.read();
Serial.print(c);
}
return;
}
Serial.println();
// upgrade the Temboo package
Serial.print("Updating Temboo...");
p.runShellCommand("opkg install http://downloads.arduino.cc/openwrtyun/1/packages/temboo_1.3.1-1_ar71xx.ipk");
returnCode = p.exitValue();
if (returnCode == 0) {
Serial.println("Success!");
} else {
Serial.println("Failed.");
while(p.available()) {
char c = p.read();
Serial.print(c);
}
return;
}
Serial.println();

// install python openssl to allow for for ssl connections
Serial.print("Installing python-openssl...");
p.runShellCommand("opkg install python-openssl");
returnCode = p.exitValue();
if (returnCode == 0) {
Serial.println("Success!");
} else {
Serial.println("Failed.");
while(p.available()) {
char c = p.read();
Serial.print(c);
}
return;
}
Serial.println();

// Installing twisted web to work with CoAP gateway
Serial.print("Installing twisted-web...");
p.runShellCommand("opkg install twisted-web");
returnCode = p.exitValue();
if (returnCode == 0) {
Serial.println("Success!");
} else {
Serial.println("Failed.");
while(p.available()) {
char c = p.read();
Serial.print(c);
}
return;
}
Serial.println();

// Configuring zope
Serial.print("Configuring zope...");
p.runShellCommand("touch /usr/lib/python2.7/site-packages/zope/__init__.py");
returnCode = p.exitValue();
if (returnCode == 0) {
Serial.println("Success!");
} else {
Serial.println("Failed.");
while(p.available()) {
char c = p.read();
Serial.print(c);
}
return;
}

Serial.println("Update Complete - your Yun is ready for Cloud Controls!");
}

void loop() {
// do nothing
}
4 changes: 4 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ setCredential KEYWORD2
setSavedInputs KEYWORD2
addInput KEYWORD2
addOutputFilter KEYWORD2
addSensorInput KEYWORD2
addInputExpression KEYWORD2
setDeviceName KEYWORD2
setDeviceType KEYWORD2
setSettingsFileToWrite KEYWORD2
setSettingsFileToRead KEYWORD2
setGatewayAddress KEYWORD2
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ paragraph=Use this library to connect your Arduino or Genuino board to Temboo, m
category=Communication
url=http://www.temboo.com/arduino
architectures=*
version=1.1.6
version=1.1.7
core-dependencies=arduino (>=1.5.0)
8 changes: 6 additions & 2 deletions src/Temboo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ class TembooChoreo : public Process {
void setSettingsFileToWrite(const String& filePath) { addParameter("-w" + filePath);}
void setSettingsFileToRead(const String& filePath) { addParameter("-r" + filePath);}
void setGatewayAddress(const String& addr) { addParameter("-s" + addr);}


void addInputExpression(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
void addSensorInput(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
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);}
void setDeviceName(const String& deviceName) {addParameter("-d" + deviceName);}
void setDeviceType(const String& deviceType) {addParameter("-t" + deviceType);}
};

#else //ARDUINO_AVR_YUN
Expand Down
8 changes: 4 additions & 4 deletions src/TembooCoAPEdgeDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const char HTTP_CODE_PREFIX[] = "HTTP_CODE\x0A\x1F";
const char HTTP_CODE_SUFFIX[] = "\x0A\x1E";
const char TembooCoAPClient::URI_PATH[] = "exec";
const char TIME_URI_PATH[] = "time";
static char HEADER_TIME[] = "x-temboo-time:";

uint16_t TembooCoAPChoreo::s_nextRequestId = 0;

Expand All @@ -54,8 +55,8 @@ TembooCoAPClient::TembooCoAPClient(TembooCoAPIPStack& ipStack, IPAddress gateway
m_blockSize(MAX_BLOCK_SIZE),
m_lastError(NO_ERROR),
m_dataLen(0),
m_respLen(0),
m_txIndex(0),
m_respLen(0),
m_txByteCount(0),
m_respHttpCode(0) {

Expand Down Expand Up @@ -551,7 +552,6 @@ bool TembooCoAPClient::moreBlocksToSend() {

TembooCoAPClient::Result TembooCoAPClient::sendChoreoRequest() {
uint16_t payloadLength = 0;
int16_t blockNum = 0;

generateToken();

Expand Down Expand Up @@ -828,7 +828,7 @@ int TembooCoAPChoreo::run(uint16_t timeoutSecs) {

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


size_t TembooCoAPChoreo::write(uint8_t data) {
size_t TembooCoAPChoreo::write(uint8_t __attribute__ ((unused)) data) {
return 0;
}

Expand Down
Loading