hirotakaster / CoAP-simple-library

Other
111 stars 48 forks source link

extend coap packet size beyond 128 #26

Closed okvittem closed 2 years ago

okvittem commented 3 years ago

Hi, Is it possible to extend the coap packet data size ? It is set too 128 in coap-simple.h : COAP_BUF_MAX_SIZE 128 This is on an Arduino MKR NB 1500 using a uBlox SARA-R410M-02B modem. On bigger packets send just returns 0 msgid. The NB-IOT MTU seem to be 1600.

okvittem commented 3 years ago

You probably wonder how my code looks like - here is the header section. The COAP_BUF_MAX_SIZE is verified 1024 by printout in the loop();

`#define COAP_BUF_MAX_SIZE 1024

define INT_REF 3.3 // internal reference volts

include

include

include "ArduinoLowPower.h"

//#include //#include

include

// time libraries //#include "RTC_SAMD21.h"

include "DateTime.h"

include "coap-simple.h"

include "arduino_secrets.h"

`

hirotakaster commented 3 years ago

@okvittem Yes, you could change CoAP packet size with "COAP_BUF_MAX_SIZE" but you would be better consider about the IP/UDP packet fragment size for too big packet size. I think COAP_BUF_MAX_SIZE = 1024 is okay if it works well on your platform.

okvittem commented 3 years ago

Defining COAP_BUF_MAX_SIZE in my program does not work. So it is probably not used when Arduino IDE is compiling coap-simple.cpp. I have changed it in coap-simple.h to make it be 1024,

lonerzzz commented 2 years ago

It would be good to include the size limit on the main page. It would be even better to allow the size to be set in a constructor as an option.

hirotakaster commented 2 years ago

Hi guys, okay, I will add MAX_PACKET_SIZE option to constructor. default value is 128, and it will be could change.

lonerzzz commented 2 years ago

If you are going to add the buffer size option, I would also suggest that the buffer used in the loop not be allocated on each method call, but rather be allocated by the constructor.

hirotakaster commented 2 years ago

now I update library. thank you guys.

lonerzzz commented 2 years ago

Thank you for the quick changes! I look forward to putting them to use.