Merge pull request #67 from cyberman54/development

v1.3.71
This commit is contained in:
Verkehrsrot 2018-06-04 08:28:07 +02:00 committed by GitHub
commit 85b4a942a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 144 additions and 58 deletions

View File

@ -23,14 +23,14 @@ Supported ESP32 based LoRa IoT boards:
- Heltec LoRa-32 {1} - Heltec LoRa-32 {1}
- TTGOv1 {1} - TTGOv1 {1}
- TTGOv2 {1}{4} - TTGOv2 {1}{4}
- TTGOv2.1 {1} - TTGOv2.1 {1}{5}
- Pycom LoPy {2} - Pycom LoPy {2}
- Pycom LoPy4 {2} - Pycom LoPy4 {2}
- Pycom FiPy {2} - Pycom FiPy {2}
- LoLin32 with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) {2}{3} - LoLin32 with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) {2}{3}
- LoLin32 Lite with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) {2}{3} - LoLin32 Lite with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) {2}{3}
{1} on board OLED Display supported; {2} on board RGB LED supported; {3} on board Hardware unique DEVEUI supported; {4} special wiring needed, see instructions in /hal/ttgov2.h {1} on board OLED Display supported; {2} on board RGB LED supported; {3} on board Hardware unique DEVEUI supported; {4} special wiring needed, see instructions in /hal/ttgov2.h; {5} battery voltage monitoring supported
Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).<br> Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).<br>
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory.<br> Hardware dependent settings (pinout etc.) are stored in board files in /hal directory.<br>
@ -56,7 +56,8 @@ If your device has silicon **Unique ID** which is stored in serial EEPROM Microc
# Building # Building
Use <A HREF="https://platformio.org/">PlatformIO</A> with your preferred IDE for development and building this code. Use <A HREF="https://platformio.org/">PlatformIO</A> with your preferred IDE for development and building this code. Make sure you have latest PlatformIO version, at least
<A HREF="https://community.platformio.org/t/platformio-core-3-5-3/4238?utm_source=platformio&utm_medium=piohome">v3.5.3</A>.
# Uploading # Uploading
@ -219,15 +220,19 @@ device answers with it's current configuration. The configuration is a C structu
byte 13: Wifi antenna switch (0=internal, 1=external) byte 13: Wifi antenna switch (0=internal, 1=external)
byte 14: Vendorfilter mode (0=disabled, 1=enabled) byte 14: Vendorfilter mode (0=disabled, 1=enabled)
byte 15: RGB LED luminosity (0..100 %) byte 15: RGB LED luminosity (0..100 %)
bytes 16-25: Software version (ASCII format) bytes 16-26: Software version (ASCII format, terminating with zero)
0x81 get device uptime 0x81 get device uptime
bytes 1-7: Uptime in seconds (little endian format) bytes 1-8: uptime in seconds (little endian format)
0x82 get device cpu temperature 0x82 get device cpu temperature
bytes 1-3: chip temperature in celsius (little endian format) bytes 1-4: chip temperature in degrees celsius (little endian format)
0x83 get device battery voltage
bytes 1-2: battery voltage in millivolt, 0 if unreadable (little endian format)
# License # License

View File

