commit
9ed78e9be0
11
README.md
11
README.md
@ -169,7 +169,7 @@ Output of sensor and peripheral data is internally switched by a bitmask registe
|
||||
| 4 | User sensor 1 |
|
||||
| 5 | User sensor 2 |
|
||||
| 6 | User sensor 3 |
|
||||
| 7 | reserved |
|
||||
| 7 | Batterylevel |
|
||||
|
||||
|
||||
# Time sync
|
||||
@ -392,6 +392,11 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
0 = BME data off
|
||||
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
|
||||
|
||||
Device answers with it's current configuration on Port 3.
|
||||
@ -400,6 +405,10 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
|
||||
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
|
||||
|
||||
Device answers with it's current status on Port 4.
|
||||
|
@ -21,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
extern QueueHandle_t LoraSendQueue;
|
||||
extern TaskHandle_t lmicTask;
|
||||
extern TaskHandle_t lmicTask, lorasendTask;
|
||||
|
||||
esp_err_t lora_stack_init();
|
||||
void lmictask(void *pvParameters);
|
||||
|
@ -10,7 +10,7 @@
|
||||
extern Ticker sendcycler;
|
||||
|
||||
void SendPayload(uint8_t port, sendprio_t prio);
|
||||
void sendCounter(void);
|
||||
void sendData(void);
|
||||
void checkSendQueues(void);
|
||||
void flushQueues();
|
||||
void sendcycle(void);
|
||||
|
@ -8,6 +8,10 @@ static const char TAG[] = "flash";
|
||||
nvs_handle my_handle;
|
||||
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
|
||||
void defaultConfig() {
|
||||
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.monitormode = 0; // 0=disabled, 1=enabled
|
||||
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] = {
|
||||
0}; // init BSEC state for BME680 sensor
|
||||
|
||||
|
@ -30,6 +30,8 @@ void doHousekeeping() {
|
||||
#if (HAS_LORA)
|
||||
ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d",
|
||||
uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask));
|
||||
ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d",
|
||||
uxTaskGetStackHighWaterMark(lorasendTask), eTaskGetState(lorasendTask));
|
||||
#endif
|
||||
#if (HAS_GPS)
|
||||
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
|
||||
|
@ -65,7 +65,7 @@ void irqHandler(void *pvParameters) {
|
||||
|
||||
// is time to send the payload?
|
||||
if (InterruptStatus & SENDCYCLE_IRQ)
|
||||
sendCounter();
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ esp_err_t lora_stack_init() {
|
||||
// start lmic send task
|
||||
xTaskCreatePinnedToCore(lora_send, // task function
|
||||
"lorasendtask", // name of task
|
||||
2048, // stack size of task
|
||||
3072, // stack size of task
|
||||
(void *)1, // parameter of the task
|
||||
1, // priority of the task
|
||||
&lorasendTask, // task handle
|
||||
|
14
src/main.cpp
14
src/main.cpp
@ -174,6 +174,13 @@ void setup() {
|
||||
// read (and initialize on first run) runtime settings from NVRAM
|
||||
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
|
||||
assert(psramFound());
|
||||
ESP_LOGI(TAG, "PSRAM found and initialized");
|
||||
@ -305,13 +312,6 @@ void setup() {
|
||||
strcat_P(features, " FILTER");
|
||||
#endif
|
||||
|
||||
// initialize display
|
||||
#ifdef HAS_DISPLAY
|
||||
strcat_P(features, " OLED");
|
||||
DisplayIsOn = cfg.screenon;
|
||||
init_display(PRODUCTNAME, PROGVERSION); // note: blocking call
|
||||
#endif
|
||||
|
||||
// initialize matrix display
|
||||
#ifdef HAS_MATRIX_DISPLAY
|
||||
strcat_P(features, " LED_MATRIX");
|
||||
|
@ -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[]) {
|
||||
ESP_LOGI(TAG, "Remote command: set payload mask to %X", val[0]);
|
||||
cfg.payloadmask = val[0];
|
||||
@ -288,6 +298,17 @@ void get_bme(uint8_t val[]) {
|
||||
#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[]) {
|
||||
ESP_LOGI(TAG, "Remote command: get time");
|
||||
payload.reset();
|
||||
@ -322,8 +343,9 @@ cmd_t table[] = {
|
||||
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
|
||||
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, 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},
|
||||
{0x15, set_bme, 1, true}, {0x16, set_batt, 1, true},
|
||||
{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},
|
||||
{0x87, set_time, 0, false}, {0x99, set_flush, 0, false}};
|
||||
|
||||
|
@ -53,7 +53,7 @@ void SendPayload(uint8_t port, sendprio_t prio) {
|
||||
} // SendPayload
|
||||
|
||||
// interrupt triggered function to prepare payload to send
|
||||
void sendCounter() {
|
||||
void sendData() {
|
||||
|
||||
uint8_t bitmask = cfg.payloadmask;
|
||||
uint8_t mask = 1;
|
||||
@ -130,7 +130,7 @@ void sendCounter() {
|
||||
mask <<= 1;
|
||||
} // while (bitmask)
|
||||
|
||||
} // sendCounter()
|
||||
} // sendData()
|
||||
|
||||
void flushQueues() {
|
||||
#if (HAS_LORA)
|
||||
|
@ -106,7 +106,7 @@ void process_timesync_req(void *taskparameter) {
|
||||
payload.addByte(0x99);
|
||||
SendPayload(RCMDPORT, prio_high);
|
||||
// ...send a alive open a receive window for last time_sync_answer
|
||||
// LMIC_sendAlive();
|
||||
LMIC_sendAlive();
|
||||
}
|
||||
} // end of for loop to collect timestamp samples
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user