Merge pull request #418 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot 2019-08-30 19:14:01 +02:00 committed by GitHub
commit 9ed78e9be0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 59 additions and 22 deletions

View File

@ -169,7 +169,7 @@ Output of sensor and peripheral data is internally switched by a bitmask registe
| 4 | User sensor 1 | | 4 | User sensor 1 |
| 5 | User sensor 2 | | 5 | User sensor 2 |
| 6 | User sensor 3 | | 6 | User sensor 3 |
| 7 | reserved | | 7 | Batterylevel |
# Time sync # Time sync
@ -392,17 +392,26 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
0 = BME data off 0 = BME data off
1 = BME data on, sends BME data on port 7 [default] 1 = BME data on, sends BME data on port 7 [default]
0x15 set battery data on/off
0 = battery data off [default]
1 = battery data on, sends voltage on port 8
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.
0x81 get device status 0x81 get device status
Device answers with it's current status on Port 2. Device answers with it's current status on Port 2.
0x83 get battery status
Device answers with battery voltage on Port 8.
0x84 get device GPS status 0x84 get device GPS status
Device answers with it's current status on Port 4. Device answers with it's current status on Port 4.
0x85 get BME280 / BME680 sensor data 0x85 get BME280 / BME680 sensor data

View File

@ -21,7 +21,7 @@
#endif #endif
extern QueueHandle_t LoraSendQueue; extern QueueHandle_t LoraSendQueue;
extern TaskHandle_t lmicTask; extern TaskHandle_t lmicTask, lorasendTask;
esp_err_t lora_stack_init(); esp_err_t lora_stack_init();
void lmictask(void *pvParameters); void lmictask(void *pvParameters);

View File

@ -10,7 +10,7 @@
extern Ticker sendcycler; extern Ticker sendcycler;
void SendPayload(uint8_t port, sendprio_t prio); void SendPayload(uint8_t port, sendprio_t prio);
void sendCounter(void); void sendData(void);
void checkSendQueues(void); void checkSendQueues(void);
void flushQueues(); void flushQueues();
void sendcycle(void); void sendcycle(void);

View File

@ -8,6 +8,10 @@ static const char TAG[] = "flash";
nvs_handle my_handle; nvs_handle my_handle;
esp_err_t err; esp_err_t err;
#define PAYLOADMASK \
(GPS_DATA | ALARM_DATA | MEMS_DATA | COUNT_DATA | SENSOR1_DATA | \
SENSOR2_DATA | SENSOR3_DATA & ~BATT_DATA)
// populate cfg vars with factory settings // populate cfg vars with factory settings
void defaultConfig() { void defaultConfig() {
cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora sf, see pacounter.conf cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora sf, see pacounter.conf
@ -29,7 +33,7 @@ void defaultConfig() {
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
cfg.monitormode = 0; // 0=disabled, 1=enabled cfg.monitormode = 0; // 0=disabled, 1=enabled
cfg.runmode = 0; // 0=normal, 1=update cfg.runmode = 0; // 0=normal, 1=update
cfg.payloadmask = 0xFF; // all payload switched on cfg.payloadmask = PAYLOADMASK; // all payload switched on
cfg.bsecstate[BSEC_MAX_STATE_BLOB_SIZE] = { cfg.bsecstate[BSEC_MAX_STATE_BLOB_SIZE] = {
0}; // init BSEC state for BME680 sensor 0}; // init BSEC state for BME680 sensor

View File

@ -30,10 +30,12 @@ void doHousekeeping() {
#if (HAS_LORA) #if (HAS_LORA)
ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask)); uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask));
ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(lorasendTask), eTaskGetState(lorasendTask));
#endif #endif
#if (HAS_GPS) #if (HAS_GPS)
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask)); uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask));
#endif #endif
#ifdef HAS_SPI #ifdef HAS_SPI
ESP_LOGD(TAG, "spiloop %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "spiloop %d bytes left | Taskstate = %d",

View File

@ -65,7 +65,7 @@ void irqHandler(void *pvParameters) {
// is time to send the payload? // is time to send the payload?
if (InterruptStatus & SENDCYCLE_IRQ) if (InterruptStatus & SENDCYCLE_IRQ)
sendCounter(); sendData();
} }
} }

View File