@ -24,6 +24,9 @@ env_default = heltec
description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around.
[common_env_data] [common_env_data]
platform_espressif32 = espressif32@>=1.0.1
board_build.partitions = no_ota.csv
board_upload.maximum_size = 2097152
lib_deps_display = lib_deps_display =
U8g2@>=2.22.14 U8g2@>=2.22.14
lib_deps_rgbled = lib_deps_rgbled =
@ -43,10 +46,13 @@ build_flags =
-include "src/paxcounter.conf" -include "src/paxcounter.conf"
[env:heltec] [env:heltec]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = heltec_wifi_lora_32 board = heltec_wifi_lora_32
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200
lib_deps = lib_deps =
${common_env_data.lib_deps_display} ${common_env_data.lib_deps_display}
build_flags = build_flags =
@ -54,9 +60,11 @@ build_flags =
-include "src/hal/heltec.h" -include "src/hal/heltec.h"
[env:ttgov1] [env:ttgov1]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200 upload_speed = 115200
lib_deps = lib_deps =
@ -66,9 +74,11 @@ build_flags =
-include "src/hal/ttgov1.h" -include "src/hal/ttgov1.h"
[env:ttgov2] [env:ttgov2]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -78,9 +88,11 @@ build_flags =
-include "src/hal/ttgov2.h" -include "src/hal/ttgov2.h"
[env:ttgov21] [env:ttgov21]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -90,9 +102,11 @@ build_flags =
-include "src/hal/ttgov21.h" -include "src/hal/ttgov21.h"
[env:fipy] [env:fipy]
platform = espressif32@0.12.0 platform = espressif32@1.0.1
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -102,9 +116,11 @@ build_flags =
-include "src/hal/fipy.h" -include "src/hal/fipy.h"
[env:lopy] [env:lopy]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -114,9 +130,11 @@ build_flags =
-include "src/hal/lopy.h" -include "src/hal/lopy.h"
[env:lopy4] [env:lopy4]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -126,9 +144,11 @@ build_flags =
-include "src/hal/lopy4.h" -include "src/hal/lopy4.h"
[env:lolin32lite] [env:lolin32lite]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = lolin32 board = lolin32
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 256000 upload_speed = 256000
lib_deps = lib_deps =
@ -138,9 +158,11 @@ build_flags =
-include "src/hal/lolin32lite_lora.h" -include "src/hal/lolin32lite_lora.h"
[env:lolin32] [env:lolin32]
platform = espressif32@0.12.0 platform = ${common_env_data.platform_espressif32}
framework = arduino framework = arduino
board = lolin32 board = lolin32
board_build.partitions = ${common_env_data.board_build.partitions}
board_upload.maximum_size = ${common_env_data.board_upload.maximum_size}
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =

56
src/adcread.cpp Normal file
View File

@ -0,0 +1,56 @@
#ifdef HAS_BATTERY_PROBE
#include "globals.h"
#include <driver/adc.h>
#include <esp_adc_cal.h>
#define DEFAULT_VREF 1100 // to be done: use adc2_vref_to_gpio() to obtain a better estimate
#define NO_OF_SAMPLES 64 // we do multisampling
// Local logging tag
static const char TAG[] = "main";
static void print_char_val_type(esp_adc_cal_value_t val_type)
{
if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) {
ESP_LOGI(TAG,"ADC characterization based on Two Point values stored in eFuse");
} else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
ESP_LOGI(TAG,"ADC characterization based on reference voltage stored in eFuse");
} else {
ESP_LOGI(TAG,"ADC characterization based on default reference voltage");
}
}
uint16_t read_voltage(void)
{
static const adc1_channel_t channel = HAS_BATTERY_PROBE;
static const adc_atten_t atten = ADC_ATTEN_DB_11;
static const adc_unit_t unit = ADC_UNIT_1;
//configure ADC1
ESP_ERROR_CHECK(adc1_config_width(ADC_WIDTH_BIT_12));
ESP_ERROR_CHECK(adc1_config_channel_atten(channel, atten));
//calibrate ADC1
esp_adc_cal_characteristics_t *adc_chars = (esp_adc_cal_characteristics_t *) calloc(1, sizeof(esp_adc_cal_characteristics_t));
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF, adc_chars);
print_char_val_type(val_type);
//multisample ADC1
uint32_t adc_reading = 0;
for (int i = 0; i < NO_OF_SAMPLES; i++) {
adc_reading += adc1_get_raw(channel);
}
adc_reading /= NO_OF_SAMPLES;
//Convert adc_reading to voltage in mV
uint16_t voltage = (uint16_t) esp_adc_cal_raw_to_voltage(adc_reading, adc_chars);
#ifdef BATT_FACTOR
voltage *= BATT_FACTOR;
#endif
ESP_LOGI(TAG,"Raw: %d / Voltage: %dmV", adc_reading, voltage);
return voltage;
}
#endif // HAS_BATTERY_PROBE

