Changeset - 5b244673cf7f
[Not reviewed]
default
0 2 0
matthewreed - 7 years ago 2017-07-04 21:45:12

Implemented internal get data function and updated protocol definition
2 files changed with 27 insertions and 2 deletions:
0 comments (0 inline, 0 general)
inc/protocol.h
Show inline comments
 
@@ -52,14 +52,15 @@ typedef enum {
 
    WATER_TEMP = 0x000B,
 
    WATER_LEVEL = 0x000C,
 
    WATER_CONDUCTIVITY = 0x000D,
 
    WATER_PH = 0x000E,
 
    CAN_ID = 0x0100,
 
    DATA_RATE = 0x0101,
 
    GPIO = 0x0102,
 
    LED_BRIGHTNESS = 0x0103,
 
    LED_BRIGHTNESS = 0x0102,
 
    INPUT = 0x0103,
 
    OUTPUT = 0x0104,
 
} protocol_data_key_t;
 
 
void protocol_init(protocol_device_t device);
 
flash_settings_t* protocol_get_settings(void);
 
bool protocol_receive_message(CanRxMsgTypeDef* can_message);
 
bool protocol_send_message(protocol_message_t* message);
src/protocol.c
Show inline comments
 
@@ -121,12 +121,36 @@ bool protocol_send_data(protocol_data_ke
 
 
    result = protocol_send_message(&message);
 
 
    return result;
 
}
 
 
bool _protocol_get_data(protocol_message_t* message)
 
{
 
    bool result = false;
 
 
    if (message->key == CAN_ID)
 
    {
 
        protocol_send_data(message->key, message->sensor, protocol_settings.val.can_id);
 
    }
 
    else if (message->key == DATA_RATE)
 
    {
 
        protocol_send_data(message->key, message->sensor, ((float)protocol_settings.val.data_rate)/1000);
 
    }
 
    else if (message->key == LED_BRIGHTNESS)
 
    {
 
        protocol_send_data(message->key, message->sensor, protocol_settings.val.led_brightness);
 
    }
 
    else
 
    {
 
        //call config weak function
 
        result = protocol_get_data(message);
 
    }
 
    return result;
 
}
 
 
bool _protocol_config(protocol_message_t* message)
 
{
 
    bool result = false;
 
 
    if (message->key == CAN_ID)
 
    {
0 comments (0 inline, 0 general)