Skip to content
This repository was archived by the owner on Jan 10, 2021. It is now read-only.

Commit 588e18d

Browse files
committed
Fix bug causing sensors not to initialize.
- Move function call for initialization in PRINTF outside - Add variable color LED turn off callback function
1 parent 1464521 commit 588e18d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

apc-node-ipv6/apc-sensor-node/apc-sensor-node.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,12 @@ publish_led_off(void *d)
853853
}
854854
/*---------------------------------------------------------------------------*/
855855
static void
856+
callback_led_off(void *data){
857+
unsigned int color = *((unsigned int *)data);
858+
leds_off(color);
859+
}
860+
/*---------------------------------------------------------------------------*/
861+
static void
856862
pub_handler(const char *topic, uint16_t topic_len, const uint8_t *chunk,
857863
uint16_t chunk_len)
858864
{
@@ -1438,6 +1444,7 @@ PROCESS_THREAD(apc_sensor_node_en_sensors_process, ev, data)
14381444
{
14391445
//initialization
14401446
uint8_t i;
1447+
static uint32_t color;
14411448
PROCESS_EXITHANDLER();
14421449
PROCESS_BEGIN();
14431450
PRINTF("APC Sensor Node (Sensor Initialization) begins...\n");
@@ -1446,8 +1453,15 @@ PROCESS_THREAD(apc_sensor_node_en_sensors_process, ev, data)
14461453
for (i = 0; i < SENSOR_COUNT; i++) {
14471454
sensor_infos[i].sensor_type = SENSOR_TYPES[i];
14481455
sensor_infos[i].is_calibrated = 0;
1456+
int res = activate_sensor(sensor_infos[i].sensor_type) == APC_SENSOR_OPFAILURE;
14491457
PRINTF("apc_sensor_node_en_sensors_process: Sensor(0x%01x): %s\n", sensor_infos[i].sensor_type,
1450-
activate_sensor(sensor_infos[i].sensor_type) == APC_SENSOR_OPFAILURE ? "ERROR\0" : "OK\0" );
1458+
res ? "ERROR\0" : "OK\0" );
1459+
if (res)
1460+
color = LEDS_GREEN;
1461+
else
1462+
color = LEDS_RED;
1463+
leds_on(color);
1464+
ctimer_set(&ct_led, PUBLISH_LED_ON_DURATION, callback_led_off, &color);
14511465
}
14521466
#if !ADC_SENSORS_CONF_USE_EXTERNAL_ADC
14531467
//configure the analog multiplexer

0 commit comments

Comments
 (0)