diff --git a/src/protocol.c b/src/protocol.c --- a/src/protocol.c +++ b/src/protocol.c @@ -11,6 +11,11 @@ void protocol_init(protocol_device_t dev can_init(protocol_settings.val.can_id, DEFAULT_BROADCAST_ID); } +flash_settings_t* protocol_get_settings(void) +{ + return &protocol_settings; +} + bool protocol_send_test() { bool result = true; @@ -90,8 +95,7 @@ bool protocol_process_message(protocol_m break; case CONFIG: { - //call config weak function - result = protocol_config(message); + result = _protocol_config(message); } break; default: @@ -119,6 +123,29 @@ bool protocol_send_data(protocol_data_ke return result; } +bool _protocol_config(protocol_message_t* message) +{ + bool result = false; + + if (message->key == LED_BRIGHTNESS) + { + uint8_t brightness = (uint8_t)message->data.float_data; + result = led_set_brightness(brightness); + protocol_settings.val.led_brightness = brightness; + } + else if (message->key == DATA_RATE) + { + uint16_t data_rate = (uint16_t) message->data.float_data; + protocol_settings.val.data_rate = data_rate; + } + else + { + //call config weak function + result = protocol_config(message); + } + return result; +} + __weak bool protocol_estop(bool value) { return false;