Merge pull request #12471 from aabadie/pr/sys/suit_shell
sys/suit: sys/shell: examples/suit_update: add shell command for triggering suit updates
This commit is contained in:
commit
b88e2ecb6d
@ -19,6 +19,8 @@
|
|||||||
*
|
*
|
||||||
* @brief SUIT CoAP helper API
|
* @brief SUIT CoAP helper API
|
||||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||||
|
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -141,6 +143,14 @@ int suit_coap_get_blockwise_url(const char *url,
|
|||||||
coap_blksize_t blksize,
|
coap_blksize_t blksize,
|
||||||
coap_blockwise_cb_t callback, void *arg);
|
coap_blockwise_cb_t callback, void *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Trigger a SUIT udate
|
||||||
|
*
|
||||||
|
* @param[in] url url pointer containing the full coap url to the manifest
|
||||||
|
* @param[in] len length of the url
|
||||||
|
*/
|
||||||
|
void suit_coap_trigger(const uint8_t *url, size_t len);
|
||||||
|
|
||||||
#endif /* DOXYGEN */
|
#endif /* DOXYGEN */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -99,4 +99,8 @@ ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE)))
|
|||||||
SRC += sc_interactive_sync.c
|
SRC += sc_interactive_sync.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter suit_coap,$(USEMODULE)))
|
||||||
|
SRC += sc_suit.c
|
||||||
|
endif
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.base
|
include $(RIOTBASE)/Makefile.base
|
||||||
|
|||||||
38
sys/shell/commands/sc_suit.c
Normal file
38
sys/shell/commands/sc_suit.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup sys_shell_commands
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Trigger a firmware update from the shell
|
||||||
|
*
|
||||||
|
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "suit/coap.h"
|
||||||
|
|
||||||
|
|
||||||
|
int _suit_handler(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("Usage: %s <manifest url>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
suit_coap_trigger((uint8_t *)argv[1], strlen(argv[1]));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -168,6 +168,10 @@ extern int _test_start(int argc, char **argv);
|
|||||||
extern int _test_ready(int argc, char **argv);
|
extern int _test_ready(int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULE_SUIT_COAP
|
||||||
|
extern int _suit_handler(int argc, char **argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
const shell_command_t _shell_command_list[] = {
|
const shell_command_t _shell_command_list[] = {
|
||||||
{"reboot", "Reboot the node", _reboot_handler},
|
{"reboot", "Reboot the node", _reboot_handler},
|
||||||
#ifdef MODULE_CONFIG
|
#ifdef MODULE_CONFIG
|
||||||
@ -276,6 +280,9 @@ const shell_command_t _shell_command_list[] = {
|
|||||||
#ifdef MODULE_TEST_UTILS_INTERACTIVE_SYNC
|
#ifdef MODULE_TEST_UTILS_INTERACTIVE_SYNC
|
||||||
{ "r", "Test sync, Ready query", _test_ready },
|
{ "r", "Test sync, Ready query", _test_ready },
|
||||||
{ "s", "Test sync, Start test trigger", _test_start },
|
{ "s", "Test sync, Start test trigger", _test_start },
|
||||||
|
#endif
|
||||||
|
#ifdef MODULE_SUIT_COAP
|
||||||
|
{ "suit", "Trigger a SUIT firmware update", _suit_handler },
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
*
|
*
|
||||||
* @author Koen Zandberg <koen@bergzand.net>
|
* @author Koen Zandberg <koen@bergzand.net>
|
||||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
* @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;
|
code = COAP_CODE_REQUEST_ENTITY_TOO_LARGE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(_url, pkt->payload, payload_len);
|
|
||||||
_url[payload_len] = '\0';
|
|
||||||
|
|
||||||
code = COAP_CODE_CREATED;
|
code = COAP_CODE_CREATED;
|
||||||
LOG_INFO("suit: received URL: \"%s\"\n", _url);
|
LOG_INFO("suit: received URL: \"%s\"\n", (char*)pkt->payload);
|
||||||
msg_t m = { .content.value = SUIT_MSG_TRIGGER };
|
suit_coap_trigger(pkt->payload, payload_len);
|
||||||
msg_send(&m, _suit_coap_pid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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);
|
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[] = {
|
static const coap_resource_t _subtree[] = {
|
||||||
#ifdef MODULE_RIOTBOOT_SLOT
|
#ifdef MODULE_RIOTBOOT_SLOT
|
||||||
{ "/suit/slot/active", COAP_METHOD_GET, _slot_handler, NULL },
|
{ "/suit/slot/active", COAP_METHOD_GET, _slot_handler, NULL },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user