Problem to send data to UDP/COAP server

Hi,
I am testing NBIOT network in Denmark and trying to send data packets (like signal strength) to server every time interval. Do you have any such examples where I can take reference?

Meanwhile I tried to send UDP packet trough sketch whrere it send UDP packet on every 10 SEC.

I made some changes on Sodaq_nbIOT.cpp library where I added connectSocket() method which calls AT+NSOST command to send data to UDP server. With this steps we are getting timeed out response.
But same steps with normal AT commands I can send UDP packet to server.

NB- Here in Denmark there is no any network provider who supports CDP so trying to connect to server with UDP .

Please help me to send my packet to server :slight_smile:

Logs while sending UDP through AT commands-

Send to COM24: “AT+NSOCR=“DGRAM”,17,14000”<<
0
OK

Send to COM24: "AT+NSOST=0,“37.139.21.140”,8989,17,“73616d706c65446174613a3131312e3030"”<<
0,17
OK
+NSONMI: 0,17

Send to COM24: “AT+NSOST=0,“37.139.21.140”,8989,9,“2B4E434F4E4649473F””<<
0,9
OK

Logs while sending from sketch

rdResp: timed out

AT+CGDCONT=1,“IP”,“company.iot.dk1.tdc”
rdResp: OK

AT+NCDP=“8.8.8.8”
rdResp: OK

AT+NSMI=0
rdResp: OK

AT+NNMI=0
rdResp: OK

AT+CFUN=1
rdResp: OK

AT+COPS=1,2,“23810”
rdResp: OK

AT+CSQ
rdResp: +CSQ: 99,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 99,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 30,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 29,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 28,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK

AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK
Failed to connect!
Start new message…>> AT+CGATT?
rdResp: +CGATT: 1
rdResp: OK
NBIOT is connected…>> AT+CSQ
rdResp: +CSQ: 27,99
rdResp: OK
Signal Message-AT+NCONFIG?
>> AT+NSOST=0,“37.139.21.140”,8989,11,"41542B4E434F4E4649473F"rdResp: timed out
Message sent failed…


Method to send UDP packet (Sorry, I am java programmer not good at c++ ;))

bool Sodaq_nbIOT::connectSocket(uint8_t socket, const char* host,
uint16_t port) {
int8_t rssi;
uint8_t ber;
if (getRSSIAndBER(&rssi, &ber)) {
String message1 = “SignalStrength:” + rssi;
DEBUG_STREAM.println(“Signal Message-” + message1);
const char* charArr = message1.c_str();
size_t size = strlen(charArr);
print(“AT+NSOST=”);
print(socket);
print(","");
print(host);
print(""");
print("," );
print(port);
print("," );
print (size);
print(","");
for (uint16_t i = 0; i < size; ++i) {
print(static_cast(NIBBLE_TO_HEX_CHAR(HIGH_NIBBLE(charArr[i]))));
print(static_cast(NIBBLE_TO_HEX_CHAR(LOW_NIBBLE(charArr[i]))));
}
print(""");
return (readResponse() == ResponseOK);
}
return false;
}

Sketch is like this

void setup() {
sodaq_wdt_safe_delay(STARTUP_DELAY);

DEBUG_STREAM.begin(DEBUG_STREAM_BAUD);
MODEM_STREAM.begin(nbiot.getDefaultBaudrate());
while ((!DEBUG_STREAM) && (millis() < 10000)) {
	// Wait for serial monitor for 10 seconds
}
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!");
	DEBUG_STREAM.println("Creating socket...!");
	socketResponsePort = nbiot.createSocket(14000);
	DEBUG_STREAM.println("Creating socket sucessfully...!");
} else {
	DEBUG_STREAM.println("Failed to connect!");
	return;
}

}

void loop() {
DEBUG_STREAM.print(“Start new message…”);
if (nbiot.isConnected() && socketResponsePort >= 0) {
DEBUG_STREAM.print(“NBIOT is connected…”);
if (nbiot.connectSocket(socketResponsePort, udpServer, udpServerPort)) {
DEBUG_STREAM.println(“Message sent successfully…”);
} else {
DEBUG_STREAM.println(“Message sent failed…”);
}
}
DEBUG_STREAM.println("---------------------------------");
sodaq_wdt_safe_delay(10000);
}

Anyone please please help if you have sample program that send udp packet to server.
I am totally blocked with my NBIOT testing, PLEASE HELP !!!

Hey @Gaurav_Kumar,

We are working on UDP support for our open source library. In the mean time, you can try in here it seems that some people already have something. We will update soon.

@ItayDagan Thanks a lot for your reply, eagerly waiting for UDP support.

Looking forward !!!

BR
Gaurav

maybe the “CR” is missing at the very last “print(”"");" code, try “println” instead

Hi

Did you solve the problem?

I cant get the AT+COPS=1,2,“23810” to work, and I can’t get the board to register to the AT+CGDCONT=1,“IP”,“company.iot.dk1.tdc”… I Got a simcard form TDC long time ago… Maybe i missing somthing…

Kind Rgds
Tom

Hi,

After sending the command AT+COPS wait till you get a reply from the modem.
It can take a while before your modem is connected. Either you get ok or an error message.

Best regards,
Jan

Hi
any good news regarding the UDP support ?

@ItayDagan

any good news regarding the UDP support ?

Hi @Islam_essam,

UDP is stable.
Please update the module and update the libraries and try again (support.sodaq.com)