1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 07:51:19 +01:00

suit: add helper function for triggering updates

This commit is contained in:
Alexandre Abadie 2019-10-11 22:59:09 +02:00
parent c68470fc3d
commit 560ee3bac9
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 27 additions and 6 deletions

View File

@ -19,6 +19,8 @@
*
* @brief SUIT CoAP helper API
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
*/
@ -141,6 +143,19 @@ int suit_coap_get_blockwise_url(const char *url,
coap_blksize_t blksize,
coap_blockwise_cb_t callback, void *arg);
/**
* @brief Set the url used to fetch the SUIT manifest
*
* @param[in] url url pointer containing the full coap url to the manifest
* @param[in] len length of the url
*/
void suit_coap_set_url(const uint8_t *url, size_t len);
/**
* @brief Trigger a SUIT udate
*/
void suit_coap_trigger(void);
#endif /* DOXYGEN */
#ifdef __cplusplus

View File

@ -17,6 +17,8 @@
*
* @author Koen Zandberg <koen@bergzand.net>
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @}
*/
@ -480,13 +482,9 @@ static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
code = COAP_CODE_REQUEST_ENTITY_TOO_LARGE;
}
else {
memcpy(_url, pkt->payload, payload_len);
_url[payload_len] = '\0';
code = COAP_CODE_CREATED;
LOG_INFO("suit: received URL: \"%s\"\n", _url);
msg_t m = { .content.value = SUIT_MSG_TRIGGER };
msg_send(&m, _suit_coap_pid);
LOG_INFO("suit: received URL: \"%s\"\n", (char*)pkt->payload);
suit_coap_trigger(pkt->payload, payload_len);
}
}
else {
@ -497,6 +495,14 @@ static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
COAP_FORMAT_NONE, NULL, 0);
}
void suit_coap_trigger(const uint8_t *url, size_t len)
{
memcpy(_url, url, len);
_url[len] = '\0';
msg_t m = { .content.value = SUIT_MSG_TRIGGER };
msg_send(&m, _suit_coap_pid);
}
static const coap_resource_t _subtree[] = {
#ifdef MODULE_RIOTBOOT_SLOT
{ "/suit/slot/active", COAP_METHOD_GET, _slot_handler, NULL },