coap v1.2.0
Crystal Lang CoAP Protocol
Communicate with IoT devices supporting CoAP
Installation
-
Add the dependency to your
shard.yml
:dependencies: coap: github: spider-gazelle/coap
-
Run
shards install
Usage
require "coap"
# client has similar semantics to HTTP::Client
client = CoAP::Client.new(URI.parse("coap://coap.me"))
# requests inherit from HTTP::Request so work the same way
request = CoAP::Request.new("get", "/test")
# use client.exec! to send a request, it returns a channel for obtaining responses
# this is because you can multi-cast requests and each device will send a response
response_channel = client.exec!(request)
# you might only be expecting a single response
response = response_channel.receive
response.status_code # => 205
response.headers["Content-Format"] # => "text/plain"
response.body # => "welcome to the ETSI plugtest!"
Repository
coap
Owner
Statistic
- 0
- 0
- 4
- 1
- 2
- 9 months ago
- September 14, 2020
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 13:22:09 GMT
Languages