Adding CoAP to our devices
We are now ready to implement CoAP in our projects. To do this, we create two new projects, which we will call SensorCoap
and ActuatorCoap
, copying the corresponding code from the Sensor
and Actuator
projects. If we wish to retain HTTP functionality, we can copy the code from the SensorHttp
and ActuatorHttp
projects instead. Our devices can support multiple protocols. We use the same hardware as we used in previous chapters. We add the Waher.Networking.CoAP.UWP
NuGet package to both projects.
Note
For .NET standard, .NET Core, or traditional .NET Framework projects, you can use the Waher.Networking.CoAP NuGet instead. Universal Windows Platform apps use different libraries and runtime binaries when it comes to accessing network adaptors. For this reason, it requires a somewhat modified version of the original library.
We must also make sure to initialize the runtime inventory of classes with a reference to the CoAP library assembly, in the beginning of the application...