apache / mynewt-mcumgr

Apache mynewt
https://mynewt.apache.org/
99 stars 76 forks source link

log_mgmt: Add support for number of log entries in mcumgr #172

Open vrahane opened 7 months ago

vrahane commented 7 months ago

This adds support for pulling number of entries from individual logs given the index. This change is backwards compatible and does not break anything.

Related mynewt-core PR: https://github.com/apache/mynewt-core/pull/3168 Related mynewt-newtmgr PR: https://github.com/apache/mynewt-newtmgr/pull/205

Example: Successful/Valid case:

$newtmgr --connstring peer_name="my_dev" --conntype oic_ble log num_entries reboot_log 0
Number of entries: 43
$newtmgr --connstring peer_name="my_dev" --conntype oic_ble log show reboot_log
Status: 0
Next index: 482
Name: reboot_log
Type: STORAGE
   [num_entries]    [index]            [timestamp] |         [module]          [level] [type]    [img] [message]
               0         16     1578455591078191us |       REBOOT (6)     CRITICAL (4)   cbor 71983333 {"cnt":311,"flags":"active bootable confirmed","hash":"719833337dcbb8cb4c0fc7356799faffde5614b93db2762eb769a7e6da3e7c95","img":"24.3.25.121935","rsn":"OTHER: 0x0"}
               1        416     1578474526687539us |       REBOOT (6)     CRITICAL (4)   cbor 9d378656 {"cnt":312,"flags":"active bootable confirmed","hash":"9d37333354ec570426e4284708a1b6d3a66278ee4633f705bb379d331331fe04","img":"24.3.25.173430","rsn":"OTHER: 0x0"}

Error case:

<Invalid log>
$newtmgr --connstring peer_name="my_dev" --conntype oic_ble log num_entries reboot 0
error: 5

<Invalid index>
$newtmgr --connstring peer_name="my_dev" --conntype oic_ble log num_entries reboot 4000
error: 5