You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/07/26 23:24:53 UTC
[GitHub] [mynewt-newtmgr] ccollins476ad opened a new pull request #133:
nmxact: API change for CoAP operations
ccollins476ad opened a new pull request #133: nmxact: API change for CoAP operations
URL: https://github.com/apache/mynewt-newtmgr/pull/133
This is a massive PR.
This PR changes the CoAP functions in the `sesn` interface. In particular, it replaces the old API with three low-level functions:
```
// Creates a listener for incoming CoAP messages matching the
// specified criteria.
ListenCoap(mc nmcoap.MsgCriteria) (*nmcoap.Listener, error)
// Cancels the CoAP listener with the specified criteria.
StopListenCoap(mc nmcoap.MsgCriteria)
// Transmits a CoAP message.
TxCoap(m coap.Message) error
```
Helper functions that combine these operations in useful ways are implemented in `sesn/sesn_util.go`.
Prior to this change, `sesn` contained only two CoAP functions:
```
TxCoapOnce(m coap.Message,
opt TxOptions) (coap.COAPCode, []byte, error)
TxCoapObserve(m coap.Message, opt TxOptions, NotifCb GetNotifyCb,
stopsignal chan int) (coap.COAPCode, []byte, []byte, error)
```
Both of these functions performed transmit followed by a blocking receive. There were two issues with these functions:
1. Lots of duplicated logic in each `sesn` implementation.
2. Some forms of application layer security are not possible.
Re: 2- for example, say secure notifications are implemented as follows:
> Notification is encrypted and wrapped in a second, unencrypted, CoAP notification. The outer message always specifies the same resource and has an indeterminate token.
To receive these notifications, the application needs to set up a permanent
listener for the secure resource. This listener needs to be created
independently; it should not be paired with a transmit operation. To make this
possible, the "listen" operation needs to be a standalone function.
More generally, an interface with low level functions leads to less code
duplication and a better design.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services