Im trying to get Temboo to work with a different wifi module. Im using a Roving Networks RVN-171 module on an arduino shield.
I've modified the original Temboo produced code to this:
#include <SPI.h>
//ADDED START
//#include <WiFi.h>
#include <WiFiClient.h>
//--------------
#include <WiFlyHQ.h>
#include <SoftwareSerial.h>
//ADDED END
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information
//ADDED START
SoftwareSerial wifiSerial(2,3); //WIFI SHIELD CLIENT
WiFly wifly; //WIFI
//--------------
WiFiClient client;
// ADDED END
int numRuns = 1; // Execution count, so this doesn't run forever
int maxRuns = 10; // Maximum number of times the Choreo should be executed
void setup() {
Serial.begin(9600);
// For debugging, wait until the serial console is connected
delay(4000);
//while(!Serial);
//ADDED BY ME
// int wifiStatus = WL_IDLE_STATUS;
//
// // Determine if the WiFi Shield is present
// Serial.print("\n\nShield:");
// if (WiFi.status() == WL_NO_SHIELD) {
// Serial.println("FAIL");
//
// // If there's no WiFi shield, stop here
// while(true);
// }
//
// Serial.println("OK");
//
// // Try to connect to the local WiFi network
// while(wifiStatus != WL_CONNECTED) {
// Serial.print("WiFi:");
// wifiStatus = WiFi.begin(WIFI_SSID, WEP_KEY_INDEX, WEP_KEY);
// if (wifiStatus == WL_CONNECTED) {
// Serial.println("OK");
// } else {
// Serial.println("FAIL");
// }
// delay(5000);
// }
//--------
wiFlyHQConnect();
//ADDED END
Serial.println("Connection to wifi complete.\n");
}
void loop() {
if (numRuns <= maxRuns) {
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++));
//delay(3000);
TembooChoreo GetWeatherByAddressChoreo(client);
Serial.println("GetWeatherByAddressChoreo(client) called...\n");
//delay(3000);
// Invoke the Temboo client
GetWeatherByAddressChoreo.begin();
Serial.println("GetWeatherByAddressChoreo.begin()...\n");
//delay(3000);
// Set Temboo account credentials
GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);
Serial.println("setters called...\n");
//delay(3000);
// Set profile to use for execution
GetWeatherByAddressChoreo.setProfile("CurrentSAPWeather");
Serial.println("profile set...\n");
//delay(3000);
// Identify the Choreo to run
GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");
Serial.println("choreo set...\n");
//delay(3000);
// Run the Choreo; when results are available, print them to serial
GetWeatherByAddressChoreo.run();
Serial.println("choreo run...\n");
//delay(3000);
while(GetWeatherByAddressChoreo.available()) {
char c = GetWeatherByAddressChoreo.read();
Serial.print(c);
}
Serial.println("data printed...\n");
//delay(3000);
GetWeatherByAddressChoreo.close();
}
Serial.println("\nWaiting...\n");
delay(30000); // wait 30 seconds between GetWeatherByAddress calls
}
void wiFlyHQConnect(){
///////////////////WiFi CLIENT SETUP////////////////////////////////////////////
char buf[32];
//data = "";
Serial.print("Free memory: ");
Serial.println(wifly.getFreeMemory(),DEC);
wifiSerial.begin(9600);
if (!wifly.begin(&wifiSerial, &Serial)) {
Serial.println("Failed to start wifly");
terminal();
}
/* Join wifi network if not already associated */
if (!wifly.isAssociated()) {
/* Setup the WiFly to connect to a wifi network */
Serial.println("Joining network");
wifly.setSSID(WIFI_SSID);
wifly.setPassphrase(WEP_KEY);
wifly.enableDHCP();
if (wifly.join()) {
Serial.println("Joined wifi network");
} else {
Serial.println("Failed to join wifi network");
terminal();
}
} else {
Serial.println("Already joined network");
}
wifly.setDeviceID("Wifly-WebClient2");
Serial.print("DeviceID: ");
Serial.println(wifly.getDeviceID(buf, sizeof(buf)));
if (wifly.isConnected()) {
Serial.println("Old connection active. Closing");
wifly.close();
}
}
void terminal(){
while (1) {
if (wifly.available() > 0) {
Serial.write(wifly.read());
}
if (Serial.available() > 0) {
wifly.write(Serial.read());
}
}
}
and I get these warnings:
Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/WiFi/src/utility/wifi_drv.cpp: In static member function 'static uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t)':
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/WiFi/src/utility/wifi_drv.cpp:451:10: warning: converting to non-pointer type 'uint8_t {aka unsigned char}' from NULL [-Wconversion-null]
return NULL;
^
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/WiFi/src/utility/wifi_drv.cpp: In static member function 'static int32_t WiFiDrv::getRSSINetoworks(uint8_t)':
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/WiFi/src/utility/wifi_drv.cpp:476:10: warning: converting to non-pointer type 'int32_t {aka long int}' from NULL [-Wconversion-null]
return NULL;
^
/Users/quique123/Documents/Arduino/libraries/WiFlyHQ/WiFlyHQ.cpp: In member function 'boolean WiFly::sleep(uint16_t)':
/Users/quique123/Documents/Arduino/libraries/WiFlyHQ/WiFlyHQ.cpp:1458:20: warning: NULL used in arithmetic [-Wpointer-arith]
if (seconds != NULL) {
^
/Users/quique123/Desktop/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp:375:6: warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::setRxIntMsk(bool enable)^
/Users/quique123/Desktop/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp:121:6: warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::recv()^
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/Temboo/src/Temboo.cpp: In member function 'int TembooChoreo::run(IPAddress, uint16_t, uint16_t)':
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/Temboo/src/Temboo.cpp:239:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
if (!m_client.findUntil("HTTP/1.", HTTP_EOL)) {
^
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/Temboo/src/Temboo.cpp:259:62: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
if (m_client.findUntil("x-temboo-time:", HTTP_EOH)) {
^
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/Temboo/src/TembooCoAPEdgeDevice.cpp: In member function 'int TembooCoAPChoreo::run(uint16_t)':
/Users/quique123/Desktop/Arduino.app/Contents/Java/libraries/Temboo/src/TembooCoAPEdgeDevice.cpp:831:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
find("x-temboo-time:");
^
Multiple libraries were found for "SPI.h"
Used: /Users/quique123/Documents/Arduino/libraries/SPI
Not used: /Users/quique123/Desktop/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI