From 21dbc40e58a79f487d1ee34129f16e26cb6ba120 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 9 Aug 2020 02:46:08 +0200 Subject: message handling iface updated --- fw/fe310/eos/power.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'fw/fe310/eos/power.c') diff --git a/fw/fe310/eos/power.c b/fw/fe310/eos/power.c index 5c874e0..2b13c9f 100644 --- a/fw/fe310/eos/power.c +++ b/fw/fe310/eos/power.c @@ -19,14 +19,16 @@ static eos_evt_handler_t evt_handler[EOS_PWR_MAX_MTYPE]; static unsigned char power_btn_down; static void power_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) { + unsigned char mtype; + if ((buffer == NULL) || (len < 1)) { eos_net_bad_handler(type, buffer, len); return; } - unsigned char mtype = buffer[0]; - if (mtype < EOS_PWR_MAX_MTYPE) { - evt_handler[mtype](type, buffer, len); + mtype = buffer[0]; + if ((mtype < EOS_PWR_MAX_MTYPE) && evt_handler[mtype]) { + evt_handler[mtype](mtype, buffer, len); } else { eos_net_bad_handler(type, buffer, len); } @@ -49,7 +51,7 @@ void eos_power_init(void) { int i; for (i=0; i