@ -452,7 +452,7 @@ esp_err_t lora_stack_init() {
// start lmic send task // start lmic send task
xTaskCreatePinnedToCore(lora_send, // task function xTaskCreatePinnedToCore(lora_send, // task function
"lorasendtask", // name of task "lorasendtask", // name of task
2048, // stack size of task 3072, // stack size of task
(void *)1, // parameter of the task (void *)1, // parameter of the task
1, // priority of the task 1, // priority of the task
&lorasendTask, // task handle &lorasendTask, // task handle

View File

@ -174,6 +174,13 @@ void setup() {
// read (and initialize on first run) runtime settings from NVRAM // read (and initialize on first run) runtime settings from NVRAM
loadConfig(); // includes initialize if necessary loadConfig(); // includes initialize if necessary
// initialize display
#ifdef HAS_DISPLAY
strcat_P(features, " OLED");
DisplayIsOn = cfg.screenon;
init_display(PRODUCTNAME, PROGVERSION); // note: blocking call
#endif
#ifdef BOARD_HAS_PSRAM #ifdef BOARD_HAS_PSRAM
assert(psramFound()); assert(psramFound());
ESP_LOGI(TAG, "PSRAM found and initialized"); ESP_LOGI(TAG, "PSRAM found and initialized");
@ -305,13 +312,6 @@ void setup() {
strcat_P(features, " FILTER"); strcat_P(features, " FILTER");
#endif #endif
// initialize display
#ifdef HAS_DISPLAY
strcat_P(features, " OLED");
DisplayIsOn = cfg.screenon;
init_display(PRODUCTNAME, PROGVERSION); // note: blocking call
#endif
// initialize matrix display // initialize matrix display
#ifdef HAS_MATRIX_DISPLAY #ifdef HAS_MATRIX_DISPLAY
strcat_P(features, " LED_MATRIX"); strcat_P(features, " LED_MATRIX");

View File

@ -140,6 +140,16 @@ void set_bme(uint8_t val[]) {
} }
} }
void set_batt(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set battery mode to %s",
val[0] ? "on" : "off");
if (val[0]) {
cfg.payloadmask |= (uint8_t)BATT_DATA; // set bit in mask
} else {
cfg.payloadmask &= ~(uint8_t)BATT_DATA; // clear bit in mask
}
}
void set_payloadmask(uint8_t val[]) { void set_payloadmask(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set payload mask to %X", val[0]); ESP_LOGI(TAG, "Remote command: set payload mask to %X", val[0]);
cfg.payloadmask = val[0]; cfg.payloadmask = val[0];
@ -288,6 +298,17 @@ void get_bme(uint8_t val[]) {
#endif #endif
}; };
void get_batt(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get battery voltage");
#ifdef BAT_MEASURE_ADC
payload.reset();
payload.addVoltage(read_voltage());
SendPayload(BATTPORT, prio_normal);
#else
ESP_LOGW(TAG, "Battery voltage not supported");
#endif
};
void get_time(uint8_t val[]) { void get_time(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get time"); ESP_LOGI(TAG, "Remote command: get time");
payload.reset(); payload.reset();
@ -322,8 +343,9 @@ cmd_t table[] = {
{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}, {0x14, set_payloadmask, 1, true}, {0x13, set_sensor, 2, true}, {0x14, set_payloadmask, 1, true},
{0x15, set_bme, 1, true}, {0x80, get_config, 0, false}, {0x15, set_bme, 1, true}, {0x16, set_batt, 1, true},
{0x81, get_status, 0, false}, {0x84, get_gps, 0, false}, {0x80, get_config, 0, false}, {0x81, get_status, 0, false},
{0x83, get_batt, 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}};

View File

@ -53,7 +53,7 @@ void SendPayload(uint8_t port, sendprio_t prio) {
} // SendPayload } // SendPayload
// interrupt triggered function to prepare payload to send // interrupt triggered function to prepare payload to send
void sendCounter() { void sendData() {
uint8_t bitmask = cfg.payloadmask; uint8_t bitmask = cfg.payloadmask;
uint8_t mask = 1; uint8_t mask = 1;
@ -130,7 +130,7 @@ void sendCounter() {
mask <<= 1; mask <<= 1;
} // while (bitmask) } // while (bitmask)
} // sendCounter() } // sendData()
void flushQueues() { void flushQueues() {
#if (HAS_LORA) #if (HAS_LORA)

View File

@ -106,7 +106,7 @@ void process_timesync_req(void *taskparameter) {
payload.addByte(0x99); payload.addByte(0x99);
SendPayload(RCMDPORT, prio_high); SendPayload(RCMDPORT, prio_high);
// ...send a alive open a receive window for last time_sync_answer // ...send a alive open a receive window for last time_sync_answer
// LMIC_sendAlive(); LMIC_sendAlive();
} }
} // end of for loop to collect timestamp samples } // end of for loop to collect timestamp samples