Closed gkapellmann closed 3 years ago
Hi, I made this with a simple test Console App where I put all the required calls and noted the response afterwards. You can surely do everything required with COAPnet.
You basically need to follow this instructions: https://github.com/home-assistant/core/issues/10252
Instead of using the coap-client application you can send the same requests with COAPnet.
Best regards Christian
OK, so can you help me understand this, its literally this command the one I am having trouble to interpret:
coap-client -m post -u "Client_identity" -k "SECURITY_CODE" -e '{"9090":"IDENTITY"}' "coaps://IP_ADDRESS:5684/15011/9063"
It clearly is a POST type, but I am assuming this has to happen before this:
var connectOptions = new CoapClientConnectOptionsBuilder() .WithHost(address) .WithPort(5684) .WithDtlsTransportLayer(o => o.WithPreSharedKey(myID, secretKey)) .Build(); await coapClient.ConnectAsync(connectOptions, CancellationToken.None);
so my problem here is how to put in the POST the address and the "Client_identity", I am clearly miss understanding something, so my POST command so far is like this:
var request = new CoapRequestBuilder() .WithMethod(CoapRequestMethod.Post) .WithPath("15011/9063") .WithQuery(GatewayCode) .WithPayload("{\"9090\":\"" + Identity + "\"}") .Build(); var response = await theClient.RequestAsync(request, CancellationToken.None).ConfigureAwait(false);
What am I missing?
Thank you in advance!
Hello @chkr1011 , I was wondering if you could give me some guidance here, I am still stuck with it.
Your code looks fine to me. I also used it to communicate with TRADFRI devices. My code is here: https://github.com/chkr1011/CoAPnet/blob/34339382f94008482b0fd5de3c1c1453744c3fa3/Source/CoAP.TestClient/Program.cs#L59
Right! I was locating the Query in the wrong place.
Thank you for your help!
Following this note: "Please note that the identity and key must be generated first using the security token on the back of the device."
Doing so with a python lib is easy, but is there a way to do this with CoAPnet?
If so, could you point me in the right direction to do so?
Thank you!