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
 
@@ -55,8 +55,9 @@ typedef enum {
 
    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);
src/protocol.c
Show inline comments
 
@@ -124,6 +124,30 @@ bool protocol_send_data(protocol_data_ke
 
    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;
0 comments (0 inline, 0 general)