Tanganelli / CoAPthon3

CoAPthon3 is a porting to python3 of my CoAPthon library. CoAPthon3 is a python3 library to the CoAP protocol compliant with the RFC. Branch is available for the Twisted framework.
MIT License
58 stars 50 forks source link

Specific implementation question on multiple coap responses #28

Closed Cyber1000 closed 4 years ago

Cyber1000 commented 4 years ago

@Tanganelli Sorry for the question but perhaps you can have a quick look on an usage of your library. I'm having a problem regarding a philips air purifier, which uses a propriatary connection, realized with coap.

Issue:

In short:

The problem:

Is there something I'm missing to get multiple responses on one request or to get a bigger response? Or do you think, that there must be something devicespecific which doesn't sound like coap ...

Thanks for your time!

Tanganelli commented 4 years ago

Hi, I looked at the reported snippet, and I discovered that you are actually trying to instigate an observing relationship: request.observe = 0. Is it intentional? In either case, to exploit bigger payloads CoAP uses the blockwise "plugin". You can explicitly exploit it by setting request.block. Take a look at the example files.

BR Giacomo

Il giorno mar 19 mag 2020 alle ore 00:16 Cyber1000 notifications@github.com ha scritto:

@Tanganelli https://github.com/Tanganelli Sorry for the question but perhaps you can have a quick look on an usage of your library. I'm having a problem regarding a philips air purifier, which uses a propriatary connection, realized with coap.

Issue:

In short:

  • send a request to device
  • device responds with a coap-message (which is AES encrypted json)
  • decrypt the AES

The problem:

  • some devices seem to have payload bigger than 1138 bytes (which seems to be the limit), it is cut of and can't be decoded therefore
  • My guess is that I should get 2 coap-responses on one request
  • I've little knowledge about coap, I've reused this part of code, which seems only to work were the payload fits into one coap-package
  • And I own a device where the payload fits into one coap package (so not really easy to test/fix)
  • Relevant code is here: https://github.com/Cyber1000/py-air-control/blob/0e530158d283da5bb0c306137ea1681a4ce10b7b/pyairctrl/airctrl.py#L792
    • mk_request followed by send_request
    • the client is a HelperClient: from coapthon.client.helperclient import HelperClient

Is there something I'm missing to get multiple responses on one request or to get a bigger response? Or do you think, that there must be something devicespecific which doesn't sound like coap ...

Thanks for your time!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Tanganelli/CoAPthon3/issues/28, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPN6VQJ5SCYXNDFRRPOU3RSGXTRANCNFSM4NEO4B4Q .

Cyber1000 commented 4 years ago

trying to instigate an observing relationship: request.observe = 0. Is it intentional? I took this from the former implementation there, the intention was more like "never change a running system" - good point, no I didn't want an observable here (at least not for now)

Could you lead me to an example file, I've searched this:

But didn't find anything like request.block or blockwise in there.

Thanks!

Tanganelli commented 4 years ago

Hi,

take a look at plugtest.py, and in particular to the function def test_td_coap_block_01_client(self). I know it is not an example but it shows how to include block2 option to specify the size of fragments (in the example 1024). Obviously it is possible to include such information even in the mk_request by means of dictionary arguments. In either case, however, the library should provide to the client a single response with the concatenation of payloads, I say should because I think there could be a bug when blockwise is combined with observing.

BR Giacomo

Il giorno mar 19 mag 2020 alle ore 20:39 Cyber1000 notifications@github.com ha scritto:

trying to instigate an observing relationship: request.observe = 0. Is it intentional? I took this from the former implementation there, the intention was more like "never change a running system" - good point, no I didn't want an observable here (at least not for now)

Could you lead me to an example file, I've searched this:

But didn't find anything like request.block or blockwise in there.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Tanganelli/CoAPthon3/issues/28#issuecomment-631006319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPN6V4TV4MTLDG3PM5F73RSLG5TANCNFSM4NEO4B4Q .

Cyber1000 commented 4 years ago

Ah thanks I see, I'll try it this weekend.

Best regards!

Cyber1000 commented 4 years ago

29 seemed to solve the problem