View File

@ -5,7 +5,7 @@
#include <Arduino.h> #include <Arduino.h>
// Local logging tag // Local logging tag
static const char* TAG = "wifi"; static const char TAG[] = "wifi";
typedef enum { typedef enum {
ANTENNA_INT = 0, ANTENNA_INT = 0,

View File

@ -17,17 +17,12 @@ https://github.com/nkolban/esp32-snippets/tree/master/BLE/scanner
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] #define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
// local Tag for logging // local Tag for logging
static const char* TAG = "bluetooth"; static const char TAG[] = "bluetooth";
// defined in macsniff.cpp // defined in macsniff.cpp
bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type); bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type);
// Prototypes const char *bt_addr_t_to_string(esp_ble_addr_type_t type) {
static const char *bt_addr_t_to_string(esp_ble_addr_type_t type);
static const char *btsig_gap_type(uint32_t gap_type);
static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
static const char *bt_addr_t_to_string(esp_ble_addr_type_t type) {
switch(type) { switch(type) {
case BLE_ADDR_TYPE_PUBLIC: case BLE_ADDR_TYPE_PUBLIC:
return "BLE_ADDR_TYPE_PUBLIC"; return "BLE_ADDR_TYPE_PUBLIC";
@ -42,7 +37,7 @@ static const char *bt_addr_t_to_string(esp_ble_addr_type_t type) {
} }
} // bt_addr_t_to_string } // bt_addr_t_to_string
static const char *btsig_gap_type(uint32_t gap_type) { const char *btsig_gap_type(uint32_t gap_type) {
switch (gap_type) switch (gap_type)
{ {
case 0x01: return "Flags"; case 0x01: return "Flags";
@ -89,7 +84,7 @@ static const char *btsig_gap_type(uint32_t gap_type) {
} // btsig_gap_type } // btsig_gap_type
// using IRAM_:ATTR here to speed up callback function // using IRAM_:ATTR here to speed up callback function
IRAM_ATTR static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{ {
esp_ble_gap_cb_param_t *p = (esp_ble_gap_cb_param_t *)param; esp_ble_gap_cb_param_t *p = (esp_ble_gap_cb_param_t *)param;

View File

@ -5,7 +5,7 @@
#include <nvs_flash.h> #include <nvs_flash.h>
// Local logging tag // Local logging tag
static const char* TAG = "flash"; static const char TAG[] = "flash";
nvs_handle my_handle; nvs_handle my_handle;

View File

@ -5,9 +5,8 @@
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define DISPLAY_FLIP 1 // rotated display #define DISPLAY_FLIP 1 // rotated display
#define HAS_LED 23 // green on board LED_G3 (not in initial board version) #define HAS_LED 23 // green on board LED_G3 (not in initial board version)
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
// disable brownout detection (needed on TTGOv2 for battery powered operation) #define BATT_FACTOR 2 // voltage divider 100k/100k on board
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
// re-define pin definitions of pins_arduino.h // re-define pin definitions of pins_arduino.h
#define PIN_SPI_SS 18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input #define PIN_SPI_SS 18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input

View File

@ -11,7 +11,7 @@
#endif #endif
// Local logging Tag // Local logging Tag
static const char* TAG = "lora"; static const char TAG[] = "lora";
// functions defined in rcommand.cpp // functions defined in rcommand.cpp
void rcommand(uint8_t cmd, uint8_t arg); void rcommand(uint8_t cmd, uint8_t arg);
@ -172,7 +172,7 @@ void onEvent (ev_t ev) {
// Disable link check validation (automatically enabled // Disable link check validation (automatically enabled
// during join, but not supported by TTN at this time). -> do we need this? // during join, but not supported by TTN at this time). -> do we need this?
LMIC_setLinkCheckMode(0); // LMIC_setLinkCheckMode(0);
// set data rate adaptation // set data rate adaptation
LMIC_setAdrMode(cfg.adrmode); LMIC_setAdrMode(cfg.adrmode);

View File

@ -7,7 +7,7 @@
#endif #endif
// Local logging tag // Local logging tag
static const char* TAG = "wifi"; static const char TAG[] = "wifi";
static wifi_country_t wifi_country = {.cc=WIFI_MY_COUNTRY, .schan=WIFI_CHANNEL_MIN, .nchan=WIFI_CHANNEL_MAX, .policy=WIFI_COUNTRY_POLICY_MANUAL}; static wifi_country_t wifi_country = {.cc=WIFI_MY_COUNTRY, .schan=WIFI_CHANNEL_MIN, .nchan=WIFI_CHANNEL_MAX, .policy=WIFI_COUNTRY_POLICY_MANUAL};
@ -90,7 +90,7 @@ void wifi_sniffer_init(void) {
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country)); // set locales for RF and channels ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); // we don't need NVRAM ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); // we don't need NVRAM
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL)); //ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set MAC frame filter ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set MAC frame filter
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler)); ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode

View File

@ -61,7 +61,7 @@ std::set<uint16_t> macs; // associative container holds total of unique MAC adre
static volatile int ButtonPressed = 0, DisplayTimerIRQ = 0, ChannelTimerIRQ = 0; static volatile int ButtonPressed = 0, DisplayTimerIRQ = 0, ChannelTimerIRQ = 0;
// local Tag for logging // local Tag for logging
static const char* TAG = "main"; static const char TAG[] = "main";
#ifndef VERBOSE #ifndef VERBOSE
int redirect_log(const char * fmt, va_list args) { int redirect_log(const char * fmt, va_list args) {
@ -153,7 +153,7 @@ void lorawan_loop(void * pvParameters) {
} }
*/ */
vTaskDelay(10/portTICK_PERIOD_MS); // reset watchdog vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
} }
} }
@ -218,7 +218,7 @@ void sniffer_loop(void * pvParameters) {
wifi_sniffer_set_channel(channel); wifi_sniffer_set_channel(channel);
ESP_LOGD(TAG, "Wifi set channel %d", channel); ESP_LOGD(TAG, "Wifi set channel %d", channel);
vTaskDelay(10/portTICK_PERIOD_MS); // reset watchdog vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
} }
} // end of infinite wifi channel rotation loop } // end of infinite wifi channel rotation loop
@ -627,7 +627,7 @@ void loop() {
reset_salt(); // get new salt for salting hashes reset_salt(); // get new salt for salting hashes
} }
vTaskDelay(10/portTICK_PERIOD_MS); // reset watchdog vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
} // end of infinite main loop } // end of infinite main loop
} }

