hirotakaster / CoAP-simple-library

Other
111 stars 48 forks source link

CoAP::start() call causing program to hang on Arduino MKR NB 1500 #39

Closed GanniMT closed 1 year ago

GanniMT commented 1 year ago

Description: After calling CoAP::start() on my Arduino MKR NB 1500 board, the program hangs and does not continue executing. I'm really not sure what is happening.

I have included the relevant code snippet below:

#include <MKRNB.h>
#include <coap-simple.h>

NBClient nbClient;
NBUDP udp;
GPRS gprsAccess;
NB nbAccess;
Coap coap(udp);

void setup()
{
  // 9600 Baudrate
  Serial.begin(9600);

  // Waiting for Serial port to Connect
  while (!Serial)
    ;

  Serial.println("Hello from setup!");
  coap.start(); // Program hangs here
  Serial.println("Coap Has Started");
}

void loop()
{
  // Code for taking sensor readings and sending data
}
hirotakaster commented 1 year ago

Hi @GanniMT

coap.start() can't work until after get an IP address(network connection), because of coap can't bind IP/port. You might want to check your Arduino getting an IP address or not.