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
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.8
version=1.2.0
core-dependencies=arduino (>=1.5.0)
46 changes: 44 additions & 2 deletions src/Temboo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo Arduino library
#
# Copyright 2015, Temboo Inc.
# Copyright 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -121,6 +121,21 @@ void TembooChoreo::setProfile(const char* profileName) {
m_preset.put(profileName);
}

void TembooChoreo::setDeviceType(const String& deviceType) {
m_deviceType.put(deviceType.c_str());
}

void TembooChoreo::setDeviceType(const char* deviceType) {
m_deviceType.put(deviceType);
}

void TembooChoreo::setDeviceName(const String& deviceName) {
m_deviceName.put(deviceName.c_str());
}

void TembooChoreo::setDeviceName(const char* deviceName) {
m_deviceName.put(deviceName);
}

void TembooChoreo::addInput(const String& inputName, const String& inputValue) {
m_inputs.put(inputName.c_str(), inputValue.c_str());
Expand All @@ -141,6 +156,33 @@ void TembooChoreo::addInput(const String& inputName, const char* inputValue) {
m_inputs.put(inputName.c_str(), inputValue);
}

void TembooChoreo::addInputExpression(const String& inputName, const String& inputValue) {
m_expressions.put(inputName.c_str(), inputValue.c_str());
}

void TembooChoreo::addInputExpression(const char* inputName, const String& inputValue) {
m_expressions.put(inputName, inputValue.c_str());
}

void TembooChoreo::addInputExpression(const char* inputName, const char* inputValue) {
m_expressions.put(inputName, inputValue);
}

void TembooChoreo::addSensorInput(const char* sensorName, int sensorValue, const char* conversion) {
m_sensors.put(sensorName, sensorValue, conversion, NULL, NULL, NULL, NULL, NULL);
}

void TembooChoreo::addSensorInput(const char* sensorName, int sensorValue) {
m_sensors.put(sensorName, sensorValue, NULL, NULL, NULL, NULL, NULL, NULL);
}

void TembooChoreo::addSensorInput(const char* sensorName, int sensorValue, const char* conversion, const char* calibrationValue) {
m_sensors.put(sensorName, sensorValue, conversion, NULL, NULL, NULL, NULL, calibrationValue);
}

void TembooChoreo::addSensorInput(const char* sensorName, int sensorValue, const char* rawLow, const char* rawHigh, const char* scaleLow, const char* scaleHigh) {
m_sensors.put(sensorName, sensorValue, NULL, rawLow, rawHigh, scaleLow, scaleHigh, NULL);
}

void TembooChoreo::addOutputFilter(const char* outputName, const char* filterPath, const char* variableName) {
m_outputs.put(outputName, filterPath, variableName);
Expand Down Expand Up @@ -219,7 +261,7 @@ int TembooChoreo::run(IPAddress addr, uint16_t port, uint16_t timeoutSecs) {

for (int i = 0; i < 2; i++) {
unsigned long timeoutBeginSecs = session.getTime();
if (0 != session.executeChoreo(m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_outputs, m_preset)) {
if (0 != session.executeChoreo(m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_expressions, m_sensors, m_outputs, m_preset, m_deviceType, m_deviceName)) {
httpCode = 0;
break;
}
Expand Down
30 changes: 29 additions & 1 deletion src/Temboo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo Arduino library
#
# Copyright 2015, Temboo Inc.
# Copyright 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,10 @@
#ifndef TEMBOO_H_
#define TEMBOO_H_

#ifndef TEMBOO_LIBRARY_VERSION
#define TEMBOO_LIBRARY_VERSION 2
#endif

#include <Arduino.h>

#if defined (ARDUINO_AVR_YUN) || defined (ARDUINO_AVR_TRE)
Expand Down Expand Up @@ -67,8 +71,11 @@ class TembooChoreo : public Process {
#include <Client.h>
#include <IPAddress.h>
#include "utility/ChoreoInputSet.h"
#include "utility/ChoreoInputExpressionSet.h"
#include "utility/ChoreoSensorInputSet.h"
#include "utility/ChoreoOutputSet.h"
#include "utility/ChoreoPreset.h"
#include "utility/ChoreoDevice.h"

#define TEMBOO_ERROR_OK (0)
#define TEMBOO_ERROR_ACCOUNT_MISSING (201)
Expand Down Expand Up @@ -121,12 +128,29 @@ class TembooChoreo : public Stream {
void setProfile(const String& profileName);
void setProfile(const char* profileName);

void setDeviceType(const String& deviceType);
void setDeviceType(const char* deviceType);

void setDeviceName(const String& deviceName);
void setDeviceName(const char* deviceName);

// sets an input to be used when executing a choreo.
// (optional or required, depending on the choreo being executed.)
void addInput(const String& inputName, const String& inputValue);
void addInput(const char* inputName, const char* inputValue);
void addInput(const char* inputName, const String& inputValue);
void addInput(const String& inputName, const char* inputValue);

void addInputExpression(const String& inputName, const String& inputValue);
void addInputExpression(const char* inputName, const String& inputValue);
void addInputExpression(const char* inputName, const char* inputValue);

// sets in input that is using a sensor value. Different parameters are needed depending
// on the type of sensor being used.
void addSensorInput(const char* sensorName, int sensorValue, const char* conversion);
void addSensorInput(const char* sensorName, int sensorValue);
void addSensorInput(const char* sensorName, int sensorValue, const char* conversion, const char* calibrationValue);
void addSensorInput(const char* sensorName, int sensorValue, const char* rawLow, const char* rawHigh, const char* scaleLow, const char* scaleHigh);

// sets an output filter to be used to process the choreo output
// (optional)
Expand Down Expand Up @@ -162,8 +186,12 @@ class TembooChoreo : public Stream {

protected:
ChoreoInputSet m_inputs;
ChoreoInputExpressionSet m_expressions;
ChoreoSensorInputSet m_sensors;
ChoreoOutputSet m_outputs;
ChoreoPreset m_preset;
ChoreoDevice m_deviceType;
ChoreoDevice m_deviceName;

const char* m_accountName;
const char* m_appKeyValue;
Expand Down
4 changes: 2 additions & 2 deletions src/TembooCoAPEdgeDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo CoAP Edge Device library
#
# Copyright (C) 2015, Temboo Inc.
# Copyright (C) 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -789,7 +789,7 @@ int TembooCoAPChoreo::run(uint16_t timeoutSecs) {
m_client.getNextMessageID();
TEMBOO_TRACE("DBG: ");
TEMBOO_TRACELN("Sending request");
rc = session.executeChoreo(m_requestId, m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_outputs, m_preset);
rc = session.executeChoreo(m_requestId, m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_expressions, m_sensors, m_outputs, m_preset, m_deviceType, m_deviceName);
if (SUCCESS != rc) {
goto ErrorExit;
}
Expand Down
12 changes: 11 additions & 1 deletion src/TembooCoAPEdgeDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo CoAP Edge Device library
#
# Copyright (C) 2015, Temboo Inc.
# Copyright (C) 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,9 @@
#ifndef TEMBOOCOAP_H_
#define TEMBOOCOAP_H_

#ifndef TEMBOO_LIBRARY_VERSION
#define TEMBOO_LIBRARY_VERSION 2
#endif

///////////////////////////////////////////////////////
// BEGIN ARDUINO NON-YUN SUPPORT
Expand All @@ -34,8 +37,11 @@

#include "utility/TembooCoAPIPStack.h"
#include "utility/ChoreoInputSet.h"
#include "utility/ChoreoInputExpressionSet.h"
#include "utility/ChoreoSensorInputSet.h"
#include "utility/ChoreoOutputSet.h"
#include "utility/ChoreoPreset.h"
#include "utility/ChoreoDevice.h"
#include "utility/CoapMsg.h"
#include "utility/CoapMessageLayer.h"
#include "utility/CoapRRLayer.h"
Expand Down Expand Up @@ -278,8 +284,12 @@ class TembooCoAPChoreo : public Stream {
const char* m_path;

ChoreoInputSet m_inputs;
ChoreoInputExpressionSet m_expressions;
ChoreoSensorInputSet m_sensors;
ChoreoOutputSet m_outputs;
ChoreoPreset m_preset;
ChoreoDevice m_deviceType;
ChoreoDevice m_deviceName;

char m_httpCodeStr[4];
char* m_respData;
Expand Down
4 changes: 2 additions & 2 deletions src/TembooMQTTEdgeDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo MQTT Edge Device library
#
# Copyright (C) 2015, Temboo Inc.
# Copyright (C) 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -714,7 +714,7 @@ int TembooMQTTChoreo::run(uint16_t timeoutSecs) {

ArduinoTimer timer(timeoutSecs * 1000L);

int rc = session.executeChoreo( m_requestId, m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_outputs, m_preset);
int rc = session.executeChoreo( m_requestId, m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_expressions, m_sensors, m_outputs, m_preset, m_deviceType, m_deviceName);
if (TEMBOO_ERROR_OK != rc) {
goto ErrorExit;
}
Expand Down
13 changes: 12 additions & 1 deletion src/TembooMQTTEdgeDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo MQTT edge device library
#
# Copyright (C) 2015, Temboo Inc.
# Copyright (C) 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,10 @@
#ifndef TEMBOOMQTT_H_
#define TEMBOOMQTT_H_

#ifndef TEMBOO_LIBRARY_VERSION
#define TEMBOO_LIBRARY_VERSION 2
#endif

#include <Arduino.h>


Expand All @@ -37,8 +41,11 @@

#include "utility/TembooMQTTIPStack.h"
#include "utility/ChoreoInputSet.h"
#include "utility/ChoreoInputExpressionSet.h"
#include "utility/ChoreoSensorInputSet.h"
#include "utility/ChoreoOutputSet.h"
#include "utility/ChoreoPreset.h"
#include "utility/ChoreoDevice.h"

#define IS_EMPTY(s) (NULL == s || '\0' == *s)

Expand Down Expand Up @@ -197,8 +204,12 @@ class TembooMQTTChoreo : public Stream {
const char* m_path;

ChoreoInputSet m_inputs;
ChoreoInputExpressionSet m_expressions;
ChoreoSensorInputSet m_sensors;
ChoreoOutputSet m_outputs;
ChoreoPreset m_preset;
ChoreoDevice m_deviceType;
ChoreoDevice m_deviceName;

char m_httpCodeStr[4];
volatile bool m_haveHttpCode;
Expand Down
2 changes: 1 addition & 1 deletion src/TembooMonitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo Arduino library
#
# Copyright 2016, Temboo Inc.
# Copyright 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 5 additions & 1 deletion src/TembooMonitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Temboo Arduino library
#
# Copyright 2016, Temboo Inc.
# Copyright 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,10 @@
#ifndef TEMBOOMESSAGING_H_
#define TEMBOOMESSAGING_H_

#ifndef TEMBOO_LIBRARY_VERSION
#define TEMBOO_LIBRARY_VERSION 2
#endif

#include <Arduino.h>
#include <Process.h>

Expand Down
51 changes: 51 additions & 0 deletions src/TembooSSL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
###############################################################################
#
# Temboo Arduino library
#
# Copyright 2017, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
#
###############################################################################
*/

#if defined (ARDUINO_AVR_YUN) || defined (ARDUINO_AVR_TRE)

#else

#include <string.h>
#include <Client.h>
#include <avr/pgmspace.h>
#include <TembooSSL.h>
#include "utility/TembooGlobal.h"
#include "utility/TembooSession.h"

TembooChoreoSSL::TembooChoreoSSL(Client& client) : TembooChoreo(client) {
m_accountName = NULL;
m_appKeyName = NULL;
m_appKeyValue = NULL;
m_path = NULL;
m_nextChar = NULL;
m_nextState = END;
}

int TembooChoreoSSL::run() {
return TembooChoreo::run(INADDR_NONE, 443, TEMBOO_CHOREO_DEFAULT_TIMEOUT_SECS);
}

int TembooChoreoSSL::run(uint16_t timeoutSecs) {
return TembooChoreo::run(INADDR_NONE, 443, timeoutSecs);
}

#endif
Loading