rcommand 0x13 user sensor on/off
This commit is contained in:
parent
467f6d70f8
commit
1a24689652
@ -305,6 +305,11 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
|||||||
byte 1 = beacon ID (0..255)
|
byte 1 = beacon ID (0..255)
|
||||||
bytes 2..7 = beacon MAC with 6 digits (e.g. MAC 80:ab:00:01:02:03 -> 0x80ab00010203)
|
bytes 2..7 = beacon MAC with 6 digits (e.g. MAC 80:ab:00:01:02:03 -> 0x80ab00010203)
|
||||||
|
|
||||||
|
0x13 set user sensor mode
|
||||||
|
|
||||||
|
byte 1 = user sensor number (1..4)
|
||||||
|
byte 2 = sensor mode (0 = disabled / 1 = enabled [default])
|
||||||
|
|
||||||
0x80 get device configuration
|
0x80 get device configuration
|
||||||
|
|
||||||
Device answers with it's current configuration on Port 3.
|
Device answers with it's current configuration on Port 3.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef _SENSOR_H
|
#ifndef _SENSOR_H
|
||||||
#define _SENSOR_H
|
#define _SENSOR_H
|
||||||
|
|
||||||
|
uint8_t sensor_mask(uint8_t sensor_no);
|
||||||
uint8_t * sensor_read(uint8_t sensor);
|
uint8_t * sensor_read(uint8_t sensor);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -13,8 +13,8 @@
|
|||||||
#define SPI_SCLK GPIO_NUM_18
|
#define SPI_SCLK GPIO_NUM_18
|
||||||
#define SPI_CS GPIO_NUM_5
|
#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 HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||||
|
|
||||||
#define CFG_sx1276_radio 1 // select LoRa chip
|
#define CFG_sx1276_radio 1 // select LoRa chip
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
// Hardware related definitions for Heltec V2 LoRa-32 Board
|
// 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 HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||||
#define CFG_sx1276_radio 1
|
#define CFG_sx1276_radio 1
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
// Hardware related definitions for TTGO T-Beam board
|
// 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 HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||||
|
|
||||||
|
@ -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[]) {
|
void set_beacon(uint8_t val[]) {
|
||||||
uint8_t id = val[0]; // use first parameter as beacon storage id
|
uint8_t id = val[0]; // use first parameter as beacon storage id
|
||||||
memmove(val, val + 1, 6); // strip off 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},
|
{0x0d, set_vendorfilter, 1, false}, {0x0e, set_blescan, 1, true},
|
||||||
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
|
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
|
||||||
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, false},
|
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, false},
|
||||||
{0x80, get_config, 0, false}, {0x81, get_status, 0, false},
|
{0x13, set_sensor, 2, true}, {0x80, get_config, 0, false},
|
||||||
{0x84, get_gps, 0, false}, {0x85, get_bme, 0, false},
|
{0x81, get_status, 0, false}, {0x84, get_gps, 0, false},
|
||||||
|
{0x85, get_bme, 0, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t cmdtablesize =
|
const uint8_t cmdtablesize =
|
||||||
|
@ -4,7 +4,21 @@
|
|||||||
// Local logging tag
|
// Local logging tag
|
||||||
static const char TAG[] = "main";
|
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};
|
static uint8_t buf[SENSORBUFFER] = {0};
|
||||||
uint8_t length = 3;
|
uint8_t length = 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user