Skip to content

Commit a7bdbaa

Browse files
Merge pull request #12 from arduino-libraries/release1.2.1
release1.2.1
2 parents c70e446 + 45dd3e3 commit a7bdbaa

File tree

10 files changed

+163
-18
lines changed

10 files changed

+163
-18
lines changed

examples/ArduinoYun/CloudControlsConfig/CloudControlsConfig.ino renamed to examples/ArduinoYun/TembooDeviceConfig/TembooDeviceConfig.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016, Temboo Inc.
1+
// Copyright 2017, Temboo Inc.
22

33
#include <Process.h>
44

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2017, 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 --force-depends");
32+
returnCode = p.exitValue();
33+
if (returnCode == 0) {
34+
Serial.println("Success!");
35+
} else {
36+
Serial.println("Failed.");
37+
Serial.println("Error number: " +String(returnCode));
38+
while(p.available()) {
39+
char c = p.read();
40+
Serial.print(c);
41+
}
42+
return;
43+
}
44+
Serial.println();
45+
46+
// install python openssl to allow for for ssl connections
47+
Serial.print("Installing python-openssl...");
48+
p.runShellCommand("opkg install python-openssl");
49+
returnCode = p.exitValue();
50+
if (returnCode == 0) {
51+
Serial.println("Success!");
52+
} else {
53+
Serial.println("Failed.");
54+
while(p.available()) {
55+
char c = p.read();
56+
Serial.print(c);
57+
}
58+
return;
59+
}
60+
Serial.println();
61+
62+
// Installing twisted web to work with CoAP gateway
63+
Serial.print("Installing twisted-web...");
64+
p.runShellCommand("opkg install http://downloads.arduino.cc/openwrtyun/1/packages/twisted-web_2.5.0-1_ar71xx.ipk --force-depends");
65+
returnCode = p.exitValue();
66+
if (returnCode == 0) {
67+
Serial.println("Success!");
68+
} else {
69+
Serial.println("Failed.");
70+
while(p.available()) {
71+
char c = p.read();
72+
Serial.print(c);
73+
}
74+
return;
75+
}
76+
Serial.println();
77+
78+
// Configuring zope
79+
Serial.print("Configuring zope...");
80+
p.runShellCommand("opkg install http://downloads.arduino.cc/openwrtyun/1/packages/zope-interface_2.5.0-1_ar71xx.ipk --force-depends");
81+
returnCode = p.exitValue();
82+
if (returnCode == 0) {
83+
p.runShellCommand("touch /usr/lib/python2.7/site-packages/zope/__init__.py");
84+
Serial.println("Success!");
85+
} else {
86+
Serial.println("Failed.");
87+
while(p.available()) {
88+
char c = p.read();
89+
Serial.print(c);
90+
}
91+
return;
92+
}
93+
94+
Serial.println("Update Complete - your Yun is ready for Cloud Controls!");
95+
}
96+
97+
void loop() {
98+
// do nothing
99+
}

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.2.0
9+
version=1.2.1
1010
core-dependencies=arduino (>=1.5.0)

src/Temboo.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ void TembooChoreo::addInput(const String& inputName, const char* inputValue) {
156156
m_inputs.put(inputName.c_str(), inputValue);
157157
}
158158

159+
void TembooChoreo::addInputWithSensor(const String& inputName, const String& inputValue) {
160+
m_expressions.put(inputName.c_str(), inputValue.c_str());
161+
}
162+
163+
void TembooChoreo::addInputWithSensor(const char* inputName, const String& inputValue) {
164+
m_expressions.put(inputName, inputValue.c_str());
165+
}
166+
167+
void TembooChoreo::addInputWithSensor(const char* inputName, const char* inputValue) {
168+
m_expressions.put(inputName, inputValue);
169+
}
170+
159171
void TembooChoreo::addInputExpression(const String& inputName, const String& inputValue) {
160172
m_expressions.put(inputName.c_str(), inputValue.c_str());
161173
}
@@ -168,6 +180,22 @@ void TembooChoreo::addInputExpression(const char* inputName, const char* inputVa
168180
m_expressions.put(inputName, inputValue);
169181
}
170182

183+
void TembooChoreo::addSensorValue(const char* sensorName, int sensorValue, const char* conversion) {
184+
m_sensors.put(sensorName, sensorValue, conversion, NULL, NULL, NULL, NULL, NULL);
185+
}
186+
187+
void TembooChoreo::addSensorValue(const char* sensorName, int sensorValue) {
188+
m_sensors.put(sensorName, sensorValue, NULL, NULL, NULL, NULL, NULL, NULL);
189+
}
190+
191+
void TembooChoreo::addSensorValue(const char* sensorName, int sensorValue, const char* conversion, const char* calibrationValue) {
192+
m_sensors.put(sensorName, sensorValue, conversion, NULL, NULL, NULL, NULL, calibrationValue);
193+
}
194+
195+
void TembooChoreo::addSensorValue(const char* sensorName, int sensorValue, const char* rawLow, const char* rawHigh, const char* scaleLow, const char* scaleHigh) {
196+
m_sensors.put(sensorName, sensorValue, NULL, rawLow, rawHigh, scaleLow, scaleHigh, NULL);
197+
}
198+
171199
void TembooChoreo::addSensorInput(const char* sensorName, int sensorValue, const char* conversion) {
172200
m_sensors.put(sensorName, sensorValue, conversion, NULL, NULL, NULL, NULL, NULL);
173201
}

