diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 7101488..fcd71f9 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -15,13 +15,13 @@ jobs: "arduino:samd:mkrwifi1010", "arduino:samd:nano_33_iot", "arduino:samd:mkrvidor4000", - '"esp8266:esp8266:huzzah" "http://arduino.esp8266.com/stable/package_esp8266com_index.json"' + '"esp8266:esp8266:huzzah" "http://arduino.esp8266.com/stable/package_esp8266com_index.json"', + '"adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off" "https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"' + #'"adafruit:avr:feather32u4" "https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" ', #'"esp32:esp32:esp32doit-devkit-v1:FlashFreq=80,UploadSpeed=921600,DebugLevel=none" "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"' ] steps: - #- run: pip install pyserial - #- run: pip3 install pyserial - uses: actions/checkout@v1 with: fetch-depth: 1 diff --git a/THIRD_PARTY.txt b/THIRD_PARTY.txt new file mode 100644 index 0000000..5ed15ef --- /dev/null +++ b/THIRD_PARTY.txt @@ -0,0 +1,13 @@ +COMPONENT | VERSION | LICENCE | URL +------------------------------------------------------------------------------------------------------------------------------------------------- +MKRNB | Latest | GNU LGPL 2.1 | https://github.com/arduino-libraries/MKRNB +MKRGSM | Latest | GNU LGPL 2.1 | https://github.com/arduino-libraries/MKRGSM +WiFiNINA | Latest | GNU LGPL 2.1 | https://github.com/arduino-libraries/WiFiNINA +WiFi101 | Latest | GNU LGPL 2.1 | https://github.com/arduino-libraries/WiFi101 +ArduinoMQTTClient | 0.1.5 moddified | GNU LGPL 2.1 | https://github.com/arduino-libraries/ArduinoMqttClient +PubSubClient | Latest | MIT License | https://github.com/knolleary/pubsubclient/blob/master/LICENSE.txt +ArduinoJSON | Latest | MIT License | https://github.com/bblanchon/ArduinoJson/blob/6.x/LICENSE.md +Adafruit FONA | Latest | BSD License | https://github.com/adafruit/Adafruit_FONA +Adafruit MQTT | 2.0.0 modiffied | MIT License | https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/LICENSE +ESP8266 boards components | Latest | GNU LGPL 2.1 | https://github.com/esp8266/Arduino/blob/master/LICENSE +ESP32 boards components | Latest | GNU LGPL 2.1 | https://github.com/espressif/arduino-esp32/blob/master/LICENSE.md diff --git a/library.properties b/library.properties index d484e8b..b198066 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiveObjectsSDK -version=1.0.0 +version=2.0.0 author=Orange maintainer=Marc Delain , Krzysztof Krzeslak sentence=A library that makes connection with Orange LiveObjects platform a breeze. diff --git a/src/Adafruit_MQTT.cpp b/src/Adafruit_MQTT.cpp index d823fce..6862a54 100644 --- a/src/Adafruit_MQTT.cpp +++ b/src/Adafruit_MQTT.cpp @@ -19,6 +19,10 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +// +// Modiffications: +// setClientID() +// #include "Adafruit_MQTT.h" #if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || \ diff --git a/src/Adafruit_MQTT_Client.cpp b/src/Adafruit_MQTT_Client.cpp deleted file mode 100644 index 3886761..0000000 --- a/src/Adafruit_MQTT_Client.cpp +++ /dev/null @@ -1,109 +0,0 @@ - -// The MIT License (MIT) -// -// Copyright (c) 2015 Adafruit Industries -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -#include "Adafruit_MQTT_Client.h" - -bool Adafruit_MQTT_Client::connectServer() { - // Grab server name from flash and copy to buffer for name resolution. - memset(buffer, 0, sizeof(buffer)); - strcpy((char *)buffer, servername); - DEBUG_PRINT(F("Connecting to: ")); - DEBUG_PRINTLN((char *)buffer); - // Connect and check for success (0 result). - int r = client->connect((char *)buffer, portnum); - DEBUG_PRINT(F("Connect result: ")); - DEBUG_PRINTLN(r); - return r != 0; -} - -bool Adafruit_MQTT_Client::disconnectServer() { - // Stop connection if connected and return success (stop has no indication of - // failure). - if (client->connected()) { - client->stop(); - } - return true; -} - -bool Adafruit_MQTT_Client::connected() { - // Return true if connected, false if not connected. - return client->connected(); -} - -uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen, - int16_t timeout) { - /* Read data until either the connection is closed, or the idle timeout is - * reached. */ - uint16_t len = 0; - int16_t t = timeout; - - while (client->connected() && (timeout >= 0)) { - // DEBUG_PRINT('.'); - while (client->available()) { - // DEBUG_PRINT('!'); - char c = client->read(); - timeout = t; // reset the timeout - buffer[len] = c; - // DEBUG_PRINTLN((uint8_t)c, HEX); - len++; - - if (maxlen == 0) { // handle zero-length packets - return 0; - } - - if (len == maxlen) { // we read all we want, bail - DEBUG_PRINT(F("Read data:\t")); - DEBUG_PRINTBUFFER(buffer, len); - return len; - } - } - timeout -= MQTT_CLIENT_READINTERVAL_MS; - delay(MQTT_CLIENT_READINTERVAL_MS); - } - return len; -} - -bool Adafruit_MQTT_Client::sendPacket(uint8_t *buffer, uint16_t len) { - uint16_t ret = 0; - - while (len > 0) { - if (client->connected()) { - // send 250 bytes at most at a time, can adjust this later based on Client - - uint16_t sendlen = len > 250 ? 250 : len; - // Serial.print("Sending: "); Serial.println(sendlen); - ret = client->write(buffer, sendlen); - DEBUG_PRINT(F("Client sendPacket returned: ")); - DEBUG_PRINTLN(ret); - len -= ret; - - if (ret != sendlen) { - DEBUG_PRINTLN("Failed to send packet."); - return false; - } - } else { - DEBUG_PRINTLN(F("Connection failed!")); - return false; - } - } - return true; -} diff --git a/src/Adafruit_MQTT_Client.h b/src/Adafruit_MQTT_Client.h deleted file mode 100644 index 5cfbb41..0000000 --- a/src/Adafruit_MQTT_Client.h +++ /dev/null @@ -1,57 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2015 Adafruit Industries -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -#ifndef _ADAFRUIT_MQTT_CLIENT_H_ -#define _ADAFRUIT_MQTT_CLIENT_H_ - -#include "Adafruit_MQTT.h" -#include "Client.h" - -// How long to delay waiting for new data to be available in readPacket. -#define MQTT_CLIENT_READINTERVAL_MS 10 - -// MQTT client implementation for a generic Arduino Client interface. Can work -// with almost all Arduino network hardware like ethernet shield, wifi shield, -// and even other platforms like ESP8266. -class Adafruit_MQTT_Client : public Adafruit_MQTT { -public: - Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port, - char *cid, const char *user, const char *pass) - : Adafruit_MQTT(server, port, cid, user, pass), client(client) {} - - Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port, - const char *user = "", const char *pass = "") - : Adafruit_MQTT(server, port, user, pass), client(client) {} - - bool connected() override; - -protected: - bool connectServer() override; - bool disconnectServer() override; - uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, - int16_t timeout) override; - bool sendPacket(uint8_t *buffer, uint16_t len) override; - -private: - Client *client; -}; - -#endif diff --git a/src/LiveObjects.cpp b/src/LiveObjects.cpp index fa03d3b..4dc5446 100644 --- a/src/LiveObjects.cpp +++ b/src/LiveObjects.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjects.h" LiveObjects& lo = LiveObjects::get(); diff --git a/src/LiveObjects.h b/src/LiveObjects.h index 57b2b5d..187ee25 100644 --- a/src/LiveObjects.h +++ b/src/LiveObjects.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once /****************************************************************************** diff --git a/src/LiveObjectsBase.cpp b/src/LiveObjectsBase.cpp index e8ce6fc..ff00fca 100644 --- a/src/LiveObjectsBase.cpp +++ b/src/LiveObjectsBase.cpp @@ -1,4 +1,10 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsBase.h" LiveObjectsBase::LiveObjectsBase() : @@ -341,6 +347,11 @@ void LiveObjectsBase::publishMessage(const String& topic, String& payload) { ******************************************************************************/ void LiveObjectsBase::begin(Protocol p, Encoding e, bool d) { + if(e != TEXT && e != BINARY) + { + outputDebug(ERR,"Wrong encoding type! Check your code. begin(MQTT/SMS , TEXT/BINARY, false/true)"); + while(true); + } m_Protocol = p; m_Encoding = e; m_bDebug = d; diff --git a/src/LiveObjectsBase.h b/src/LiveObjectsBase.h index 9a3bdbb..cb7d165 100644 --- a/src/LiveObjectsBase.h +++ b/src/LiveObjectsBase.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once diff --git a/src/LiveObjectsCellular.cpp b/src/LiveObjectsCellular.cpp index 6729cc0..0215964 100644 --- a/src/LiveObjectsCellular.cpp +++ b/src/LiveObjectsCellular.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsCellular.h" #if defined NBD || defined GSMD diff --git a/src/LiveObjectsCellular.h b/src/LiveObjectsCellular.h index eb5ae00..9f00f02 100644 --- a/src/LiveObjectsCellular.h +++ b/src/LiveObjectsCellular.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsMKR.h" #if defined ARDUINO_SAMD_MKRNB1500 #define NBD diff --git a/src/LiveObjectsCert.h b/src/LiveObjectsCert.h index 3882f7a..0528fa8 100644 --- a/src/LiveObjectsCert.h +++ b/src/LiveObjectsCert.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #ifndef _LIVEOBJECTS_CERT_H_INCLUDED #define _LIVEOBJECTS_CERT_H_INCLUDED diff --git a/src/LiveObjectsESP.cpp b/src/LiveObjectsESP.cpp index bf8afb1..a0ed539 100644 --- a/src/LiveObjectsESP.cpp +++ b/src/LiveObjectsESP.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsESP.h" #if defined ESP8266D || defined ESP32D diff --git a/src/LiveObjectsESP.h b/src/LiveObjectsESP.h index 33add29..71bce97 100644 --- a/src/LiveObjectsESP.h +++ b/src/LiveObjectsESP.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once #if defined ESP8266 || defined ESP32 #include "LiveObjectsBase.h" diff --git a/src/LiveObjectsFona.cpp b/src/LiveObjectsFona.cpp index e21bac1..8540b8b 100644 --- a/src/LiveObjectsFona.cpp +++ b/src/LiveObjectsFona.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsFona.h" #ifdef FONAD LiveObjectsFona::LiveObjectsFona() @@ -6,6 +12,7 @@ LiveObjectsFona::LiveObjectsFona() ,m_FonaSerial(FONA_TX,FONA_RX) ,m_FonaMQTT(&m_Fona,MQTT_BROKER, 1883,"Fona", MQTT_USER, SECRET_LIVEOBJECTS_API_KEY) ,m_sClientID() + ,m_sModel("Orange") ,m_nPort(1883) ,m_Security(NONE) { @@ -14,9 +21,10 @@ LiveObjectsFona::LiveObjectsFona() void LiveObjectsFona::begin(Protocol p, Encoding e, bool d) { - if(m_Encoding == BINARY) + if(m_Encoding != TEXT) { - //Serial.println("[ERROR] This board support only Text mode"); + Serial.println("[ERROR] This board support only Text mode"); + while(true); } m_Protocol=p; m_Encoding=e; diff --git a/src/LiveObjectsFona.h b/src/LiveObjectsFona.h index be94970..e0a713a 100644 --- a/src/LiveObjectsFona.h +++ b/src/LiveObjectsFona.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once #ifdef ARDUINO_ARCH_AVR diff --git a/src/LiveObjectsMKR.cpp b/src/LiveObjectsMKR.cpp index 84c3552..c19b6a8 100644 --- a/src/LiveObjectsMKR.cpp +++ b/src/LiveObjectsMKR.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsMKR.h" LiveObjectsMKR::LiveObjectsMKR() : diff --git a/src/LiveObjectsMKR.h b/src/LiveObjectsMKR.h index 911b4c5..a36637e 100644 --- a/src/LiveObjectsMKR.h +++ b/src/LiveObjectsMKR.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once /****************************************************************************** MKR BOARDS BASE CLASS diff --git a/src/LiveObjectsWiFi.cpp b/src/LiveObjectsWiFi.cpp index 828439a..3641037 100644 --- a/src/LiveObjectsWiFi.cpp +++ b/src/LiveObjectsWiFi.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "LiveObjectsWiFi.h" #ifdef WIFID LiveObjectsWiFi::LiveObjectsWiFi() diff --git a/src/LiveObjectsWiFi.h b/src/LiveObjectsWiFi.h index d7994f4..24239c3 100644 --- a/src/LiveObjectsWiFi.h +++ b/src/LiveObjectsWiFi.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #if defined ARDUINO_SAMD_MKRWIFI1010 || defined ARDUINO_SAMD_NANO_33_IOT || defined ARDUINO_SAMD_MKRVIDOR4000 #ifdef ARDUINO_SAMD_MKRVIDOR4000 #include diff --git a/src/MqttClient.h b/src/MqttClient.h index 47365cb..0e799da 100644 --- a/src/MqttClient.h +++ b/src/MqttClient.h @@ -15,6 +15,10 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Modiffications: + setTxPatyloadSize() + unsigned short _tx_payload_buffer_size; */ #ifndef _MQTT_CLIENT_H_ diff --git a/src/Utils.cpp b/src/Utils.cpp index e7a2435..e0b77a4 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #include "Utils.h" #include //#if not defined ESP8266 && not defined ESP32 diff --git a/src/Utils.h b/src/Utils.h index b604f74..4aa6c10 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) Orange + * + * This software is distributed under the terms and conditions of the 'MIT' + * license which can be found in the file 'LICENSE.md' in this package distribution + */ #pragma once #include