View File

@ -1,6 +1,6 @@
// program version - note: increment version after modifications to configData_t struct!! // program version - note: increment version after modifications to configData_t struct!!
#define PROGVERSION "1.3.6" // use max 10 chars here! #define PROGVERSION "1.3.71" // use max 10 chars here!
#define PROGNAME "PAXCNT" #define PROGNAME "PAXCNT"
//--- Declarations --- //--- Declarations ---

View File

@ -10,7 +10,7 @@
#include <hal/hal.h> #include <hal/hal.h>
// Local logging tag // Local logging tag
static const char* TAG = "main"; static const char TAG[] = "main";
// table of remote commands and assigned functions // table of remote commands and assigned functions
typedef struct { typedef struct {
@ -24,6 +24,12 @@ typedef struct {
void antenna_select(const uint8_t _ant); void antenna_select(const uint8_t _ant);
#endif #endif
// function defined in adcread.cpp
#ifdef HAS_BATTERY_PROBE
uint32_t read_voltage(void);
#endif
// help function to assign LoRa datarates to numeric spreadfactor values // help function to assign LoRa datarates to numeric spreadfactor values
void switch_lora (uint8_t sf, uint8_t tx) { void switch_lora (uint8_t sf, uint8_t tx) {
if ( tx > 20 ) return; if ( tx > 20 ) return;
@ -205,36 +211,38 @@ void set_noop (uint8_t val) {
void get_config (uint8_t val) { void get_config (uint8_t val) {
ESP_LOGI(TAG, "Remote command: get configuration"); ESP_LOGI(TAG, "Remote command: get configuration");
int size = sizeof(configData_t); int size = sizeof(configData_t);
// declare send buffer (char byte array) LMIC_setTxData2(RCMDPORT, (byte*)&cfg, size, 0); // send data unconfirmed on RCMD Port
unsigned char *sendData = new unsigned char[size]; ESP_LOGI(TAG, "%d bytes queued in send queue", size);
// copy current configuration (struct) to send buffer
memcpy(sendData, &cfg, size);
LMIC_setTxData2(RCMDPORT, sendData, size-1, 0); // send data unconfirmed on RCMD Port
delete sendData; // free memory
ESP_LOGI(TAG, "%d bytes queued in send queue", size-1);
}; };
void get_uptime (uint8_t val) { void get_uptime (uint8_t val) {
ESP_LOGI(TAG, "Remote command: get uptime"); ESP_LOGI(TAG, "Remote command: get uptime");
int size = sizeof(uptimecounter); int size = sizeof(uptimecounter);
unsigned char *sendData = new unsigned char[size]; LMIC_setTxData2(RCMDPORT, (byte*)&uptimecounter, size, 0); // send data unconfirmed on RCMD Port
memcpy(sendData, (unsigned char*)&uptimecounter , size); ESP_LOGI(TAG, "%d bytes queued in send queue", size);
LMIC_setTxData2(RCMDPORT, sendData, size-1, 0); // send data unconfirmed on RCMD Port
delete sendData; // free memory
ESP_LOGI(TAG, "%d bytes queued in send queue", size-1);
}; };
void get_cputemp (uint8_t val) { void get_cputemp (uint8_t val) {
ESP_LOGI(TAG, "Remote command: get cpu temperature"); ESP_LOGI(TAG, "Remote command: get cpu temperature");
float temp = temperatureRead(); float temp = temperatureRead();
int size = sizeof(temp); int size = sizeof(temp);
unsigned char *sendData = new unsigned char[size]; LMIC_setTxData2(RCMDPORT, (byte*)&temp, size, 0); // send data unconfirmed on RCMD Port
memcpy(sendData, (unsigned char*)&temp, size); ESP_LOGI(TAG, "%d bytes queued in send queue", size);
LMIC_setTxData2(RCMDPORT, sendData, size-1, 0); // send data unconfirmed on RCMD Port
delete sendData; // free memory
ESP_LOGI(TAG, "%d bytes queued in send queue", size-1);
}; };
void get_voltage (uint8_t val) {
ESP_LOGI(TAG, "Remote command: get battery voltage");
#ifdef HAS_BATTERY_PROBE
uint16_t voltage = read_voltage();
#else
uint16_t voltage = 0;
#endif
int size = sizeof(voltage);
LMIC_setTxData2(RCMDPORT, (byte*)&voltage, size, 0); // send data unconfirmed on RCMD Port
ESP_LOGI(TAG, "%d bytes queued in send queue", size);
};
// assign previously defined functions to set of numeric remote commands // assign previously defined functions to set of numeric remote commands
// format: opcode, function, flag (1 = do make settings persistent / 0 = don't) // format: opcode, function, flag (1 = do make settings persistent / 0 = don't)
// //
@ -257,7 +265,8 @@ cmd_t table[] = {
{0x10, set_rgblum, true}, {0x10, set_rgblum, true},
{0x80, get_config, false}, {0x80, get_config, false},
{0x81, get_uptime, false}, {0x81, get_uptime, false},
{0x82, get_cputemp, false} {0x82, get_cputemp, false},
{0x83, get_voltage, false}
}; };
// check and execute remote command // check and execute remote command