src/Temboo.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ class TembooChoreo : public Process {
5353
void setSettingsFileToRead(const String& filePath) { addParameter("-r" + filePath);}
5454
void setGatewayAddress(const String& addr) { addParameter("-s" + addr);}
5555
void addInputExpression(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
56+
void addInputWithSensor(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
5657
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
5758
void addSensorInput(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
5859
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion, const String& calibrationValue) {addParameter("-b" + sensorName + ":" + String(sensorValue) + ":" + conversion + ":" + calibrationValue);}
5960
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);}
61+
void addSensorValue(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
62+
void addSensorValue(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
63+
void addSensorValue(const String& sensorName, long sensorValue, const String& conversion, const String& calibrationValue) {addParameter("-b" + sensorName + ":" + String(sensorValue) + ":" + conversion + ":" + calibrationValue);}
64+
void addSensorValue(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);}
6065
void setDeviceName(const String& deviceName) {addParameter("-d" + deviceName);}
6166
void setDeviceType(const String& deviceType) {addParameter("-t" + deviceType);}
6267
};
@@ -112,12 +117,12 @@ class TembooChoreo : public Stream {
112117
void setAppKey(const String& appKey);
113118
void setAppKey(const char* appKey);
114119

115-
// sets the name of the choreo to be executed.
120+
// Sets the name of the choreo to be executed.
116121
// (required)
117122
void setChoreo(const String& choreoPath);
118123
void setChoreo(const char* choreoPath);
119124

120-
// sets the name of the saved inputs to use when executing the choreo
125+
// Sets the name of the saved inputs to use when executing the choreo
121126
// (optional)
122127
void setSavedInputs(const String& savedInputsName);
123128
void setSavedInputs(const char* savedInputsName);
@@ -134,25 +139,35 @@ class TembooChoreo : public Stream {
134139
void setDeviceName(const String& deviceName);
135140
void setDeviceName(const char* deviceName);
136141

137-
// sets an input to be used when executing a choreo.
142+
// Sets an input to be used when executing a choreo.
138143
// (optional or required, depending on the choreo being executed.)
139144
void addInput(const String& inputName, const String& inputValue);
140145
void addInput(const char* inputName, const char* inputValue);
141146
void addInput(const char* inputName, const String& inputValue);
142147
void addInput(const String& inputName, const char* inputValue);
143148

149+
// Sets a Choreo input that contains a sensor value to be converted by Temboo
150+
void addInputWithSensor(const String& inputName, const String& inputValue);
151+
void addInputWithSensor(const char* inputName, const String& inputValue);
152+
void addInputWithSensor(const char* inputName, const char* inputValue);
153+
// Keeping legacy methods
144154
void addInputExpression(const String& inputName, const String& inputValue);
145155
void addInputExpression(const char* inputName, const String& inputValue);
146156
void addInputExpression(const char* inputName, const char* inputValue);
147157

148-
// sets in input that is using a sensor value. Different parameters are needed depending
158+
// Sets in input that is using a sensor value. Different parameters are needed depending
149159
// on the type of sensor being used.
160+
void addSensorValue(const char* sensorName, int sensorValue, const char* conversion);
161+
void addSensorValue(const char* sensorName, int sensorValue);
162+
void addSensorValue(const char* sensorName, int sensorValue, const char* conversion, const char* calibrationValue);
163+
void addSensorValue(const char* sensorName, int sensorValue, const char* rawLow, const char* rawHigh, const char* scaleLow, const char* scaleHigh);
164+
// Keeping legacy methods
150165
void addSensorInput(const char* sensorName, int sensorValue, const char* conversion);
151166
void addSensorInput(const char* sensorName, int sensorValue);
152167
void addSensorInput(const char* sensorName, int sensorValue, const char* conversion, const char* calibrationValue);
153168
void addSensorInput(const char* sensorName, int sensorValue, const char* rawLow, const char* rawHigh, const char* scaleLow, const char* scaleHigh);
154-
155-
// sets an output filter to be used to process the choreo output
169+
170+
// Sets an output filter to be used to process the choreo output
156171
// (optional)
157172
void addOutputFilter(const char* filterName, const char* filterPath, const char* variableName);
158173
void addOutputFilter(const String& filterName, const char* filterPath, const char* variableName);
@@ -163,12 +178,12 @@ class TembooChoreo : public Stream {
163178
void addOutputFilter(const char* filterName, const String& filterPath, const String& variableName);
164179
void addOutputFilter(const String& filterName, const String& filterPath, const String& variableName);
165180

166-
// run the choreo using the current input info
181+
// Run the choreo using the current input info
167182
int run();
168-
// run the choreo with a user specified timeout
183+
// Run the choreo with a user specified timeout
169184
int run(uint16_t timeoutSecs);
170185

171-
// run the choreo on the Temboo server at the given IP address and port
186+
// Run the choreo on the Temboo server at the given IP address and port
172187
int run(IPAddress addr, uint16_t port);
173188
int run(IPAddress addr, uint16_t port, uint16_t timeoutSecs);
174189

src/TembooMQTTEdgeDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
###############################################################################
33
#
4-
# Temboo MQTT edge device library
4+
# Temboo MQTT Edge Device library
55
#
66
# Copyright (C) 2017, Temboo Inc.
77
#

src/TembooMonitoring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <Arduino.h>
2525
#include <Mailbox.h>
26-
#ifdef ARDUINO_ARCH_SAMD
26+
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
2727
#include "avr/dtostrf.h"
2828
#endif
2929
#include "utility/TembooGlobal.h"

src/TembooYunShield.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ class TembooYunShieldChoreo : public Process {
5252
void setSettingsFileToRead(const String& filePath) { addParameter("-r" + filePath);}
5353
void setGatewayAddress(const String& addr) { addParameter("-s" + addr);}
5454
void addInputExpression(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
55+
void addInputWithSensor(const String& inputName, const String& inputValue) { addParameter("-f" + inputName + ":" + inputValue);}
5556
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
5657
void addSensorInput(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
57-
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);}
5858
void addSensorInput(const String& sensorName, long sensorValue, const String& conversion, const String& calibrationValue) {addParameter("-b" + sensorName + ":" + String(sensorValue) + ":" + conversion + ":" + calibrationValue);}
59+
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);}
60+
void addSensorValue(const String& sensorName, long sensorValue, const String& conversion) {addParameter("-n" + sensorName + ":" + String(sensorValue) + ":" + conversion);}
61+
void addSensorValue(const String& sensorName, long sensorValue) {addParameter("-v" + sensorName + ":" + String(sensorValue));}
62+
void addSensorValue(const String& sensorName, long sensorValue, const String& conversion, const String& calibrationValue) {addParameter("-b" + sensorName + ":" + String(sensorValue) + ":" + conversion + ":" + calibrationValue);}
63+
void addSensorValue(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);}
5964
void setDeviceName(const String& deviceName) {addParameter("-d" + deviceName);}
6065
void setDeviceType(const String& deviceType) {addParameter("-t" + deviceType);}
6166
};

src/utility/TembooGPIO.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ void tembooDigitalGPIOInit(TembooGPIOConfig* sensorConfig, TembooSensor* tembooS
7676
tembooDigitalWrite(sensorConfig, defaultValue);
7777
tembooSensor->write = tembooDigitalWrite;
7878
} else {
79-
// probably don't need to do this, but best go on and set it
80-
// TODO: remove /comment after review
8179
sensorConfig->currentValue = tembooDigitalRead(sensorConfig);
8280
tembooSensor->write = NULL;
8381
}
@@ -99,8 +97,6 @@ void tembooAnalogGPIOInit(TembooGPIOConfig* sensorConfig, TembooSensor* tembooSe
9997
tembooAnalogWrite(sensorConfig, defaultValue);
10098
tembooSensor->write = tembooAnalogWrite;
10199
} else {
102-
// probably don't need to do this, but best go on and set it
103-
// TODO: remove /comment after review
104100
sensorConfig->currentValue = tembooAnalogRead(sensorConfig);
105101
tembooSensor->write = NULL;
106102
}

src/utility/TembooWebSocketRequestHandles.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ typedef struct TembooSensor{
6161
int defaultValue;
6262
} TembooSensor;
6363

64+
typedef TembooSensor TembooActuator;
65+
6466
void addWebSocketPinData(int pin, int pinVal, bool requestResponse);
6567
void updateIntervalTime(int intervalTime);
6668

0 commit comments

Comments
 (0)