rcommand 0x13 user sensor on/off
This commit is contained in:
1 parent
467f6d70f8
commit
1a24689652
7 files changed
+54
-5
No files matched your search
+2
-2
@@ -13,8 +13,8 @@
|
||||
#define SPI_SCLK GPIO_NUM_18
|
||||
#define SPI_CS GPIO_NUM_5
|
||||
|
||||
#define HAS_BME 0x77 // BME680 sensor on I2C bus (SDA=4/SCL=15); comment out if not present
|
||||
|
||||
// enable only if device has these sensors, otherwise comment these lines
|
||||
#define HAS_BME 0x77 // BME680 sensor on I2C bus (default SDA=4/SCL=15); comment out if not present
|
||||
#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||
|
||||
#define CFG_sx1276_radio 1 // select LoRa chip
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
// Hardware related definitions for Heltec V2 LoRa-32 Board
|
||||
|
||||
//#define HAS_BME 0x77 // BME680 sensor on I2C bus (SDI=21/SCL=22); comment out
|
||||
//if not present
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define CFG_sx1276_radio 1
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
// Hardware related definitions for TTGO T-Beam board
|
||||
|
||||
#define HAS_SENSORS 1 // test
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
|
||||
|
||||
+26
-2
@@ -134,6 +134,29 @@ void set_gps(uint8_t val[]) {
|
||||
}
|
||||
}
|
||||
|
||||
void set_sensor(uint8_t val[]) {
|
||||
switch (val[0]) { // check if valid sensor number 1...4
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
break; // valid sensor number -> continue
|
||||
default:
|
||||
ESP_LOGW(
|
||||
TAG,
|
||||
"Remote command set sensor mode called with invalid sensor number");
|
||||
return; // invalid sensor number -> exit
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Remote command: set sensor #%d mode to %s", val[0],
|
||||
val[1] ? "on" : "off");
|
||||
|
||||
if (val[1])
|
||||
cfg.payloadmask |= sensor_mask(val[0]); // set bit
|
||||
else
|
||||
cfg.payloadmask &= ~sensor_mask(val[0]); // clear bit
|
||||
}
|
||||
|
||||
void set_beacon(uint8_t val[]) {
|
||||
uint8_t id = val[0]; // use first parameter as beacon storage id
|
||||
memmove(val, val + 1, 6); // strip off storage id
|
||||
@@ -269,8 +292,9 @@ cmd_t table[] = {
|
||||
{0x0d, set_vendorfilter, 1, false}, {0x0e, set_blescan, 1, true},
|
||||
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
|
||||
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, false},
|
||||
{0x80, get_config, 0, false}, {0x81, get_status, 0, false},
|
||||
{0x84, get_gps, 0, false}, {0x85, get_bme, 0, false},
|
||||
{0x13, set_sensor, 2, true}, {0x80, get_config, 0, false},
|
||||
{0x81, get_status, 0, false}, {0x84, get_gps, 0, false},
|
||||
{0x85, get_bme, 0, false},
|
||||
};
|
||||
|
||||
const uint8_t cmdtablesize =
|
||||
|
||||
+15
-1
@@ -4,7 +4,21 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = "main";
|
||||
|
||||
uint8_t * sensor_read(uint8_t sensor) {
|
||||
uint8_t sensor_mask(uint8_t sensor_no) {
|
||||
switch (sensor_no) {
|
||||
case 1:
|
||||
return (uint8_t)SENSOR1_DATA;
|
||||
case 2:
|
||||
return (uint8_t)SENSOR2_DATA;
|
||||
break;
|
||||
case 3:
|
||||
return (uint8_t)SENSOR3_DATA;
|
||||
case 4:
|
||||
return (uint8_t)SENSOR4_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *sensor_read(uint8_t sensor) {
|
||||
|
||||
static uint8_t buf[SENSORBUFFER] = {0};
|
||||
uint8_t length = 3;
|
||||
|
||||
Reference in new issue
Block a user