rcommand.cpp: set payload mask & set BME data
This commit is contained in:
parent
43cf6b7fe5
commit
bbca15a76e
11
README.md
11
README.md
@ -156,7 +156,7 @@ If you're using a device with OLED display, or if you add such one to the I2C bu
|
|||||||
|
|
||||||
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
|
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
|
||||||
|
|
||||||
Output of user sensor data can be switched by user remote control command 0x13 sent to Port 2.
|
Output of user sensor data can be switched by user remote control command 0x14 sent to Port 2.
|
||||||
|
|
||||||
Output of sensor and peripheral data is internally switched by a bitmask register. Default mask (0xFF) can be tailored by editing *cfg.payloadmask* initialization value in [*configmanager.cpp*](src/configmanager.cpp) following this scheme:
|
Output of sensor and peripheral data is internally switched by a bitmask register. Default mask (0xFF) can be tailored by editing *cfg.payloadmask* initialization value in [*configmanager.cpp*](src/configmanager.cpp) following this scheme:
|
||||||
|
|
||||||
@ -383,6 +383,15 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
|||||||
byte 1 = user sensor number (1..3)
|
byte 1 = user sensor number (1..3)
|
||||||
byte 2 = sensor mode (0 = disabled / 1 = enabled [default])
|
byte 2 = sensor mode (0 = disabled / 1 = enabled [default])
|
||||||
|
|
||||||
|
0x14 set payload mask
|
||||||
|
|
||||||
|
byte 1 = sensor data payload mask (0..255, meaning of bits see above)
|
||||||
|
|
||||||
|
0x15 set BME data on/off
|
||||||
|
|
||||||
|
0 = BME data off
|
||||||
|
1 = BME data on, sends BME data on port 7 [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.
|
||||||
|
@ -143,7 +143,9 @@ int checkIaqSensorStatus(void) {
|
|||||||
|
|
||||||
// store current BME sensor data in struct
|
// store current BME sensor data in struct
|
||||||
void bme_storedata(bmeStatus_t *bme_store) {
|
void bme_storedata(bmeStatus_t *bme_store) {
|
||||||
if (I2C_MUTEX_LOCK()) { // block i2c bus access
|
|
||||||
|
if ((cfg.payloadmask && MEMS_DATA) &
|
||||||
|
(I2C_MUTEX_LOCK())) { // block i2c bus access
|
||||||
|
|
||||||
#ifdef HAS_BME680
|
#ifdef HAS_BME680
|
||||||
if (iaqSensor.run()) { // if new data is available
|
if (iaqSensor.run()) { // if new data is available
|
||||||
|
@ -131,6 +131,20 @@ void set_gps(uint8_t val[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_bme(uint8_t val[]) {
|
||||||
|
ESP_LOGI(TAG, "Remote command: set BME mode to %s", val[0] ? "on" : "off");
|
||||||
|
if (val[0]) {
|
||||||
|
cfg.payloadmask |= (uint8_t)MEMS_DATA; // set bit in mask
|
||||||
|
} else {
|
||||||
|
cfg.payloadmask &= ~(uint8_t)MEMS_DATA; // clear bit in mask
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_payloadmask(uint8_t val[]) {
|
||||||
|
ESP_LOGI(TAG, "Remote command: set payload mask to %X", val[0]);
|
||||||
|
cfg.payloadmask = val[0];
|
||||||
|
}
|
||||||
|
|
||||||
void set_sensor(uint8_t val[]) {
|
void set_sensor(uint8_t val[]) {
|
||||||
#if (HAS_SENSORS)
|
#if (HAS_SENSORS)
|
||||||
switch (val[0]) { // check if valid sensor number 1...4
|
switch (val[0]) { // check if valid sensor number 1...4
|
||||||
@ -307,7 +321,8 @@ 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},
|
||||||
{0x13, set_sensor, 2, true}, {0x80, get_config, 0, false},
|
{0x13, set_sensor, 2, true}, {0x14, set_payloadmask, 1, true},
|
||||||
|
{0x15, set_bme, 1, true}, {0x80, get_config, 0, false},
|
||||||
{0x81, get_status, 0, false}, {0x84, get_gps, 0, false},
|
{0x81, get_status, 0, false}, {0x84, get_gps, 0, false},
|
||||||
{0x85, get_bme, 0, false}, {0x86, get_time, 0, false},
|
{0x85, get_bme, 0, false}, {0x86, get_time, 0, false},
|
||||||
{0x87, set_time, 0, false}, {0x99, set_flush, 0, false}};
|
{0x87, set_time, 0, false}, {0x99, set_flush, 0, false}};
|
||||||
|
Loading…
Reference in New Issue
Block a user