I'm a bit of a beginner in C# but what I'm coding a CoAP client that will test the throughput and response time of several CoAP servers at once. FYI the application is implemented as a command line program. The library I'm using is CoAP.NET.
Everything went just fine until I wanted to change the default block size from 512 bytes to something less like 32 bytes.
This is where my understanding of C# fails me, the settings are located in the interface ICoapConfig and the class CoapConfig. These settings just magically loads at some point.
I have tried to do this:
CoapConfig conf = new CoapConfig();
conf.DefaultBlockSize = 32;
CoapClient client = new CoapClient(conf);
...
Request req = new Request(Method.PUT);
req.SetPayload(payload, MediaType.TextPlain);
client.Send(req);
However the blocksize is still 512 as messages only get transferred blockwise when over 512b.
DEBUG - BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize:512
This is the first line of output I get when running the program.
Happy for any help :)
SOLUTION:
CoapConfig conf = new CoapConfig();
conf.DefaultBlockSize = 32;
...
Request req = new Request(Method.PUT);
req.SetPayload(payload, MediaType.TextPlain);
req.URI = client.Uri;
IEndPoint _clientEndpoint;
_clientEndpoint = new CoAPEndPoint(conf);
_clientEndpoint.Start();
req.Send(_clientEndpoint);
...
I don't really know what this EndPoint thing might be but this lets you use a desired configuration when sending. FYI: I tried to set the config for the server to but with no success.