I'm Steve Hamblett, a long time Dartisan and C/C++/C# developer in my day job, with a particular interest in IOT/embedded stuff. See my Dart Pub publisher site for a few more details. For now here are some stats for my repositories -
A few badges -
A Coap package for dart
License: Other
I'm Steve Hamblett, a long time Dartisan and C/C++/C# developer in my day job, with a particular interest in IOT/embedded stuff. See my Dart Pub publisher site for a few more details. For now here are some stats for my repositories -
A few badges -
Hello @shamblett ,
I am using coap version 2.0.1 and checking markObserve() functionality for get request.
But it gives following error.
Please guide me.
2021-01-02 16:41:24.554 4771-4885/com.gladiance.gladiance_one I/flutter: 2021-01-02 16:41:24.553: INFO: >> Matcher - received response
<<< Response Message >>>
Type: 1, Code: 2.05 Content, Id: 26844, Token: 00004b74,
Options =
[
If-Match :
Uri Host : None
E-tags : ETag: 6b750232
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : 50
Max Age : 0
Uri Queries :
Accept : -1
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : 4
Size 1 : 0
Size 2 : 0
],
Payload :
{"resp":"error in query"}
2021-01-02 16:41:24.554 4771-4885/com.gladiance.gladiance_one I/flutter: 2021-01-02 16:41:24.554: SEVERE: >> Rejecting unmatchable response from Instance of 'CoapInternetAddress'
If a Client sends a multicast request and receives a response using blockwise transfer, it seems as if the client is currently not switching to a unicast transfer to handle the remaining blocks (c. f. RFC 7959, section 2.8). This causes problems as subsequent blocks will also be requested from the multicast address which leads to an exponential(?) growth of requests and responses (if multiple servers are part of the same group and provide a similar resource) until a final block has been reached while also corrupting the total payload.
I will try to provide a fix for this problem in the upcoming days.
I use a non confirmable observer from the example. Version 4.0.0 and 4.1.0 is working correctly, all events are coming in. In 4.2.0 and above a lot of events are missing after ~ 13 events.
final reqObsNon = CoapRequest(CoapCode.get, confirmable: false)..addUriPath('Json');
Hi,
Greetings!
I am using CoAP 3.4.0 library in my sample application. I used your given example of Hello World. After run the project on device, I managed to receive response first time. On second request it get timed out after retrying.
Please suggest me, if I am doing anything wrong.
Here I'm attached my sample code file and response file
main.txt
responses.txt
Thank you,
Chetan
Look into providing support for TCP as specified in RFC 8323.
I'm trying to use this package in a flutter app. I'm using the example here - coap/example/flutter/lib/main.dart. When I press the Floating Action Button, it connects to my simple node.js server and displays the response text. However, if I press that button again, I get the exception below. Actually, it appears to be in some sort of Timer, so it just repeats the same error over and over again.
[ +8 ms] E/flutter (22091): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: Cannot add new events after calling close
[ ] E/flutter (22091): #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:249:24)
[ ] E/flutter (22091): #1 EventBus.fire (package:event_bus/event_bus.dart:61:22)
[ ] E/flutter (22091): #2 CoapEventBus.fire (package:coap/src/event/coap_event_bus.dart:153:17)
[ ] E/flutter (22091): #3 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:177:15)
[ ] E/flutter (22091): #4 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:110:21)
[ ] E/flutter (22091): #5 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
[ ] E/flutter (22091): #6 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
[ ] E/flutter (22091): #7 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:140:11)
[ ] E/flutter (22091): #8 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
[ ] E/flutter (22091): #9 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
[ ] E/flutter (22091): #10 CoapTokenLayer.sendRequest (package:coap/src/stack/coap_token_layer.dart:28:11)
[ ] E/flutter (22091): #11 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
[ ] E/flutter (22091): #12 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
[ ] E/flutter (22091): #13 CoapBlockwiseLayer.sendRequest (package:coap/src/stack/coap_blockwise_layer.dart:56:13)
[ ] E/flutter (22091): #14 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
[ ] E/flutter (22091): #15 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
[ ] E/flutter (22091): #16 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
[ ] E/flutter (22091): #17 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
[ ] E/flutter (22091): #18 CoapStackTopLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:66:11)
[ ] E/flutter (22091): #19 CoapLayerStack.sendRequest (package:coap/src/stack/coap_layer_stack.dart:136:17)
[ ] E/flutter (22091): #20 CoapEndPoint.sendEpRequest.<anonymous closure> (package:coap/src/net/coap_endpoint.dart:82:37)
[ ] E/flutter (22091): #21 CoapExecutor.start.<anonymous closure> (package:coap/src/threading/coap_executor.dart:18:11)
[ ] E/flutter (22091): #22 _Executor.scheduleTask (package:executor/src/executor_impl.dart:61:29)
[ ] E/flutter (22091): <asynchronous suspension>
[ ] E/flutter (22091): #23 CoapExecutor.start (package:coap/src/threading/coap_executor.dart:17:14)
[ ] E/flutter (22091): #24 CoapEndPoint.sendEpRequest (package:coap/src/net/coap_endpoint.dart:82:14)
[ ] E/flutter (22091): #25 CoapRequest.send (package:coap/src/coap_request.dart:120:14)
[ ] E/flutter (22091): #26 CoapClient.send (package:coap/src/coap_client.dart:271:20)
[ ] E/flutter (22091): <asynchronous suspension>
[ ] E/flutter (22091): #27 CoapClient.get (package:coap/src/coap_client.dart:109:12)
[ ] E/flutter (22091): #28 _CoapScreenState._loadData (package:bbqtech/ui/test/coap.dart:264:50)
[ ] E/flutter (22091): #29 _CoapScreenState._buildTestButton.<anonymous closure> (package:bbqtech/ui/test/coap.dart:243:24)
[ ] E/flutter (22091): #30 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
[ ] E/flutter (22091): #31 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
[ ] E/flutter (22091): #32 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
[ ] E/flutter (22091): #33 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
[ ] E/flutter (22091): #34 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
[ ] E/flutter (22091): #35 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7)
[ ] E/flutter (22091): #36 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9)
[ ] E/flutter (22091): #37 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
[ ] E/flutter (22091): #38 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
[ ] E/flutter (22091): #39 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
[ ] E/flutter (22091): #40 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
[ ] E/flutter (22091): #41 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
[ ] E/flutter (22091): #42 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
[ ] E/flutter (22091): #43 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
[ ] E/flutter (22091): #44 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
[ ] E/flutter (22091): #45 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
[ ] E/flutter (22091): #46 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
[ ] E/flutter (22091): #47 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
[ ] E/flutter (22091): #48 _rootRunUnary (dart:async/zone.dart:1206:13)
[ ] E/flutter (22091): #49 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
[ ] E/flutter (22091): #50 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
[ ] E/flutter (22091): #51 _invoke1 (dart:ui/hooks.dart:265:10)
[ ] E/flutter (22091): #52 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
If the response from the server is a bit larger (>1k) the requests seem really unstable: the response payload frequently (always?) corrupts. Not really sure how to debug or get more information, any pointers would be great.
Hello @shamblett ,
I have updated coap 2.0.1 library, but I am getting following error most or times, this issue I never faced with 2.0.0 version. Please guide.
I/flutter (27746): 2021-01-01 18:07:52.530: INFO: >> Reliability - Scheduling transmission for
I/flutter (27746): <<< Request Message >>>
I/flutter (27746): Type: 0, Code: PUT, Id: 18429, Token: 0000589a,
I/flutter (27746): Options =
I/flutter (27746): [
I/flutter (27746): If-Match :
I/flutter (27746): Uri Host : Uri-Host: 192.168.1.18
I/flutter (27746): E-tags :
I/flutter (27746): None
I/flutter (27746): Uri Port : 5683
I/flutter (27746): Location Paths:
I/flutter (27746): Uri Paths : inline
I/flutter (27746): Content-Type : 0
I/flutter (27746): Max Age : None
I/flutter (27746): Uri Queries : Uri-Query: proj_abced_567qwfcsd/flid00009/rmid999/arid333
I/flutter (27746): Accept : 0
I/flutter (27746): Location Queries :
I/flutter (27746): Proxy Uri : None
I/flutter (27746): Proxy Scheme : None
I/flutter (27746): Block 1 : None
I/flutter (27746): Block 2 : None
I/flutter (27746): Observe : -1
I/flutter (27746): Size 1 : 0
I/flutter (27746): Size 2 : 0
I/flutter (27746): ],
I/flutter (27746): Payload :
I/flutter (27746): {"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100,"controlmode":1,"entityid":1,"setlevelpercent":0}
I/flutter (27746): 2021-01-01 18:07:52.530: INFO: >> Reliability - sending request, failed transmission count: 0
I/flutter (27746): 2021-01-01 18:07:52.530: INFO: >> Reliability - Retransmission timeout is 520 ms
I/flutter (27746): 2021-01-01 18:07:52.532: INFO: >> Matcher - Stored open request by KeyID[18429]) + KeyToken[0000589a]
E/flutter (27746): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method 'newMessageEncoder' was called on null.
E/flutter (27746): Receiver: null
E/flutter (27746): Tried calling: newMessageEncoder()
E/flutter (27746): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (27746): #1 CoapEndPoint._serializeRequest (package:coap/src/net/coap_endpoint.dart:225:28)
E/flutter (27746): #2 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:180:21)
E/flutter (27746): #3 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:110:21)
E/flutter (27746): #4 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
E/flutter (27746): #5 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
E/flutter (27746): #6 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:140:11)
E/flutter (27746): #7 CoapReliabilityLayer.sendRequest. (package:coap/src/stack/coap_reliability_layer.dart:137:28)
E/flutter (27746): #8 CoapTransmissionContext._timerElapsed (package:coap/src/stack/coap_reliability_layer.dart:98:20)
E/flutter (27746): #9 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (27746): #10 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27746): #11 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (27746): #12 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (27746): #13 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (27746): #14 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27746): #15 _CustomZone.bindCallback. (dart:async/zone.dart:1021:23)
E/flutter (27746): #16 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
E/flutter (27746): #17 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (27746): #18 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (27746): #19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (27746):
E/flutter (27746): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method 'newMessageEncoder' was called on null.
E/flutter (27746): Receiver: null
E/flutter (27746): Tried calling: newMessageEncoder()
E/flutter (27746): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (27746): #1 CoapEndPoint._serializeRequest (package:coap/src/net/coap_endpoint.dart:225:28)
E/flutter (27746): #2 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:180:21)
E/flutter (27746): #3 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:110:21)
E/flutter (27746): #4 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
E/flutter (27746): #5 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
E/flutter (27746): #6 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:140:11)
E/flutter (27746): #7 CoapReliabilityLayer.sendRequest. (package:coap/src/stack/coap_reliability_layer.dart:137:28)
E/flutter (27746): #8 CoapTransmissionContext._timerElapsed (package:coap/src/stack/coap_reliability_layer.dart:98:20)
E/flutter (27746): #9 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (27746): #10 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27746): #11 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (27746): #12 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (27746): #13 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (27746): #14 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27746): #15 _CustomZone.bindCallback. (dart:async/zone.dart:1021:23)
E/flutter (27746): #16 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
E/flutter (27746): #17 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (27746): #18 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (27746): #19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (27746):
I/flutter (27746): Loaded assets/intl/strings.json
May it is possible to build up the dtls support fot the coap-client
Hi, @shamblett
I was caught in a new difficulty that How to receive data continuously
.
The Flutter app's Loading State is always in a waiting state when a coap server send msg in it.
The Flutter App's code is example\flutter\lib\main.dart:
setState(() => _isLoading = true);
final CoapResponse response = await client.get();
setState(() {
_isLoading = false;
_data = response?.payloadString ?? 'No Data';
});
1. Is there a way to continuously receive the data?
2. Why always show WARNING: >> Matcher - Ignoring unmatchable piggy-backed response
?
Please help me.
The log see:
I/flutter ( 4189): 2021-02-04 22:00:09.261: INFO: >> CoapUtils:lookupHost host '192.168.0.100' is an IP address, not resolving
I/flutter ( 4189): 2021-02-04 22:00:09.273: INFO: >> Reliability - Scheduling transmission for
I/flutter ( 4189): <<< Request Message >>>
I/flutter ( 4189): Type: 0, Code: GET, Id: 4968, Token: 00006b23,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : Uri-Host: 192.168.0.100
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : 5683
I/flutter ( 4189): Location Paths:
I/flutter ( 4189): Uri Paths : hello
I/flutter ( 4189): Content-Type : None
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : None
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : 1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): null
I/flutter ( 4189): 2021-02-04 22:00:09.274: INFO: >> Reliability - sending request, failed transmission count: 0
I/flutter ( 4189): 2021-02-04 22:00:09.275: INFO: >> Reliability - Retransmission timeout is 3921 ms
I/flutter ( 4189): 2021-02-04 22:00:09.277: INFO: >> Matcher - Stored open request by KeyID[4968]) + KeyToken[00006b23]
I/flutter ( 4189): 2021-02-04 22:00:09.283: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
D/libc-netbsd( 4189): [getaddrinfo]: hostname=0.0.0.0; servname=(null); netid=0; mark=0
D/libc-netbsd( 4189): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
I/flutter ( 4189): 2021-02-04 22:00:13.203: WARNING: >> Reliability - Retransmission timeout elapsed
I/flutter ( 4189): 2021-02-04 22:00:13.205: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 4968
I/flutter ( 4189): 2021-02-04 22:00:13.208: INFO: >> Reliability - Scheduling transmission for
I/flutter ( 4189): <<< Request Message >>>
I/flutter ( 4189): Type: 0, Code: GET, Id: 4968, Token: 00006b23,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : Uri-Host: 192.168.0.100
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : 5683
I/flutter ( 4189): Location Paths:
I/flutter ( 4189): Uri Paths : hello
I/flutter ( 4189): Content-Type : None
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : None
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : 1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): null
I/flutter ( 4189): 2021-02-04 22:00:13.209: INFO: >> Reliability - sending request, failed transmission count: 1
I/flutter ( 4189): 2021-02-04 22:00:13.210: INFO: >> Reliability - Retransmission timeout is 7842 ms
I/flutter ( 4189): 2021-02-04 22:00:13.211: INFO: >> Matcher - Stored open request by KeyID[4968]) + KeyToken[00006b23]
I/flutter ( 4189): 2021-02-04 22:00:13.294: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 0s
I/flutter ( 4189): 2021-02-04 22:00:13.296: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 0s
I/flutter ( 4189): 2021-02-04 22:00:14.358: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 1.0010573s
I/flutter ( 4189): 2021-02-04 22:00:14.360: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 1.0010573s
I/flutter ( 4189): 2021-02-04 22:00:15.377: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 2.0011145s
I/flutter ( 4189): 2021-02-04 22:00:15.378: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 2.0011145s
I/flutter ( 4189): 2021-02-04 22:00:15.500: INFO: >> Start Mark-And-Sweep with 0 entries
I/flutter ( 4189): 2021-02-04 22:00:16.297: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 3.0011717s
I/flutter ( 4189): 2021-02-04 22:00:16.299: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 3.0011717s
I/flutter ( 4189): 2021-02-04 22:00:17.320: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 4.0012289s
I/flutter ( 4189): 2021-02-04 22:00:17.321: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 4.0012289s
I/flutter ( 4189): 2021-02-04 22:00:18.252: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 5.0012861s
I/flutter ( 4189): 2021-02-04 22:00:18.253: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 5.0012861s
I/flutter ( 4189): 2021-02-04 22:00:19.347: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 6.0013433s
I/flutter ( 4189): 2021-02-04 22:00:19.348: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 6.0013433s
I/flutter ( 4189): 2021-02-04 22:00:20.254: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 7.0014005s
I/flutter ( 4189): 2021-02-04 22:00:20.256: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 7.0014005s
I/flutter ( 4189): 2021-02-04 22:00:21.058: WARNING: >> Reliability - Retransmission timeout elapsed
I/flutter ( 4189): 2021-02-04 22:00:21.058: WARNING: >> Reliability - Timeout: retransmit message, failed count: 2 message: 4968
I/flutter ( 4189): 2021-02-04 22:00:21.059: INFO: >> Reliability - Scheduling transmission for
I/flutter ( 4189): <<< Request Message >>>
I/flutter ( 4189): Type: 0, Code: GET, Id: 4968, Token: 00006b23,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : Uri-Host: 192.168.0.100
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : 5683
I/flutter ( 4189): Location Paths:
I/flutter ( 4189): Uri Paths : hello
I/flutter ( 4189): Content-Type : None
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : None
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : 1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): null
I/flutter ( 4189): 2021-02-04 22:00:21.060: INFO: >> Reliability - sending request, failed transmission count: 2
I/flutter ( 4189): 2021-02-04 22:00:21.062: INFO: >> Reliability - Retransmission timeout is 15684 ms
I/flutter ( 4189): 2021-02-04 22:00:21.063: INFO: >> Matcher - Stored open request by KeyID[4968]) + KeyToken[00006b23]
I/flutter ( 4189): 2021-02-04 22:00:21.188: INFO: >> Matcher - received response
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
I/flutter ( 4189): Options =
I/flutter ( 4189): [
I/flutter ( 4189): If-Match :
I/flutter ( 4189): Uri Host : None
I/flutter ( 4189): E-tags :
I/flutter ( 4189): None
I/flutter ( 4189): Uri Port : None
I/flutter ( 4189): Location Paths: Location-Path: hello
I/flutter ( 4189): Uri Paths :
I/flutter ( 4189): Content-Type : 0
I/flutter ( 4189): Max Age : None
I/flutter ( 4189): Uri Queries :
I/flutter ( 4189): Accept : -1
I/flutter ( 4189): Location Queries :
I/flutter ( 4189): Proxy Uri : None
I/flutter ( 4189): Proxy Scheme : None
I/flutter ( 4189): Block 1 : None
I/flutter ( 4189): Block 2 : None
I/flutter ( 4189): Observe : -1
I/flutter ( 4189): Size 1 : 0
I/flutter ( 4189): Size 2 : 0
I/flutter ( 4189): ],
I/flutter ( 4189): Payload :
I/flutter ( 4189): Been running for 0s
I/flutter ( 4189): 2021-02-04 22:00:21.189: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.0.100 :
I/flutter ( 4189): <<< Response Message >>>
I/flutter ( 4189): Type: 2, Code: 2.05 Content, Id: 4968, Token: 00,
...
Hi @shamblett ,
I am using your ping request example.
I works with coap.me server, but does not work with my ESP server. It returns false after ping timeout.
Whereas, all other requests such as get, put etc. works with my ESP server.
Also from IOT CoaP app of play store, ping request returns true with my ESP server.
Only problem with my application.
Please guide me.
HERE IS MY CODE:
import 'package:coap/coap.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/coap_config.dart';
void main() {
runApp(MyApp(null));
}
// final client;
var count = 1;
class MyApp extends StatelessWidget {
CoapClient client;
MyApp(this.client);
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(client, title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
CoapClient client;
// MyHomePage(this.client);
MyHomePage(this.client, {Key key, this.title}) : super(key: key);
final String title;
@OverRide
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
int _counter = 0;
void _incrementCounter() async {
print('ISSUE: First getPut');
// if (_counter == 0) {
// sendPing();
sendGet();
// }
// await getPut(count);
// await sendCoap();
setState(() {
// sendCoap();
_counter++;
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
sendPing() async {
// Create a configuration class. Logging levels can be specified in
// the configuration file.
final conf = CoapConfig();
// Build the request uri, note that the request paths/query parameters can be changed
// on the request anytime after this initial setup.
// const host = 'coap.me';
const host = '192.168.1.16';
final uri = Uri(scheme: 'coap', host: host, port: conf.defaultPort);
// Create the client.
// The method we are using creates its own request so we do
// not need to supply one.
// The current request is always available from the client.
final client = CoapClient(uri, conf);
print('EXAMPLE - Ping client, sending ping request to '
'$host, waiting for response....');
// Perform the ping
final pingOk = await client.ping(10000);
if (pingOk) {
print('EXAMPLE - Ping response OK ');
} else {
print('EXAMPLE - Ping failed');
}
// Cancel the current request
print('EXAMPLE - Cleaning up');
client.close();
// exit(0);
}
When Dart 2.17 is released, enhanced enums will simplify our code a bit: dart-lang/sdk#47849
Examples:
CoapCode
could be broken down into int enumsCoapMediaType
could be int enumCoapMessageType
could be int enumRequest.observe
could be int enum?CoapDefinedAddress
could be string enum?See: https://pub.dev/packages/pedantic
Recommended alternative for Dart: https://pub.dev/packages/lints
Hi,
for the project I'm building I want to subscribe to events. I'm using this coap package with version 3.2.1. After about 10 successful events the events suddenly stop coming in. In a python script I'm using next to my project, the events do keep coming in. So the problem seems to be with either my dart code or possibly with this package.
My coap_config.yaml file is exactly the same as in the example. This is my dart code:
observeCoap() async {
var conf = CoapConfig();
connectedHost = CoapClient(Uri(
scheme: 'coap',
host: '10.0.1.220',
port: conf.defaultPort,
),
conf);
final CoapRequest request = CoapRequest.newGet();
request.addUriPath('Json');
request.markObserve();
request.responses.listen((data) {
print(data);
});
connectedHost!.request = request;
await connectedHost!.get();
}
I understand that it's hard to test this without having access to my testhardware, however does anyone else have this problem? And is there perhaps a test server that sends frequent events to the subscribers to test? I think this may be a problem with the ack message, but I'm not sure.
Thanks
Hello @shamblett, I am using your coap example.
I am sending put and get requests. If I send only put requests after a specific time intervals, it works with maximum 1 time retransmission.
But it I send get request and then send put request, the it continuously timeouts and send retransmission requests before receiving response of the previous requests. It goes in recursion mode. Please find the log outout given below.
Please guide.
Thank you.
Log output:
2020-12-18 10:06:18.052 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.051: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-18 10:06:18.062 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.062: INFO: >> Starting endpoint bound to InternetAddress('192.168.1.6', IPv4)
2020-12-18 10:06:18.123 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.123: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 9337, Token: 000060c1,
Options =
[
If-Match :
Uri Host : Uri-Host: 192.168.1.6
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : inline
Content-Type : None
Max Age : None
Uri Queries : Uri-Query: status/4/2/1
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-18 10:06:18.129 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.128: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-18 10:06:18.130 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.130: INFO: >> Reliability - Retransmission timeout is 732 ms
2020-12-18 10:06:18.140 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.140: INFO: >> Matcher - Stored open request by KeyID[9337]) + KeyToken[000060c1]
2020-12-18 10:06:18.164 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.164: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-18 10:06:18.871 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.871: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-18 10:06:18.874 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.874: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 9337
2020-12-18 10:06:18.878 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.878: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 9337, Token: 000060c1,
Options =
[
If-Match :
Uri Host : Uri-Host: 192.168.1.6
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : inline
Content-Type : None
Max Age : None
Uri Queries : Uri-Query: status/4/2/1
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-18 10:06:18.879 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.878: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-18 10:06:18.879 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.879: INFO: >> Reliability - Retransmission timeout is 594 ms
2020-12-18 10:06:18.881 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:18.881: INFO: >> Matcher - Stored open request by KeyID[9337]) + KeyToken[000060c1]
2020-12-18 10:06:19.072 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:19.072: INFO: >> Matcher - received response
<<< Response Message >>>
Type: 2, Code: 2.05 Content, Id: 9337, Token: 000060c1,
Options =
[
If-Match :
Uri Host : None
E-tags : ETag: 92970fdd
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : 50
Max Age : 0
Uri Queries :
Accept : -1
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"control":2,"unicastaddr":4,"controlmode":1,"udptstate":1,"setlevel":1}
2020-12-18 10:06:19.074 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:19.074: INFO: >> Matcher - cleaning up KeyID[9337])
2020-12-18 10:06:19.083 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:19.083: INFO: >> Reliability - Cancel retransmission for token: 000060c1 id: 9337
2020-12-18 10:06:19.117 13613-13715/com.gladiance.gladiance_one I/flutter: load status received: null
2020-12-18 10:06:19.122 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:19.122: INFO: >> Matcher - Exchange completed: Cleaning up KeyToken[000060c1]
2020-12-18 10:06:28.055 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:28.054: INFO: >> Start Mark-And-Sweep with 1 entries
2020-12-18 10:06:28.063 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:28.062: INFO: >> Mark-And-Sweep removes KeyID[9337])
2020-12-18 10:06:35.337 13613-13715/com.gladiance.gladiance_one I/flutter: payload = {"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:35.338 13613-13715/com.gladiance.gladiance_one I/flutter: path = inline, query = lamp, payload = {"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}, blocs size1: 0, blocs size2: 0
2020-12-18 10:06:35.344 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.343: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512
2020-12-18 10:06:35.345 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.344: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-18 10:06:35.346 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.345: INFO: >> Starting endpoint bound to InternetAddress('192.168.1.6', IPv4)
2020-12-18 10:06:35.349 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.348: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: PUT, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : Uri-Host: 192.168.1.6
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : inline
Content-Type : 0
Max Age : None
Uri Queries : Uri-Query: lamp
Accept : 0
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:35.349 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.349: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-18 10:06:35.350 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.349: INFO: >> Reliability - Retransmission timeout is 539 ms
2020-12-18 10:06:35.351 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.350: INFO: >> Matcher - Stored open request by KeyID[3454]) + KeyToken[000022d3]
2020-12-18 10:06:35.353 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.352: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-18 10:06:35.891 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.891: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-18 10:06:35.892 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.891: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 3454
2020-12-18 10:06:35.893 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.892: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: PUT, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : Uri-Host: 192.168.1.6
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : inline
Content-Type : 0
Max Age : None
Uri Queries : Uri-Query: lamp
Accept : 0
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:35.894 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.893: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-18 10:06:35.894 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.894: INFO: >> Reliability - Retransmission timeout is 611 ms
2020-12-18 10:06:35.895 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:35.895: INFO: >> Matcher - Stored open request by KeyID[3454]) + KeyToken[000022d3]
2020-12-18 10:06:36.014 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.014: INFO: >> Matcher - received response
<<< Response Message >>>
Type: 2, Code: 2.04 Changed, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : None
E-tags :
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:36.018 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.017: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.1.6 :
<<< Response Message >>>
Type: 2, Code: 2.04 Changed, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : None
E-tags :
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:36.508 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.508: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-18 10:06:36.509 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.508: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 3454
2020-12-18 10:06:36.510 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.509: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: PUT, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : Uri-Host: 192.168.1.6
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : inline
Content-Type : 0
Max Age : None
Uri Queries : Uri-Query: lamp
Accept : 0
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:36.511 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.510: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-18 10:06:36.512 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.511: INFO: >> Reliability - Retransmission timeout is 509 ms
2020-12-18 10:06:36.513 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.513: INFO: >> Matcher - Stored open request by KeyID[3454]) + KeyToken[000022d3]
2020-12-18 10:06:36.614 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.613: INFO: >> Matcher - received response
<<< Response Message >>>
Type: 2, Code: 2.04 Changed, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : None
E-tags :
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:36.616 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:36.615: WARNING: >> Matcher - Ignoring unmatchable piggy-backed response from 192.168.1.6 :
<<< Response Message >>>
Type: 2, Code: 2.04 Changed, Id: 3454, Token: 000022d3,
Options =
[
If-Match :
Uri Host : None
E-tags :
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
{"unicastaddr":4,"control":1,"setlevel":1,"udptstate":true,"curtain_delay_ms":100000,"controlmode":1,"entityid":1,"setlevelpercent":0}
2020-12-18 10:06:37.024 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:37.023: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-18 10:06:37.024 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:37.024: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 3454
2020-12-18 10:06:37.025 13613-13715/com.gladiance.gladiance_one I/flutter: 2020-12-18 10:06:37.025: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: PUT, Id: 3454, Token: 000022d3,
Options =
In the current version of the library, using multicast with block-wise transfer currently does not work anymore, as the client checks if the response's token matches the one of the original request.
Line 474 in 3f03f45
However, because the client switches to unicast when using block-wise transfer with a server, this check always returns false
because a new token is assigned once the switch is made. I will try to come up with a fix for this problem in the next couple of days.
Maybe the check could simply return true
if multicast is being used, like so?
.where((final e) => req.multicast || e.resp.token!.equals(req.token!))
Or could we add a field for an "original token" somewhere, which could be used for matching instead?
Remove old and deprecated:
examples/testserver-example
(duplicate example code, uses CoAP.NET which has not seen active development in ~8 years)examples/flutter_example
(superfluous)Hi @shamblett ,
Thanks for your great work,it help me a lot.
The difficulty I have is pass a IP address to CoapClient in a flutter App,when the App and a laptop on the same LAN. The laptop is CoAP server, it only has IP, no domain host.
Please suggest the solution. What can I do to make it work?
Regards
I tried bindAddress:
final CoapRequest request = CoapRequest.newGet();
request.bindAddress= InternetAddress('192.168.0.100');
request.addUriPath('hello');
client.request = request;
And add the permission to all of AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
But got the error :
I/flutter (15848): 2021-02-02 11:04:20.482: INFO: >> Reliability - sending request, failed transmission count: 0
I/flutter (15848): 2021-02-02 11:04:20.484: INFO: >> Reliability - Retransmission timeout is 4357 ms
I/flutter (15848): 2021-02-02 11:04:20.497: INFO: >> Matcher - Stored open request by KeyID[24968]) + KeyToken[0000170e]
I/flutter (15848): 2021-02-02 11:04:20.542: INFO: >> CoapNetworkUDP - binding to InternetAddress('192.168.0.100', IPv4)
D/libc-netbsd(15848): [getaddrinfo]: hostname=InternetAddress('192.168.0.100', IPv4); servname=(null); netid=0; mark=0
D/libc-netbsd(15848): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
D/libc-netbsd(15848): getaddrinfo: dnsproxy bogus hostname >>
D/libc-netbsd(15848): getaddrinfo: InternetAddress('192.168.0.100', IPv4) get result from proxy gai_error = 7
D/libc-netbsd(15848): [getaddrinfo]: hostname=InternetAddress('192.168.0.100', IPv4); servname=(null); netid=0; mark=0
D/libc-netbsd(15848): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0
D/libc-netbsd(15848): getaddrinfo: dnsproxy bogus hostname >>
D/libc-netbsd(15848): getaddrinfo: InternetAddress('192.168.0.100', IPv4) get result from proxy gai_error = 7
E/flutter (15848): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: Failed host lookup: 'InternetAddress('192.168.0.100', IPv4)' (OS Error: No address associated with hostname, errno = 7)
E/flutter (15848): #0 _NativeSocket.lookup. (dart:io-patch/socket_patch.dart:502:9)
E/flutter (15848): #1 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (15848): #2 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (15848): #3 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (15848): #4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (15848): #5 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (15848): #6 Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (15848): #7 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:567:7)
E/flutter (15848): #8 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (15848): #9 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (15848): #10 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (15848): #11 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (15848): #12 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15848): #13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (15848):
E/flutter (15848): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: Failed host lookup: 'InternetAddress('192.168.0.100', IPv4)' (OS Error: No address associated with hostname, errno = 7)
E/flutter (15848): #0 _NativeSocket.lookup. (dart:io-patch/socket_patch.dart:502:9)
E/flutter (15848): #1 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (15848): #2 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (15848): #3 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (15848): #4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (15848): #5 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (15848): #6 Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (15848): #7 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:567:7)
E/flutter (15848): #8 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (15848): #9 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (15848): #10 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (15848): #11 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
E/flutter (15848): #12 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15848): #13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (15848):
BTW, using a real domain host is fine.
Hi, great to see a CoAP library for Dart! I decided to try version 3.2.1 out and found some potential issues.
I'm getting intermittent errors:
Reliability - Retransmission timeout elapsed
Reliability - Timeout: retransmit message, failed count: 3 message: 27007
Matcher - Ignoring unmatchable piggy-backed response from localhost
Frequently polling for a resource will yield these failures 5-10% of the time. Both server and client are running on localhost so I think we can rule out issues with the connectivity... Latency on the server side is ~10 ms, CoAP client timeout is 3000 ms with 3 retries. The message size is about 60-120 bytes. Can't see anything indicating an error on the server side.
I'm also getting:
SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512
Perhaps this event, which I guess is an info message, doesn't need to be marked as the most severe event of them all in the logs?
I'm connecting with a server on a local network for example: 10.0.1.112
Since the latest update 3.4.1 I get the following error.
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: SocketException: Send failed (OS Error: Operation not permitted, errno = 1), address = 0:0:0:0:0:0:0:0, port = 0
#0 _NativeSocket.send (dart:io-patch/socket_patch.dart:1205:34)
#1 _RawDatagramSocket.send (dart:io-patch/socket_patch.dart:2438:15)
#2 CoapNetworkUDP.send (package:coap/src/channel/coap_network_udp.dart:52:18)
I am having some trouble trying to grasp how error handling is supposed to work. If sending a message times out, client.send()
returns and empty response, instead throwing a timeout exception.
When establishing a UDP connection fails, the error is cought (for logging), but never re-thrown. One could say that this is because your internet may be bad currently and it may be able to establish the connection later on, however it is never retried.
Maybe there is some fundamental concept of error in this package handling that i am missing?
Hi @shamblett I am using your flutter example to working on my CoAP Client. When I send request every time, first attempt get timed out and response received on second retransmit. Is it right? Please guide me if I am doing wrong. Here is the code snippet and log out put:
import 'package:coap/coap.dart';
import 'package:flutter/material.dart';
import 'config/coap_config.dart';
void main() => runApp(MyApp());
/// make linter happy
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
/// make linter happy
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _data;
bool _isLoading = false;
final _config = CoapConfig();
final host = 'coap.me';
// Client
CoapClient _client;
@override
void didChangeDependencies() {
super.didChangeDependencies();
_client = CoapClient(
Uri(scheme: 'coap', host: host, port: _config.defaultPort), _config);
}
Future<void> _loadData() async {
try {
// Create the request for the get request
final CoapRequest request = CoapRequest.newGet();
request.addUriPath('hello');
_client.request = request;
setState(() => _isLoading = true);
final CoapResponse response = await _client.get();
setState(() {
_isLoading = false;
_data = response?.payloadString ?? 'No Data';
});
} catch (e) {
print("Caught Error Doing COAP Stuff $e");
}
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Flutter CoAP'),
),
body: Center(
child: Builder(
builder: (_) {
if (_isLoading) {
return const CircularProgressIndicator();
}
if (_data != null) {
return Text('Response:\n $_data',
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18)
);
}
return const Text('Press the button to load data');
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: _loadData,
tooltip: 'Load',
child: Icon(Icons.cloud_download),
),
);
}
Log Output:
2020-12-10 11:04:17.810495+0530 Runner[432:56145] flutter: 2020-12-10 11:04:17.810: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 6812, Token: 00000ca2,
Options =
[
If-Match :
Uri Host : Uri-Host: coap.me
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : hello
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-10 11:04:17.810922+0530 Runner[432:56145] flutter: 2020-12-10 11:04:17.810: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-10 11:04:17.811139+0530 Runner[432:56145] flutter: 2020-12-10 11:04:17.811: INFO: >> Reliability - Retransmission timeout is 1393 ms
2020-12-10 11:04:17.811626+0530 Runner[432:56145] flutter: 2020-12-10 11:04:17.811: INFO: >> Matcher - Stored open request by KeyID[6812]) + KeyToken[00000ca2]
2020-12-10 11:04:17.812571+0530 Runner[432:56145] flutter: 2020-12-10 11:04:17.812: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-10 11:04:19.206718+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.206: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-10 11:04:19.207221+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.207: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 6812
2020-12-10 11:04:19.207848+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.207: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 6812, Token: 00000ca2,
Options =
[
If-Match :
Uri Host : Uri-Host: coap.me
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : hello
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-10 11:04:19.208282+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.208: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-10 11:04:19.208480+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.208: INFO: >> Reliability - Retransmission timeout is 1291 ms
2020-12-10 11:04:19.208956+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.208: INFO: >> Matcher - Stored open request by KeyID[6812]) + KeyToken[00000ca2]
2020-12-10 11:04:19.455576+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.455: INFO: >> Matcher - received response
<<< Response Message >>>
Type: 2, Code: 2.05 Content, Id: 6812, Token: 00000ca2,
Options =
[
If-Match :
Uri Host : None
E-tags :
None
Uri Port : None
Location Paths:
Uri Paths :
Content-Type : 0
Max Age : None
Uri Queries :
Accept : -1
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : -1
Size 1 : 0
Size 2 : 0
],
Payload :
world
2020-12-10 11:04:19.455972+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.455: INFO: >> Matcher - cleaning up KeyID[6812])
2020-12-10 11:04:19.456568+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.456: INFO: >> Reliability - Cancel retransmission for token: 00000ca2 id: 6812
2020-12-10 11:04:19.457640+0530 Runner[432:56145] flutter: 2020-12-10 11:04:19.457: INFO: >> Matcher - Exchange completed: Cleaning up KeyToken[00000ca2]
The send function from the coap_client
class is not using the returned value from the prepape method, it hat right?
In the coap_client
file we have this:
/// Send
Future<CoapResponse> send(CoapRequest request) async {
await prepare(request);
return request.send().waitForResponse(timeout);
}
Here the prepare(request)
return a CoapRequest
. I'm wondering if we must use the returned request from the prepare function or it is ok that way.
This package can't be used with Flutter because one of their dependency uses Dart mirrors wich is not supported by Flutter applications.
This is what I receive while trying to use this packagein a Flutter application:
E/flutter ( 9165): [ERROR:flutter/shell/common/shell.cc(199)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
E/flutter ( 9165): [ERROR:flutter/shell/common/engine.cc(198)] Could not prepare to run the isolate.
E/flutter ( 9165): [ERROR:flutter/shell/common/engine.cc(137)] Engine not prepare and launch isolate.
E/flutter ( 9165): [ERROR:flutter/shell/common/shell.cc(437)] Could not launch engine with configuration.
Edit:
This can solved by removing safe_config
from the dependencies since it uses Dart mirrors and use tool like code-generator to generate the configuration class from a .yaml
file.
Hi,
I'm trying to ping different servers using the CoAP package in my Flutter app. The first one works and returns true.
The second however gives back an error. In this example I've used the same host, but in the real app I would of course use a different host.
The reason I would like to ping different hosts is because I want to discover hardware on my local network by pinging different hosts.
pingCoap() async {
var conf = CoapConfig();
Uri uri = Uri(
scheme: 'coap',
host: 'coap.me',
port: conf.defaultPort,
);
var client1 = CoapClient(uri, conf);
bool firstPingResponse = await client1.ping(10000);
client1.close();
// This works
print(firstPingResponse);
Uri uri1 = Uri(
scheme: 'coap',
host: 'coap.me',
port: conf.defaultPort,
);
var client2 = CoapClient(uri1, conf);
bool secondPingResponse = await client2.ping(10000);
client2.close();
print(secondPingResponse);
}
This is the error in the console:
[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: RangeError: Index out of range: no indices are valid: 0
#0 TypedDataBuffer.[] (package:typed_data/src/typed_buffer.dart:32:26)
#1 ListMixin.removeAt (dart:collection/list.dart:538:20)
#2 CoapDatagramReader._readCurrentByte (package:coap/src/codec/datagram/coap_datagram_reader.dart:81:26)
#3 CoapDatagramReader.read (package:coap/src/codec/datagram/coap_datagram_reader.dart:34:9)
#4 CoapMessageDecoder18.readProtocol (package:coap/src/codec/decoders/coap_message_decoder18.dart:23:25)
#5 new CoapMessageDecoder18 (package:coap/src/codec/decoders/coap_message_decoder18.dart:14:5)
#6 CoapDraft18.newMessageDecoder (package:coap/src/specification/drafts/coap_draft18.dart:52:7)
#7 CoapEndPoint._receiveData (package:coap/src/net/coap_endpoint.dart:96:35)
#8 _rootRunUnary (dart:async/zone.dart:1362:47)
#9 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#10 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#11 CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
#12 _rootRunUnary (dart:async/zone.dart:1362:47)
#13 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#14 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#16 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#17 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#18 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#19 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#20 _rootRunUnary (dart:async/zone.dart:1362:47)
#21 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#23 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#24 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#25 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#26 _PendingEvents.schedule. (dart:async/stream_impl.dart:663:7)
#27 _rootRun (dart:async/zone.dart:1346:47)
#28 _CustomZone.run (dart:async/zone.dart:1258:19)
#29 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#30 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
#31 _rootRun (dart:async/zone.dart:1354:13)
#32 _CustomZone.run (dart:async/zone.dart:1258:19)
#33 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#34 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
#35 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#36 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
Am I doing something wrong? Or is it not possible to ping different hosts?
This limitation should perhaps at least be documented, better yet fixed for those who run multiple clients and want to use a base config as starting point.
Steps to reproduce:
FutureOr<void> main(List<String> args) async {
// intended for client1
final conf1 = CoapConfig();
// intended for client2, default config but different port (example)
final conf2 = CoapConfig()..defaultPort = 1234;
final uri = Uri(scheme: 'coap', host: 'coap.me', port: conf1.defaultPort);
final client1 = CoapClient(uri, conf1);
final request = CoapRequest.newGet();
request.addUriPath('large');
client1.request = request;
await client1.get();
client1.close();
}
Output:
Unhandled exception:
Null check operator used on a null value
#0 CoapEndPoint._serializeRequest (package:coap/src/net/coap_endpoint.dart:230:28)
#1 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:185:21)
#2 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:116:23)
#3 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
#4 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
#5 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:140:11)
#6 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
#7 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
#8 CoapTokenLayer.sendRequest (package:coap/src/stack/coap_token_layer.dart:28:11)
#9 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
#10 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
#11 CoapBlockwiseLayer.sendRequest (package:coap/src/stack/coap_blockwise_layer.dart:57:13)
#12 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
#13 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
#14 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10)
#15 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15)
#16 CoapStackTopLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:71:11)
#17 CoapLayerStack.sendRequest (package:coap/src/stack/coap_layer_stack.dart:142:18)
#18 CoapEndPoint.sendEpRequest.<anonymous closure> (package:coap/src/net/coap_endpoint.dart:89:37)
#19 CoapExecutor.start.<anonymous closure> (package:coap/src/threading/coap_executor.dart:18:11)
#20 _Executor.scheduleTask (package:executor/src/executor_impl.dart:61:29)
<asynchronous suspension>
Workaround, set spec
manually:
final CoapConfig coapConfig = CoapConfig()
..spec = CoapRfc7252();
When performing a (Block2) blockwise transfer, the block numbering seems to jump to 128 instead of 16 after the block with number 15 has been received. At the same time, (in my case) the block size jumps from 16 to 32 indicating that there seems to be an issue with the binary encoding. I will try to provide a code example for reproducing the issue.
hello @shamblett.The following exception is reported when I use markObserve()
log:
EXAMPLE - Sending get observable request to wsncoap.org, waiting for responses ....
2020-12-28 10:13:51.714: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512
2020-12-28 10:13:51.727: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-28 10:13:51.729: INFO: >> Starting endpoint bound to InternetAddress('139.196.187.107', IPv4)
2020-12-28 10:13:51.750: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 2461, Token: 00005929,
Options =
[
If-Match :
Uri Host : Uri-Host: wsncoap.org
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : obs
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : 0
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-28 10:13:51.752: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-28 10:13:51.753: INFO: >> Reliability - Retransmission timeout is 3618 ms
2020-12-28 10:13:51.756: INFO: >> Matcher - Stored open request by KeyID[2461]) + KeyToken[00005929]
2020-12-28 10:13:51.767: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
2020-12-28 10:13:55.378: WARNING: >> Reliability - Retransmission timeout elapsed
2020-12-28 10:13:55.379: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 2461
2020-12-28 10:13:55.379: INFO: >> Reliability - Scheduling transmission for
<<< Request Message >>>
Type: 0, Code: GET, Id: 2461, Token: 00005929,
Options =
[
If-Match :
Uri Host : Uri-Host: wsncoap.org
E-tags :
None
Uri Port : 5683
Location Paths:
Uri Paths : obs
Content-Type : None
Max Age : None
Uri Queries :
Accept : None
Location Queries :
Proxy Uri : None
Proxy Scheme : None
Block 1 : None
Block 2 : None
Observe : 0
Size 1 : 0
Size 2 : 0
],
Payload :
null
2020-12-28 10:13:55.379: INFO: >> Reliability - sending request, failed transmission count: 0
2020-12-28 10:13:55.379: INFO: >> Reliability - Retransmission timeout is 3616 ms
2020-12-28 10:13:55.379: INFO: >> Matcher - Stored open request by KeyID[2461]) + KeyToken[00005929]
Unhandled exception:
RangeError (index): Index out of range: no indices are valid: 0
#0 _Uint32ArrayView.[] (dart:typed_data-patch/typed_data_patch.dart:4168:7)
#1 CoapOption.intValue (package:coap/src/coap_option.dart:49:18)
#2 CoapOption.value (package:coap/src/coap_option.dart:108:16)
#3 CoapMessage.observe (package:coap/src/coap_message.dart:938:18)
#4 CoapUtil.optionsToString (package:coap/src/util/coap_util.dart:183:20)
#5 CoapMessage.toString (package:coap/src/coap_message.dart:349:35)
#6 CoapResponse.toString (package:coap/src/coap_response.dart:36:60)
#7 _StringBase._interpolate (dart:core-patch/string_patch.dart:848:19)
#8 CoapMatcher.receiveResponse (package:coap/src/net/coap_matcher.dart:229:54)
#9 CoapEndPoint._receiveData (package:coap/src/net/coap_endpoint.dart:137:35)
#10 _RootZone.runUnaryGuarded (dart:async/zone.dart:1384:10)
#11 CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
#12 _RootZone.runUnaryGuarded (dart:async/zone.dart:1384:10)
#13 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#14 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
#15 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:127:11)
#16 _WhereStream._handleData (dart:async/stream_pipe.dart:199:12)
#17 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:157:13)
#18 _RootZone.runUnaryGuarded (dart:async/zone.dart:1384:10)
#19 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#20 _DelayedData.perform (dart:async/stream_impl.dart:611:14)
#21 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
#22 _PendingEvents.schedule. (dart:async/stream_impl.dart:687:7)
#23 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#25 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#26 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
Process finished with exit code 255
example code:
import 'dart:async';
import 'package:coap/coap.dart';
import '../../config/coap_config.dart';
FutureOr main(List args) async {
// Create a configuration class. Logging levels can be specified in the
// configuration file.
final conf = CoapConfig();
// Build the request uri, note that the request paths/query parameters can be changed
// on the request anytime after this initial setup.
const host = 'wsncoap.org';
final uri = Uri(scheme: 'coap', host: host, port: conf.defaultPort);
// Create the client.
// The method we are using creates its own request so we do not
// need to supply one.
// The current request is always available from the client.
final client = CoapClient(uri, conf);
// Adjust the response timeout if needed, defaults to 32767 milliseconds
//client.timeout = 10000;
// Create the request for the get request
final request = CoapRequest.newGet();
request.addUriPath('obs');
// Mark the request as observable
request.markObserve();
client.request = request;
print('EXAMPLE - Sending get observable request to '
'$host, waiting for responses ....');
await client.get();
// Getting responses form the observable resource
request.responses.listen((CoapResponse response) {
print('EXAMPLE - payload: ${response.payloadString}');
});
}
After importing this package and I try to run my project (without using any class of the package just importing it), I'm receiving the following error:
[ERROR:flutter/shell/common/shell.cc(437)] Could not launch engine with configuration.
pubspec.yaml
:dependencies:
coap:
import 'package:coap/coap.dart';
void main() {
runApp(MyApp());
}
We don't seem to check if the socket is bound (send
's return value is typically ignored, and it's always -1?), but perhaps this is okay since we have retries anyway. Should we ignore any SocketExceptions
thrown by send
as well then?
Once this issue is fixed I need to remember to test if the previously bound socket is still usable, or if we need to re-bind after some downtime. Need to think about error handling for observe as well, on re-bind...
Example, turning my wifi off during this loop (testing what happens if I drop off a shaky network temporarily):
FutureOr<void> main() async {
final conf = CoapConfig();
final uri = Uri(
scheme: 'coap',
host: 'californium.eclipseprojects.io',
port: conf.defaultPort,
);
final client = CoapClient(uri, conf);
try {
for (var i = 0; i < 10; i++) {
print('Sending request $i');
final resp = await client.get('test');
if (resp.code != CoapCode.content) {
print('Request failed!');
}
await Future<void>.delayed(const Duration(seconds: 5));
}
} on Exception catch (e) {
print('CoAP encountered an exception: $e');
}
client.close();
}
Unhandled exception:
SocketException: Send failed (OS Error: Network is unreachable, errno = 51), address = 0.0.0.0, port = 0
#0 _NativeSocket.send (dart:io-patch/socket_patch.dart:1213:34)
#1 _RawDatagramSocket.send (dart:io-patch/socket_patch.dart:2450:15)
#2 CoapNetworkUDP.send (package:coap/src/network/coap_network_udp.dart:55:16)
#3 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:198:21)
#4 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:162:30)
#5 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:29:10)
#6 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:26:15)
#7 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:118:11)
#8 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:29:10)
#9 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:26:15)
#10 CoapTokenLayer.sendRequest (package:coap/src/stack/coap_token_layer.dart:35:11)
#11 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:29:10)
#12 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:26:15)
#13 CoapBlockwiseLayer.sendRequest (package:coap/src/stack/coap_blockwise_layer.dart:72:13)
#14 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:29:10)
#15 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:26:15)
#16 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:29:10)
#17 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:26:15)
#18 CoapStackTopLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:99:11)
#19 CoapLayerStack.sendRequest (package:coap/src/stack/coap_layer_stack.dart:197:18)
#20 CoapEndPoint.sendEpRequest.<anonymous closure> (package:coap/src/net/coap_endpoint.dart:105:37)
#21 _Executor.scheduleTask (package:executor/src/executor_impl.dart:61:29)
<asynchronous suspension>
Hi, @shamblett and @pedromassango
When I using observe() in a Flutter App, I got a fatal error:
E/flutter (12606): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The getter
'localEndpoint' was called on null.
E/flutter (12606): Receiver: null
E/flutter (12606): Tried calling: localEndpoint
E/flutter (12606): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (12606): #1 CoapEndpointManager.getDefaultEndpoint (package:coap/src/net/coap_endpoint_manager.dart:24:33)
E/flutter (12606): #2 CoapClient._getEffectiveEndpoint (package:coap/src/coap_client.dart:300:34)
E/flutter (12606): #3 CoapClient._observeAsync (package:coap/src/coap_client.dart:346:22)
E/flutter (12606): #4 CoapClient._observe (package:coap/src/coap_client.dart:335:22)
E/flutter (12606): #5 CoapClient.observe (package:coap/src/coap_client.dart:212:12)
E/flutter (12606): #6 _MyHomePageState._loadData (package:flutter_firstapp/main.dart:74:25)
my first version code:
final Uri uri = Uri(scheme: 'coap',host:'192.168.0.100', port: 5683);
// Client
client = CoapClient(uri, config);
final CoapRequest request = CoapRequest.newGet();
request.addUriPath('hello');
client.request = request;
client.request.responses.listen((event) {
setState(() {
_isLoading = false;
_data = event ?? 'No Data';
});
});
var observe = client.observe();
and then after debugging, the observe() called _observeAsync()
CoapObserveClientRelation _observeAsync(CoapRequest request,
ActionGeneric<CoapResponse> notify, ActionGeneric<FailReason> error) {
final endpoint = _getEffectiveEndpoint(request); // Throw the error above
final relation = CoapObserveClientRelation(request, endpoint, _config);
_doPrepare(request);
request.send();
return relation;
}
looks as _getEffectiveEndpoint(request)
need that _doPrepare(request) be called previously
.
Please check it.
Thanks
Please help me to solve these problems.
Hello @shamblett ,
I have set maxRetransmit: 1 in coap configuration file.
If I sent ping request or any other get or put request. If My host ip address is not reachable, the coap client continuesly retransmits the commands after time out. It should stop retransmitting after retransmit count reached to maxRetransmit.
Please suggest the solution. Is there any setting to achieve this?
I think the request can contain multiple ETags (multiple cached versions of a resource), but the response must never contain more than one (the current version of the resource).
In the RFC: https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.6
The ETag Option MUST NOT occur more than once in a response.
There is no default value for the ETag Option; if it is not present in a response, the server makes no statement about the entity-tag for the tagged representation.
To reduce confusion, I'm planning to switch etags
to singular nullable etag
for the response if no one objects, the etags
field should be part of the request in this case, not the CoapMessage
base class.
Options that are at least three bytes long are currently not correctly encoded. This is at least the case with the Accept and Block1/Block2 options.
After doing some more research I now think I discovered the real reason why this is happening: The bytes after the one for option delta and length are using an incorrect byte order which is why they get malformed. This should hopefully be relatively easy to fix.
Edit: The fix has been a bit more challenging than expected. I now realized that only numeric options like Block1, Block2, and Accept have a wrong byte order both during encoding and decoding while string-based options like uriPath are not affected. I will have another look into this.
(This issue is related to #47 where I first encountered this problem in the context of blockwise transfer.)
Hello,
Is there a sample server application available? Something I could just run and start sending CoAP Requests with a given client (such as Firefox Copper) and receive back CoAP Responses containing some example resources?
Thanks!
Bruno Melo.
A couple of things that puzzled me as I've dug into the code. I also want to stress that I understand that this is originally a port of another project, so I'm sure it carries some legacy from there, and I don't mean to nag or be a PITA. I've just created this issue to spark some discussion regarding possibilities revolving around the future direction of the repo.
This is not only confusing semantically but might also pose issues if this library was to support non-blocking sends in the future. Imagine:
final request = CoapRequest.newGet()..addUriPath('large');
client.request = request;
client.get().then((response) => print(response.payloadString));
final request2 = CoapRequest.newGet()..addUriPath('hello');
client.request = request2;
client.get().then((response) => print(response.payloadString));
print(client.request); // Two ongoing requests, which one is `client.request`?
Makes more sense to:
final request = CoapRequest.newGet()..addUriPath('large');
client.send(request).then((response) => print(response.payloadString));
final request2 = CoapRequest.newGet()..addUriPath('hello');
client.send(request2).then((response) => print(response.payloadString));
I know you can do both (synchronously), but should you be able to? In a larger piece of code, even with synchronous sends, with client.send(request)
it's clear what's going on without any added context, whereas with client.get()
it's much less so.
Proposal: Drop client.request
and related methods.
Confusing example now:
final conf = CoapConfig();
final uri = Uri(scheme: 'coap', host: 'coap.me', port: conf.defaultPort);
final client = CoapClient(uri, conf);
final request = CoapRequest.newGet()
..addUriPath('large')
..endpoint = notCoapDotMe;
var response = await client.send(request);
The client URI says coap.me but the request is sent somewhere else.
Proposal: Make request.endpoint
a private field, or drop it altogether if the refactoring is feasible. The request still has a destination
via its inheritance from CoapMessage
, and CoapRequest send()
could perhaps be moved to the client. Clients typically send requests, requests don't send themselves.
CoapResponse? _currentResponse;
CoapResponse? get response => _currentResponse;
threading
folder naming is a bit confusing. There is no threading going on there from what I can see. The executor is scheduling tasks on the main isolate, concurrency is not the same thing as parallellism.Proposal: Rename the folder to tasks
or scheduling
?
To make CI results a bit more accessible from the Github UI, it could be moved from Travis to Github Actions. Would it make sense to do so? Or do you prefer testing on Travis? I could provide a PR for the switch if you'd like.
lib/src/config/coap_config.dart:15:13: Error: The field 'CoapConfig.spec' has type 'CoapISpec', which does not match the corresponding type, 'CoapISpec?', in the overridden setter, 'DefaultCoapConfig.spec'.
- 'CoapISpec' is from 'package:coap/coap.dart' ('../../../../../.pub-cache/hosted/pub.dartlang.org/coap-3.1.0/lib/coap.dart').
CoapISpec spec;
^
../../../../../.pub-cache/hosted/pub.dartlang.org/coap-3.1.0/lib/src/coap_config.dart:23:14: Context: This is the overridden method ('spec').
CoapISpec? spec;
^
lib/src/config/coap_config.dart:15:13: Error: Field 'spec' should be initialized because its type 'CoapISpec' doesn't allow null.
- 'CoapISpec' is from 'package:coap/coap.dart' ('../../../../../.pub-cache/hosted/pub.dartlang.org/coap-3.1.0/lib/coap.dart').
CoapISpec spec;
^^^^
it appears the code generator is missing a single ?
for null safety
Going forward only CoAP IETF Draft 18 is going to be supported, the other older drafts should be removed.
The package should be updated to remove the older drafts, remove the configuration option to select the specification and the README updated to state that only Draft 18 is now supported.
More concise naming of internal classes would make the code a bit easier to read.
See: #113 (comment)
Hello,
I am facing this issue while working with coal operations.
I don't want to keep coap client running continuously in my app application.
So that I am closing it at some point.
But whenever required, when I tried to create new instance and send command on it, I am getting this exception.
Is there any method to clear bloc instances of coap client?
Please guide.
The client.timeout
overrides the timeout implicitly specified by the config, should we allow this/do we need this? Initial discussion: #76 (comment)
I propose just dropping the client.timeout
and letting the config dictate timeouts. Easier to manage in code and less confusing to the users of the library.
The docs state that this package does not support secure CoAP. Can you please explain me why?
I'm asking because I want to know if there is something that I can do to add support for it.
While it is good that connections are being re-used based on the (address, port)
identifier, in some cases you might want to have a dart program create multiple separate sessions to the same remote (address, port)
. For that, some kind of namespace could be introduced to overgo that, of course being hidden by default
Hi @shamblett , We are exploring your coap library with our project.
But we have observed that requests(GET/POST) are a bit slow.
In the best-case scenario, the time it takes to send a request and receive a response
is around 3 seconds.
Note : We also ran additional requests using this(https://github.com/Tanganelli/CoAPthon) Library.
In which case the request-response time period is below 500 milliseconds.
Below is sample code to produce the issue:
Coap version - 2.0.4
Future coapGetRequest() async {
print("GET REQUEST STARTED*");
final CoapConfig conf = CoapConfig();
const String host = "coap.me";
final Uri uri = Uri(scheme: 'coap', host: host, port: conf.defaultPort);
final CoapClient client = CoapClient(uri, conf);
//client.timeout = 3000;
final CoapRequest request = CoapRequest.newGet();
request.addUriPath('hello');
client.request = request;
print('Sending get request to $host, waiting for response....');
Stopwatch stopwatch = Stopwatch()..start();
final res = await client.get();
print(
"TIME ELAPSED : ${stopwatch.elapsed.inMilliseconds} milliseconds");
if (res != null) {
print("Response Received*");
print(res.payloadString);
} else {
print("***No Response received");
}
// Clean up
client.close();
print("GET REQUEST FINISHED");
// exit(0);
}
Log output:
I/flutter ( 5708): GET REQUEST STARTED*
I/flutter ( 5708): Sending get request to coap.me, waiting for response....
I/flutter ( 5708): 2021-06-23 11:21:58.387: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512
I/flutter ( 5708): 2021-06-23 11:21:58.412: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
I/flutter ( 5708): 2021-06-23 11:21:58.419: INFO: >> Starting endpoint bound to InternetAddress('134.102.218.18', IPv4)
I/flutter ( 5708): 2021-06-23 11:21:58.466: INFO: >> Reliability - Scheduling transmission for
I/flutter ( 5708): <<< Request Message >>>
I/flutter ( 5708): Type: 0, Code: GET, Id: 31273, Token: 00003258,
I/flutter ( 5708): Options =
I/flutter ( 5708): [
I/flutter ( 5708): If-Match :
I/flutter ( 5708): Uri Host : Uri-Host: coap.me
I/flutter ( 5708): E-tags :
I/flutter ( 5708): None
I/flutter ( 5708): Uri Port : 5683
I/flutter ( 5708): Location Paths:
I/flutter ( 5708): Uri Paths : hello
I/flutter ( 5708): Content-Type : None
I/flutter ( 5708): Max Age : None
I/flutter ( 5708): Uri Queries :
I/flutter ( 5708): Accept : None
I/flutter ( 5708): Location Queries :
I/flutter ( 5708): Proxy Uri : None
I/flutter ( 5708): Proxy Scheme : None
I/flutter ( 5708): Block 1 : None
I/flutter ( 5708): Block 2 : None
I/flutter ( 5708): Observe : -1
I/flutter ( 5708): Size 1 : 0
I/flutter ( 5708): Size 2 : 0
I/flutter ( 5708): ],
I/flutter ( 5708): Payload :
I/flutter ( 5708): null
I/flutter ( 5708): 2021-06-23 11:21:58.470: INFO: >> Reliability - sending request, failed transmission count: 0
I/flutter ( 5708): 2021-06-23 11:21:58.472: INFO: >> Reliability - Retransmission timeout is 4059 ms
I/flutter ( 5708): 2021-06-23 11:21:58.479: INFO: >> Matcher - Stored open request by KeyID[31273]) + KeyToken[00003258]
I/flutter ( 5708): 2021-06-23 11:21:58.498: INFO: >> CoapNetworkUDP - binding to 0.0.0.0
I/flutter ( 5708): 2021-06-23 11:22:02.575: WARNING: >> Reliability - Retransmission timeout elapsed
I/flutter ( 5708): 2021-06-23 11:22:02.577: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 31273
I/flutter ( 5708): 2021-06-23 11:22:02.581: INFO: >> Reliability - Scheduling transmission for
I/flutter ( 5708): <<< Request Message >>>
I/flutter ( 5708): Type: 0, Code: GET, Id: 31273, Token: 00003258,
I/flutter ( 5708): Options =
I/flutter ( 5708): [
I/flutter ( 5708): If-Match :
I/flutter ( 5708): Uri Host : Uri-Host: coap.me
I/flutter ( 5708): E-tags :
I/flutter ( 5708): None
I/flutter ( 5708): Uri Port : 5683
I/flutter ( 5708): Location Paths:
I/flutter ( 5708): Uri Paths : hello
I/flutter ( 5708): Content-Type : None
I/flutter ( 5708): Max Age : None
I/flutter ( 5708): Uri Queries :
I/flutter ( 5708): Accept : None
I/flutter ( 5708): Location Queries :
I/flutter ( 5708): Proxy Uri : None
I/flutter ( 5708): Proxy Scheme : None
I/flutter ( 5708): Block 1 : None
I/flutter ( 5708): Block 2 : None
I/flutter ( 5708): Observe : -1
I/flutter ( 5708): Size 1 : 0
I/flutter ( 5708): Size 2 : 0
I/flutter ( 5708): ],
I/flutter ( 5708): Payload :
I/flutter ( 5708): null
I/flutter ( 5708): 2021-06-23 11:22:02.582: INFO: >> Reliability - sending request, failed transmission count: 1
I/flutter ( 5708): 2021-06-23 11:22:02.585: INFO: >> Reliability - Retransmission timeout is 8118 ms
I/flutter ( 5708): 2021-06-23 11:22:02.586: INFO: >> Matcher - Stored open request by KeyID[31273]) + KeyToken[00003258]
I/flutter ( 5708): 2021-06-23 11:22:03.015: INFO: >> Matcher - received response
I/flutter ( 5708): <<< Response Message >>>
I/flutter ( 5708): Type: 2, Code: 2.05 Content, Id: 31273, Token: 00003258,
I/flutter ( 5708): Options =
I/flutter ( 5708): [
I/flutter ( 5708): If-Match :
I/flutter ( 5708): Uri Host : None
I/flutter ( 5708): E-tags :
I/flutter ( 5708): None
I/flutter ( 5708): Uri Port : None
I/flutter ( 5708): Location Paths:
I/flutter ( 5708): Uri Paths :
I/flutter ( 5708): Content-Type : 0
I/flutter ( 5708): Max Age : None
I/flutter ( 5708): Uri Queries :
I/flutter ( 5708): Accept : -1
I/flutter ( 5708): Location Queries :
I/flutter ( 5708): Proxy Uri : None
I/flutter ( 5708): Proxy Scheme : None
I/flutter ( 5708): Block 1 : None
I/flutter ( 5708): Block 2 : None
I/flutter ( 5708): Observe : -1
I/flutter ( 5708): Size 1 : 0
I/flutter ( 5708): Size 2 : 0
I/flutter ( 5708): ],
I/flutter ( 5708): Payload :
I/flutter ( 5708): world
I/flutter ( 5708): 2021-06-23 11:22:03.016: INFO: >> Matcher - cleaning up KeyID[31273])
I/flutter ( 5708): 2021-06-23 11:22:03.021: INFO: >> Reliability - Cancel retransmission for token: 00003258 id: 31273
I/flutter ( 5708): TIME ELAPSED : 6187 milliseconds
I/flutter ( 5708): Response Received*
I/flutter ( 5708): world
I/flutter ( 5708): 2021-06-23 11:22:03.038: INFO: >> Close - closing client
I/flutter ( 5708): 2021-06-23 11:22:03.039: INFO: >> Endpoint - stopping endpoint bound to InternetAddress('134.102.218.18', IPv4)
I/flutter ( 5708): 2021-06-23 11:22:03.040: INFO: >> Network UDP - closing coap.me, port 5683
I/flutter ( 5708): GET REQUEST FINISHED*
I/flutter ( 5708): 2021-06-23 11:22:03.044: INFO: >> Matcher - Exchange completed: Cleaning up KeyToken[00003258]
I/flutter ( 5708): 2021-06-23 11:22:03.046: INFO: >> Network UDP - closing coap.me, port 5683
Here is coap config:
version: "RFC7252"
defaultPort: 5683
defaultSecurePort: 5684
httpPort: 8080
ackTimeout: 3000 # ms
ackRandomFactor: 1.5
ackTimeoutScale: 2.0
maxRetransmit: 4
maxMessageSize: 1024
defaultBlockSize: 512
blockwiseStatusLifetime: 60000 # ms
useRandomIDStart: true
useRandomTokenStart: true
notificationMaxAge: 128000 # ms
notificationCheckIntervalTime: 86400000 # ms
notificationCheckIntervalCount: 100 # ms
notificationReregistrationBackoff: 2000 # ms
cropRotationPeriod: 2000 # ms
exchangeLifetime: 1247000 # ms
markAndSweepInterval: 10000 # ms
channelReceivePacketSize: 2048
deduplicator: "MarkAndSweep" # CropRotayion or Noop
Logging section
Target is none or console
logTarget: "console"
Log levels
logError: "true"
logDebug: "true"
logWarn: "true"
logInfo: "true"
Can altering config help ?
We also noticed:
I/flutter ( 5708): 2021-06-23 11:22:02.582: INFO: >> Reliability - sending request, failed transmission count: 1
Which clearly states that the request transmission failed.
What could be causing these failures? How can we address this issue?
The base/recommended lint config is pretty lenient: https://github.com/dart-lang/lints/blob/main/lib/recommended.yaml
Perhaps we could have a look at the list of additional linter rules and add the ones we like: https://dart.dev/tools/linter-rules
Perhaps this can be revised when Dart 2.17 is released, then the lints
package will be upgraded from v1.0.1 to v2.0.0 as well.
I've snap the project from repository and compiled it without problem. All tests pass. However, the execution of simple_client.dart fails with the error:
/usr/lib/dart/bin/dart --enable-asserts --enable-vm-service:60640 /home/michael_k/IdeaProjects/coap_dart/examples/simple_client.dart
Observatory listening on http://127.0.0.1:60640/
Resolved address : InternetAddress('::1', IPv6)
SJH - isLinkLocal - false
SJH - isLoopback - true
SJH - isLinkMulticast - false
SJH - type - InternetAddressType: IPv6
Simple client, sending request to localhost with path .well-known/core, waiting for response....
Unhandled exception:
SocketException: Send failed (OS Error: Address family not supported by protocol, errno = 97), address = localhost, port = 5683
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#4 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Process finished with exit code 255
Not sure that this error has any significant significance, since I don’t understand how a client can be checked if the server (or simple_server) is missing. Do you plan to write simple server? It's interesting to look at the real interaction of two applications.
Hello,
I’m trying to connect to my Ikea lights with Flutter. My issue is that when I try to do a post request the response is Code: 4.05 Method Not Allowed
which is weird because a post request should be allowed.
When I do the exact same request from command line there is no issue (with the SECURITY_CODE and PRE_SHARED_KEY replaced of course) :
Request: coap-client-openssl -m post -u "Client_identity" -k "SECURITY_CODE" -e '{"9090":"IDENTITY"}' "coaps://192.168.1.41:5684/15011/9063"
Response: {"9091":"PRE_SHARED_KEY","9029":"1.19.0026"}
Could you have a look to my code and tell me what’s wrong? I would be very grateful if you could help me to get this working, I really want to play with this!
If you are curious the request I try to do is the one described here: home-assistant-libs/pytradfri#90
Here is a minimum example followed by my pubspec
import 'package:flutter/material.dart';
import 'package:coap/coap.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Test lights',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const TestWidget());
}
}
class TestWidget extends StatefulWidget {
const TestWidget({
Key? key,
}) : super(key: key);
@override
State<TestWidget> createState() => _TestWidgetState();
}
class _TestWidgetState extends State<TestWidget> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: TextButton(
child: const Text('Test button'),
onPressed: () async {
final conf = DtlsConfig();
var credentials = PskCredentials(
identity: 'Client_identity',
preSharedKey: 'SECURITY_CODE',
);
PskCredentials pskCredentialsCallback(final String indentity) => credentials;
final uri = Uri(
scheme: 'coaps',
host: '192.168.1.41',
port: conf.defaultSecurePort,
);
final client = CoapClient(
uri,
conf,
pskCredentialsCallback: pskCredentialsCallback,
);
try {
client.events.on<Object>().listen(print);
final response = await client.post(
'15011/9063',
payload: '{"9090":"IDENTITY"}',
);
} on Exception catch (e) {
print('CoAP encountered an exception: $e');
}
client.close();
},
),
),
);
}
}
class DtlsConfig extends DefaultCoapConfig {
@override
final dtlsBackend = DtlsBackend.TinyDtls;
}
name: auto_lights
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.17.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
coap: ^4.1.0
dart_tinydtls_libs: ^0.1.1
dart_tinydtls: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
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.