Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anoochit
Created February 18, 2018 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoochit/1d6acc4294b7a0fc3a4babd869f8a5e7 to your computer and use it in GitHub Desktop.
Save anoochit/1d6acc4294b7a0fc3a4babd869f8a5e7 to your computer and use it in GitHub Desktop.
AIS NB-IoT example code
#include "AIS_NB_BC95.h"
String apnName = "devkit.nb";
String serverIP = ""; // Your Server IP
String serverPort = ""; // Your Server Port
String udpData = "HelloWorld";
AIS_NB_BC95 AISnb;
const long interval = 20000; //millisecond
unsigned long previousMillis = 0;
long cnt = 0;
void setup()
{
AISnb.debug = true;
Serial.begin(9600);
AISnb.setupDevice(serverPort);
String ip1 = AISnb.getDeviceIP();
delay(1000);
pingRESP pingR = AISnb.pingIP(serverIP);
previousMillis = millis();
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
cnt++;
// Send data in String
UDPSend udp = AISnb.sendUDPmsgStr(serverIP, serverPort, udpData+String(cnt));
//Send data in HexString
//udpDataHEX = AISnb.str2HexStr(udpData);
//UDPSend udp = AISnb.sendUDPmsg(serverIP, serverPort, udpDataHEX);
previousMillis = currentMillis;
}
UDPReceive resp = AISnb.waitResponse();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment