I noticed that there are new libraries available version 2.0.2 so I’m looking how to use these with my R412M AFF board (I was using 1.x before).
What I noticed is that some examples (nbIOT_test_udp) use:
I tried them both and the one with R4X is working and the other one is not working.
Sending UDP packages from my device is no problem, but I’m confused how to properly receive UDP packages. This is part of my code:
void loop() {
if (MODEM_STREAM.available()) {
if (socketID != -1) {
while (r4x.socketHasPendingBytes(socketID)) {
DEBUG_STREAM.println(“I have pending bytes”);
char data[200];
while (r4x.socketReceive(socketID,(uint8_t*)data,200)) {
DEBUG_STREAM.println(“I’m reading bytes”);
DEBUG_STREAM.println(data);
}
}
}
If I send data to my device, MODEM_STREAM.available becomes true. But the r4x.socketHasPendingBytes does not detect it and remains false.
I could manually perform a MODEM_STREAM.read, but I thought it’s better to use the functions from the library?
The socketID is 0, and when I print the MODEM_STREAM I do get the USORF 0,4. Maybe a bug in the library?
The v2.0.2 of the R4X library only works with the latest version of the ublox firmware.
Do you have the latest firmware on both boards? https://support.sodaq.com/Boards/Sara_AFF/#r4
I solved the modem problem by loading my personal sketch (which sets additional modem settings).
The modem connects fine.
After that I reuploaded the r4x example.
The modem now connects fine, but still r4x.socketHasPendingBytes remains false and MODEM_STREAM.available() is true. So problem is still not solved.