bristlemouth / bm_protocol

Primary Bristlemouth firmware repository
https://www.bristlemouth.org/
Apache License 2.0
10 stars 7 forks source link

Feature/bcmp cfg callbacks #90

Closed victorsowa12 closed 6 months ago

victorsowa12 commented 6 months ago

add the ability to call: bcmp_config_get, bcmp_config_set, bcmp_config_status_request, bcmp_config_del_key and provide a callback to be used when processing the reply, otherwise use the default behavior (print it out).

Example where I added a callback to the bm status command (I will remove this before merging since it should just use the default behavior).

bm cfg status 4d58ce2f22dfb374 s
BCMP - Sending message with seq_num 0
Successful status request send
BCMP message with seq_num 0 found
BCMP - Received reply to our request message with seq_num 0
Status callback <------------------------------------------------------------------- :)
Response msg -- Node Id:4d58ce2f22dfb374,Partition:1, Commit Status:0
Num Keys: 10
bridgePowerControllerEnabled
samplesPerReport
transmitAggregations
sampleIntervalMs
sampleDurationMs
subsampleIntervalMs
subsampleEnabled
currentReadingPeriodMs
alignmentInterval5Min
subsampleDurationMs

Example of the default behavior still happening when no callback is present:

bm cfg get 4d58ce2f22dfb374 s subsampleDurationMs
BCMP - Sending message with seq_num 1
Succesfully sent config get msg
BCMP message with seq_num 1 found
BCMP - Received reply to our request message with seq_num 1
Node Id: 4d58ce2f22dfb374 Value:5000