Change the CC26xx web demo to use the button HAL
This commit is contained in:
parent
70dc73ff9d
commit
5f190be6c9
@ -45,7 +45,7 @@
|
||||
#include "lib/list.h"
|
||||
#include "sys/process.h"
|
||||
#include "net/ipv6/sicslowpan.h"
|
||||
#include "button-sensor.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "batmon-sensor.h"
|
||||
#include "httpd-simple.h"
|
||||
#include "cc26xx-web-demo.h"
|
||||
@ -882,8 +882,6 @@ init_sensors(void)
|
||||
list_add(sensor_list, &mpu_gyro_x_reading);
|
||||
list_add(sensor_list, &mpu_gyro_y_reading);
|
||||
list_add(sensor_list, &mpu_gyro_z_reading);
|
||||
|
||||
SENSORS_ACTIVATE(reed_relay_sensor);
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -977,16 +975,16 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ev == sensors_event && data == CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER) {
|
||||
if((CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER)->value(
|
||||
BUTTON_SENSOR_VALUE_DURATION) > CLOCK_SECOND * 5) {
|
||||
printf("Restoring defaults!\n");
|
||||
cc26xx_web_demo_restore_defaults();
|
||||
} else {
|
||||
init_sensor_readings();
|
||||
|
||||
process_post(PROCESS_BROADCAST, cc26xx_web_demo_publish_event, NULL);
|
||||
}
|
||||
if(ev == button_hal_release_event &&
|
||||
((button_hal_button_t *)data)->unique_id ==
|
||||
CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER) {
|
||||
init_sensor_readings();
|
||||
process_post(PROCESS_BROADCAST, cc26xx_web_demo_publish_event, NULL);
|
||||
} else if(ev == button_hal_periodic_event &&
|
||||
((button_hal_button_t *)data)->unique_id ==
|
||||
CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER) {
|
||||
printf("Restoring defaults!\n");
|
||||
cc26xx_web_demo_restore_defaults();
|
||||
} else if(ev == httpd_simple_event_new_config) {
|
||||
save_config();
|
||||
#if BOARD_SENSORTAG
|
||||
|
@ -98,18 +98,18 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* User configuration */
|
||||
/* Take a sensor reading on button press */
|
||||
#define CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER &button_left_sensor
|
||||
#define CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
|
||||
/* Payload length of ICMPv6 echo requests used to measure RSSI with def rt */
|
||||
#define CC26XX_WEB_DEMO_ECHO_REQ_PAYLOAD_LEN 20
|
||||
|
||||
#if BOARD_SENSORTAG
|
||||
/* Force an MQTT publish on sensor event */
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &reed_relay_sensor
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_REED_RELAY
|
||||
#elif BOARD_LAUNCHPAD
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &button_left_sensor
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
#else
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER &button_down_sensor
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_DOWN
|
||||
#endif
|
||||
|
||||
#define CC26XX_WEB_DEMO_STATUS_LED LEDS_GREEN
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/ctimer.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "button-sensor.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "board-peripherals.h"
|
||||
#include "cc26xx-web-demo.h"
|
||||
#include "dev/leds.h"
|
||||
@ -882,10 +882,14 @@ PROCESS_THREAD(mqtt_client_process, ev, data)
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == sensors_event && data == CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER) {
|
||||
if(state == MQTT_CLIENT_STATE_ERROR) {
|
||||
connect_attempt = 1;
|
||||
state = MQTT_CLIENT_STATE_REGISTERED;
|
||||
if(ev == button_hal_release_event) {
|
||||
button_hal_button_t *btn = (button_hal_button_t *)data;
|
||||
|
||||
if(btn->unique_id == CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER) {
|
||||
if(state == MQTT_CLIENT_STATE_ERROR) {
|
||||
connect_attempt = 1;
|
||||
state = MQTT_CLIENT_STATE_REGISTERED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -901,7 +905,9 @@ PROCESS_THREAD(mqtt_client_process, ev, data)
|
||||
if((ev == PROCESS_EVENT_TIMER && data == &publish_periodic_timer) ||
|
||||
ev == PROCESS_EVENT_POLL ||
|
||||
ev == cc26xx_web_demo_publish_event ||
|
||||
(ev == sensors_event && data == CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER)) {
|
||||
(ev == button_hal_release_event &&
|
||||
((button_hal_button_t *)data)->unique_id ==
|
||||
CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER)) {
|
||||
state_machine();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user