1 #include <sancus/reactive.h> 2 3 #include <stdio.h> 4 5 #include "wan_commands.h" 6 #include "ihd.h" 7 8 #define SMNAME HAN 9 10 static uint16_t SM_DATA(SMNAME) consumption_timestamp; 11 static uint8_t SM_DATA(SMNAME) supply_state; 12 static uint16_t SM_DATA(SMNAME) active_power_import; 13 static uint16_t SM_DATA(SMNAME) active_import_register; 14 15 16 #define CHANNEL_ESME 1 17 18 void SM_FUNC(SMNAME) get_input(uint8_t channel, const uint8_t *data, 19 size_t len) 20 { 21 if (channel == CHANNEL_ESME) { 22 if (len >= 9 && data[2] == GET_CONSUMPTION_DATA) { 23 consumption_timestamp += 1; 24 supply_state = data[4]; 25 active_power_import = data[5] | data[6] << (8*1); 26 active_import_register = data[7] | data[8] << (8*1); 27 28 ihd_update_supply_state(supply_state); 29 ihd_update_active_power_import(active_power_import); 30 ihd_update_active_import_register(active_import_register); 31 ihd_display(); 32 } 33 } 34 } 35 36 SM_INPUT(SMNAME, esme_in, data, len) 37 { 38 get_input(CHANNEL_ESME, data, len); 39 } 40