chkr1011 / coapnet Goto Github PK
View Code? Open in Web Editor NEWCoAPnet is a high performance .NET library for CoAP based communication. It provides a CoAP client and a CoAP server. It also has DTLS support out of the box.
License: MIT License
CoAPnet is a high performance .NET library for CoAP based communication. It provides a CoAP client and a CoAP server. It also has DTLS support out of the box.
License: MIT License
Hello,
In the example, it says to create a connection the builder is setup as:
var connectOptions = new CoapClientConnectOptionsBuilder()
.WithHost("GW-B8D7AF2B3EA3.fritz.box")
.WithPort(5684)
.WithDtlsTransportLayer(new DtlsCoapTransportLayerOptionsBuilder()
.WithPreSharedKey("IDENTITY", "lqxbBH6o2eAKSo5A")
.Build())
.Build();
However, when the package is downloaded from the nuget link, yhis line doesnt seem to be accepted:
.WithDtlsTransportLayer(new DtlsCoapTransportLayerOptionsBuilder()
And Visual studio only seems to find:
.WithTransportLayer
How will the example be setup in this case?
Thank you!
For some reason, that I wasn't able to find yet, the Dispose function of the client is somehow blocked / won't exit.
It doesn't matter If I run the code in a unit test or a console application.
I'm using a using
statement, just like in the sample code. The code runs fine. I implemented a couple of functions to work with the Ikea Gateway.
But as soon as my code hits the end of the using statement, it will just run forever.
I also tried the example code from the wiki and I have the same behavior. So that could serve as my example code for the issue. But if I could provide any more details that can help you fix that, please let me know.
I'm using a MacBook Pro with Big Sur 11.2.3 and .NET 5 (5.0.102).
Hi,
Great library! You have done an amazing amount of work.
One question, in the example for using IKEA Tradfri (https://github.com/chkr1011/CoAPnet/wiki/CoAP-Client-Examples), you mention the following link to create the pre shared key (home-assistant/core#10252). I have tried to do this using the functions available in your library, trying various permutations of parameters etc, however I cannot get it to come back with a result due to timeouts. Is the basic functionality there in the DTLS libs to be able to string something together, or does there need to be additional work done in the WithDtlsTransportLayer function?
Kind Regards.
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!
I can't find the wiki with examples any more. Is it gone ?
Does this library have support for Block1 blockwise transfer (request payload)? If so, do you have any sample of this working?
We are trying to do a Coap Push with a large file payload but we can't see how to use blockwise transfer to send it.
So, I got this code to connect to an IKEA Tradri:
`public static async Task ConnectTradfri(ICoapClient theClient, string IP, string ID, string secretKey) {
Console.WriteLine("< CONNECTING...");
var connectOptions = new CoapClientConnectOptionsBuilder()
.WithHost(IP)
.WithPort(5684)
.WithDtlsTransportLayer(o => o.WithPreSharedKey(ID, secretKey))
.Build();
using (var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(taskTimout))) {
await theClient.ConnectAsync(connectOptions, cancellationTokenSource.Token);
}
}`
That works perfectly well when using the libs from version [1.0.9], but now that I upgraded to version [1.1.0] the same code is unable to connect. It now needs .ConfigureAwait(false); at the end.
Has something changed that I am missing? Or why could this be happening?
Hi,
I have been trying to get the Ikea Tradfri Symfonisk device to report its events via Observe in this library. The device is connected sucessfully and I can ask the gateway for its details and it even send random updates using Observe, however it will not report click and rotation events.
A clue as to why may be in the following comment within the deconz project. The developer says:
"bind the client OnOff cluster to a group. And then the client Level Control cluster. After that, it now behaves normally, waking up to send commands on click and turn. " (dresden-elektronik/deconz-rest-plugin#1898 (comment))
Is there the ability to do this in CoAPnet? I would really love to get this device working. So many uses for it.
Cheers!
Is the CoAP server with DTLS implemented?
I seem to only find CoAP Clients in this package
According to the standard, in a Block2 transfer the client should set the "more" bit in Block2 option as 0. Although this shouldn't pose an issue, it's still technically a requirement.
I added "receivedBlock2OptionValue.HasFollowingBlocks = false;" in the loop CoapClientBlockTransferReceiver.ReceiveFullPayload method
I cannot find any code for the server - is this another repo?
Hi, I was playing around with Tradfri (thanks a lot for this library BTW). And when I started making parallel requests I started noticing that there are weird situations where the message is trimmed (but maybe I'm even getting response to another request, it is difficult to tell in async context and given that all the responses are the same - device info to be exact).
I was able to fix this by augmenting CoapMessage
with byte[] PayloadBytes
and using that in CoapMessageToResponseConverter
. I assign PayloadBytes
here by just doing message.PayloadBytes = message.Payload.ToArray();
and voila the problem is gone (quick and dirty, but it did the job).
I didn't do more digging, but it makes me wonder whether the array segments aren't reused somewhere and reassigned before the converter has chance to pick up the data for the response.
This problem also occurs the most during jitting in steady state it is much less likely to occur.
I'll be happy to provide you with more feedback or a sample provided tou have a gateway to test it on 😉.
发生异常: CLR/CoAPnet.Exceptions.CoapCommunicationException
“CoAPnet.Exceptions.CoapCommunicationException”类型的异常在 System.Private.CoreLib.dll 中发生,但未在用户代码中进行处理: 'Error while resolving DNS name.'
发现内部异常,有关更多详细信息,请参阅变量窗口中的 $exception。
最里面的异常 System.Net.Sockets.SocketException : 不知道这样的主机。
在 CoAPnet.LowLevelClient.LowLevelCoapClient.d__12.MoveNext() 在 c:\Users\19112\Desktop\github\CoAPnet-master\CoAPnet-master\Source\CoAPnet\LowLevelClient\LowLevelCoapClient.cs 中: 第 118 行
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.