commit 573b67a58ce397cb0951db61b4927e00b9bb0813 Author: Danyi Dávid Date: Tue Oct 17 21:41:58 2017 +0200 * initial commit diff --git a/examples/nbIOT_test/nbIOT_test.ino b/examples/nbIOT_test/nbIOT_test.ino new file mode 100644 index 0000000..65a9309 --- /dev/null +++ b/examples/nbIOT_test/nbIOT_test.ino @@ -0,0 +1,94 @@ +/* + Copyright (c) 2015-2016 Sodaq. All rights reserved. + + This file is part of Sodaq_nbIOT. + + Sodaq_nbIOT is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of + the License, or(at your option) any later version. + + Sodaq_nbIOT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with Sodaq_nbIOT. If not, see + . +*/ + +#include "Sodaq_nbIOT.h" +#include + +#ifdef ARDUINO_SODAQ_EXPLORER +#define MODEM_ON_OFF_PIN 7 +#define MODEM_STREAM Serial +#else +#error "You need to declare the modem on/off pin and stream for your particular board!" +#endif + +#define DEBUG_STREAM SerialUSB +#define DEBUG_STREAM_BAUD 115200 + +#define STARTUP_DELAY 5000 + +const char* apn = "oceanconnect.t-mobile.nl"; +const char* cdp = "172.16.14.22"; +const char* forceOperator = "20416"; // optional - depends on SIM / network + +Sodaq_nbIOT nbiot; + +void showMessageCountFromModem(); + +void setup() +{ + sodaq_wdt_safe_delay(STARTUP_DELAY); + + DEBUG_STREAM.begin(DEBUG_STREAM_BAUD); + MODEM_STREAM.begin(nbiot.getDefaultBaudrate()); + + DEBUG_STREAM.print("Initializing and connecting... "); + + nbiot.init(MODEM_STREAM, MODEM_ON_OFF_PIN); + nbiot.setDiag(DEBUG_STREAM); + + if (nbiot.connect(apn, cdp, forceOperator)) { + DEBUG_STREAM.println("Connected succesfully!"); + } + else { + DEBUG_STREAM.println("Failed to connect!"); + return; + } + + showMessageCountFromModem(); + + const char* message = "Hello World!"; + DEBUG_STREAM.print("Sending message: \""); + DEBUG_STREAM.print(message); + DEBUG_STREAM.print("\"... "); + + if (!nbiot.sendMessage(message)) { + DEBUG_STREAM.println("Could not queue message!"); + } + else { + DEBUG_STREAM.println("Message queued for transmission!"); + } +} + +void loop() +{ + if (nbiot.isConnected()) { + showMessageCountFromModem(); + } + + sodaq_wdt_safe_delay(5000); +} + +void showMessageCountFromModem() +{ + DEBUG_STREAM.print("Pending Messages: "); + DEBUG_STREAM.print(nbiot.getSentMessagesCount(Sodaq_nbIOT::Pending)); + DEBUG_STREAM.print(" | Failed Messages: "); + DEBUG_STREAM.println(nbiot.getSentMessagesCount(Sodaq_nbIOT::Error)); +} diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..4bca86e --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=Sodaq_nbIOT_SOCK +version=1.0.1 +author=ETH +maintainer= +sentence= +paragraph= +category=Device Control +url= +architectures=avr,samd diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/src/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml new file mode 100644 index 0000000..f669a0e --- /dev/null +++ b/src/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/.idea/src.iml b/src/.idea/src.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/src/.idea/src.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/.idea/workspace.xml b/src/.idea/workspace.xml new file mode 100644 index 0000000..5acf9fc --- /dev/null +++ b/src/.idea/workspace.xml @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + readResponse + ::readResponse + wdt + println + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + +