Skip to content

Commit

Permalink
Add utility function 'get UDP IP/port'
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaranu committed May 21, 2019
1 parent 09dbe14 commit c3db861
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions src/IoTtweetNBIoT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* IoTtweet configuration parameter */
#define IoTtweetNBIoT_HOST "35.185.177.33" // - New Cloud IoTtweet server
#define IoTtweetNBIoT_PORT "5683" // - Default udp port
#define IoTtweetNBIoT_libVersion "v1.7"
#define IoTtweetNBIoT_libVersion "v2.1"

/* AIS_NB_BC95 library parameter */
String apnName = "devkit.nb";
Expand Down Expand Up @@ -116,6 +116,36 @@ String IoTtweetNBIoT::getNetworkTime(){
return _ntp;
}

String IoTtweetNBIoT::getControlbySwitch(String userid, String key, int swnum){

_userid = userid;
_key = key;
_swnum = String(swnum);

String _getswctl = "SWC";
_getswctl += ":";
_getswctl += _userid;
_getswctl += ":";
_getswctl += _key;
_getswctl += ":";
_getswctl += _swnum;

UDPSend udpGetcontrol = AISnb.sendUDPmsgStr(serverIP, serverPort, _getswctl);
String _ctlstatus = getRespFromServer();
return _ctlstatus;
}

String IoTtweetNBIoT::getUDPip(){

String _udpipPacket = "IP";
Serial.println("Request UDP IP address");

UDPSend udpIP = AISnb.sendUDPmsgStr(serverIP, serverPort, _udpipPacket);
_udpip = getRespFromServer();

return _udpip;
}

String IoTtweetNBIoT::getRespFromServer(){

String respStr = "";
Expand All @@ -140,25 +170,6 @@ String IoTtweetNBIoT::getRespFromServer(){

}

String IoTtweetNBIoT::getControlbySwitch(String userid, String key, int swnum){

_userid = userid;
_key = key;
_swnum = String(swnum);

String _getswctl = "SWC";
_getswctl += ":";
_getswctl += _userid;
_getswctl += ":";
_getswctl += _key;
_getswctl += ":";
_getswctl += _swnum;

UDPSend udpGetcontrol = AISnb.sendUDPmsgStr(serverIP, serverPort, _getswctl);
String _ctlstatus = getRespFromServer();
return _ctlstatus;
}

/*
String IoTtweetNBIoT::receiveResponse(){
Expand Down

0 comments on commit c3db861

Please sign in to comment.