[SYS] Add Blufi support (#1913)

* First build with IDF, tested with esp32dev-ble only.

* Fix frameworks for non-esp32 boards

* Add blufi support.

* Adds an environment to use esp-idf and Arduino as a component to facilitate incorporating blufi for onboarding and configuration.

---------

Co-authored-by: h2zero <powellperalata@gmail.com>
This commit is contained in:
h2zeroandh2zero authored and GitHub committed 2024-03-15 07:53:13 -05:00
1 parent e55431ad94
commit ffe88feddc
14 files changed
+760 -9

No files matched your search

+2
View File
@@ -81,6 +81,7 @@ jobs:
- "esp32c3-m5stamp"
- "thingpulse-espgateway"
- "theengs-bridge"
- "esp32dev-ble-idf"
runs-on: ubuntu-latest
name: Build with PlatformIO
steps:
@@ -93,6 +94,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install platformio
pip install setuptools
- name: Extract ESP32 platform version from platformio.ini
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
+4
View File
@@ -7,3 +7,7 @@ node_modules
main/certs/private*
lib/*
!lib/esp32-bt-lib
CMakeLists.txt
dependencies.lock
sdkconfig.*
!sdkconfig.defaults
+19
View File
@@ -1810,3 +1810,22 @@ build_flags =
; '-DsimplePublishing=true'
custom_description = BLE Gateway using ethernet or wifi with external antenna
custom_hardware = ThingPulse gateway single ESP32
[env:esp32dev-ble-idf]
platform = ${com.esp32_platform}
framework = arduino, espidf
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = partitions/min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.ble}
${libraries.decoder}
build_flags =
${com-esp32.build_flags}
'-DZgatewayBT="BT"'
'-DLED_SEND_RECEIVE=2'
'-DLED_SEND_RECEIVE_ON=0'
'-DGateway_Name="OMG_ESP32_BLE"'
'-DUSE_BLUFI=1'
custom_description = Regular BLE gateway with adaptive scanning activated, automatically adapts the scan parameters depending on your devices
+265
View File
@@ -0,0 +1,265 @@
/*
OpenMQTTGateway - ESP8266 or Arduino program for home automation
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
Send and receiving command by MQTT
This program enables to:
- receive MQTT data from a topic and send signal (RF, IR, BLE, GSM) corresponding to the received MQTT data
- publish MQTT data to a different topic related to received signals (RF, IR, BLE, GSM)
Copyright: (c)Florian ROBERT
This file is part of OpenMQTTGateway.
OpenMQTTGateway is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenMQTTGateway is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(ESP32) && defined(USE_BLUFI)
# include "esp_blufi_api.h"
extern "C" {
# include "esp_blufi.h"
}
/* store the station info for send back to phone */
//static bool gl_sta_connected = false;
bool omg_blufi_ble_connected = false;
static uint8_t gl_sta_bssid[6];
static uint8_t gl_sta_ssid[32];
static uint8_t gl_sta_passwd[64];
static int gl_sta_ssid_len;
static bool gl_sta_is_connecting = false;
static esp_blufi_extra_info_t gl_sta_conn_info;
static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t* param);
void wifi_event_handler(arduino_event_id_t event);
esp_err_t blufi_security_init(void);
void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_data, int* output_len, bool* need_free);
int blufi_aes_encrypt(uint8_t iv8, uint8_t* crypt_data, int crypt_len);
int blufi_aes_decrypt(uint8_t iv8, uint8_t* crypt_data, int crypt_len);
uint16_t blufi_crc_checksum(uint8_t iv8, uint8_t* data, int len);
void blufi_security_deinit(void);
static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t* param) {
/* actually, should post to blufi_task handle the procedure,
* now, as a example, we do it more simply */
switch (event) {
case ESP_BLUFI_EVENT_INIT_FINISH:
Log.notice(F("BLUFI init finish" CR));
esp_blufi_adv_start();
break;
case ESP_BLUFI_EVENT_DEINIT_FINISH:
Log.notice(F("BLUFI deinit finish" CR));
NimBLEDevice::deinit(true);
break;
case ESP_BLUFI_EVENT_BLE_CONNECT:
omg_blufi_ble_connected = true;
esp_blufi_adv_stop();
blufi_security_init();
break;
case ESP_BLUFI_EVENT_BLE_DISCONNECT:
omg_blufi_ble_connected = false;
blufi_security_deinit();
if (WiFi.isConnected()) {
esp_blufi_deinit();
} else {
esp_blufi_adv_start();
}
break;
case ESP_BLUFI_EVENT_REQ_CONNECT_TO_AP:
Log.notice(F("BLUFI requset wifi connect to AP" CR));
WiFi.begin((char*)gl_sta_ssid, (char*)gl_sta_passwd);
gl_sta_is_connecting = true;
break;
case ESP_BLUFI_EVENT_REQ_DISCONNECT_FROM_AP:
Log.notice(F("BLUFI requset wifi disconnect from AP\n" CR));
WiFi.disconnect();
break;
case ESP_BLUFI_EVENT_REPORT_ERROR:
Log.notice(F("BLUFI report error, error code %d\n" CR), param->report_error.state);
esp_blufi_send_error_info(param->report_error.state);
break;
case ESP_BLUFI_EVENT_GET_WIFI_STATUS: {
esp_blufi_extra_info_t info;
if (WiFi.isConnected()) {
memset(&info, 0, sizeof(esp_blufi_extra_info_t));
memcpy(info.sta_bssid, gl_sta_bssid, 6);
info.sta_bssid_set = true;
info.sta_ssid = gl_sta_ssid;
info.sta_ssid_len = gl_sta_ssid_len;
esp_blufi_send_wifi_conn_report(WIFI_MODE_STA, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info);
} else if (gl_sta_is_connecting) {
esp_blufi_send_wifi_conn_report(WIFI_MODE_STA, ESP_BLUFI_STA_CONNECTING, 0, &gl_sta_conn_info);
} else {
esp_blufi_send_wifi_conn_report(WIFI_MODE_STA, ESP_BLUFI_STA_CONN_FAIL, 0, &gl_sta_conn_info);
}
break;
}
case ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE:
esp_blufi_disconnect();
break;
case ESP_BLUFI_EVENT_RECV_STA_SSID:
strncpy((char*)gl_sta_ssid, (char*)param->sta_ssid.ssid, param->sta_ssid.ssid_len);
gl_sta_ssid[param->sta_ssid.ssid_len] = '\0';
Log.notice(F("Recv STA SSID %s" CR), gl_sta_ssid);
break;
case ESP_BLUFI_EVENT_RECV_STA_PASSWD:
strncpy((char*)gl_sta_passwd, (char*)param->sta_passwd.passwd, param->sta_passwd.passwd_len);
gl_sta_passwd[param->sta_passwd.passwd_len] = '\0';
Log.notice(F("Recv STA PASSWORD %s" CR), gl_sta_passwd);
break;
case ESP_BLUFI_EVENT_GET_WIFI_LIST: {
WiFi.scanNetworks(true);
break;
}
case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA: {
Log.notice(F("Recv Custom Data %" PRIu32 CR), param->custom_data.data_len);
esp_log_buffer_hex("Custom Data", param->custom_data.data, param->custom_data.data_len);
DynamicJsonDocument json(1024);
auto error = deserializeJson(json, param->custom_data.data);
if (error) {
Log.error(F("deserialize config failed: %s, buffer capacity: %u" CR), error.c_str(), json.capacity());
break;
}
if (!json.isNull()) {
Log.trace(F("\nparsed json, size: %u" CR), json.memoryUsage());
if (json.containsKey("mqtt_server"))
strcpy(mqtt_server, json["mqtt_server"]);
if (json.containsKey("mqtt_port"))
strcpy(mqtt_port, json["mqtt_port"]);
if (json.containsKey("mqtt_user"))
strcpy(mqtt_user, json["mqtt_user"]);
if (json.containsKey("mqtt_pass"))
strcpy(mqtt_pass, json["mqtt_pass"]);
if (json.containsKey("mqtt_topic"))
strcpy(mqtt_topic, json["mqtt_topic"]);
if (json.containsKey("mqtt_broker_secure"))
mqtt_secure = json["mqtt_broker_secure"].as<bool>();
if (json.containsKey("gateway_name"))
strcpy(gateway_name, json["gateway_name"]);
saveConfig();
}
break;
}
case ESP_BLUFI_EVENT_RECV_USERNAME:
break;
case ESP_BLUFI_EVENT_RECV_CA_CERT:
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_CERT:
break;
case ESP_BLUFI_EVENT_RECV_SERVER_CERT:
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY:
break;
;
case ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY:
break;
default:
break;
}
}
void wifi_event_handler(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
case ARDUINO_EVENT_WIFI_STA_GOT_IP: {
gl_sta_is_connecting = false;
esp_blufi_extra_info_t info;
memset(&info, 0, sizeof(esp_blufi_extra_info_t));
memcpy(info.sta_bssid, gl_sta_bssid, 6);
info.sta_bssid_set = true;
info.sta_ssid = gl_sta_ssid;
info.sta_ssid_len = gl_sta_ssid_len;
if (omg_blufi_ble_connected == true) {
esp_blufi_send_wifi_conn_report(WIFI_MODE_STA, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info);
}
break;
}
case ARDUINO_EVENT_WIFI_SCAN_DONE: {
uint16_t apCount = WiFi.scanComplete();
if (apCount == 0) {
Log.notice(F("No AP found" CR));
break;
}
wifi_ap_record_t* ap_list = (wifi_ap_record_t*)malloc(sizeof(wifi_ap_record_t) * apCount);
if (!ap_list) {
Log.error(F("malloc error, ap_list is NULL"));
break;
}
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list));
esp_blufi_ap_record_t* blufi_ap_list = (esp_blufi_ap_record_t*)malloc(apCount * sizeof(esp_blufi_ap_record_t));
if (!blufi_ap_list) {
if (ap_list) {
free(ap_list);
}
Log.error(F("malloc error, blufi_ap_list is NULL" CR));
break;
}
for (int i = 0; i < apCount; ++i) {
blufi_ap_list[i].rssi = ap_list[i].rssi;
memcpy(blufi_ap_list[i].ssid, ap_list[i].ssid, sizeof(ap_list[i].ssid));
}
if (omg_blufi_ble_connected == true) {
esp_blufi_send_wifi_list(apCount, blufi_ap_list);
}
free(ap_list);
free(blufi_ap_list);
break;
}
default:
break;
}
return;
}
static esp_blufi_callbacks_t example_callbacks = {
.event_cb = example_event_callback,
.negotiate_data_handler = blufi_dh_negotiate_data_handler,
.encrypt_func = blufi_aes_encrypt,
.decrypt_func = blufi_aes_decrypt,
.checksum_func = blufi_crc_checksum,
};
bool startBlufi() {
esp_err_t ret = ESP_OK;
WiFi.onEvent(wifi_event_handler);
ret = esp_blufi_register_callbacks(&example_callbacks);
if (ret) {
Log.error(F("%s blufi register failed, error code = %x" CR), __func__, ret);
return false;
}
if (NimBLEDevice::getInitialized()) {
NimBLEDevice::deinit(true);
delay(50);
}
esp_blufi_btc_init();
uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_WIFI_STA);
char advName[20] = {0};
snprintf(advName, sizeof(advName), "OMGBFI_%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
NimBLEDevice::init(advName);
esp_blufi_gatt_svr_init();
ble_gatts_start();
return esp_blufi_profile_init() == ESP_OK;
}
#endif // defined(ESP32) && defined(USE_BLUFI)
+197
View File
@@ -0,0 +1,197 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#if defined(ESP32) && defined(USE_BLUFI)
# include "esp_blufi_api.h"
# include "esp_crc.h"
# include "mbedtls/aes.h"
# include "mbedtls/dhm.h"
# include "mbedtls/md5.h"
/*
The SEC_TYPE_xxx is for self-defined packet data type in the procedure of "BLUFI negotiate key"
If user use other negotiation procedure to exchange(or generate) key, should redefine the type by yourself.
*/
# define SEC_TYPE_DH_PARAM_LEN 0x00
# define SEC_TYPE_DH_PARAM_DATA 0x01
# define SEC_TYPE_DH_P 0x02
# define SEC_TYPE_DH_G 0x03
# define SEC_TYPE_DH_PUBLIC 0x04
struct blufi_security {
# define DH_SELF_PUB_KEY_LEN 128
# define DH_SELF_PUB_KEY_BIT_LEN (DH_SELF_PUB_KEY_LEN * 8)
uint8_t self_public_key[DH_SELF_PUB_KEY_LEN];
# define SHARE_KEY_LEN 128
# define SHARE_KEY_BIT_LEN (SHARE_KEY_LEN * 8)
uint8_t share_key[SHARE_KEY_LEN];
size_t share_len;
# define PSK_LEN 16
uint8_t psk[PSK_LEN];
uint8_t* dh_param;
int dh_param_len;
uint8_t iv[16];
mbedtls_dhm_context dhm;
mbedtls_aes_context aes;
};
static struct blufi_security* blufi_sec;
static int myrand(void* rng_state, unsigned char* output, size_t len) {
esp_fill_random(output, len);
return (0);
}
extern "C" void btc_blufi_report_error(esp_blufi_error_state_t state);
void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_data, int* output_len, bool* need_free) {
int ret;
uint8_t type = data[0];
if (blufi_sec == NULL) {
Log.error(F("BLUFI Security is not initialized" CR));
btc_blufi_report_error(ESP_BLUFI_INIT_SECURITY_ERROR);
return;
}
switch (type) {
case SEC_TYPE_DH_PARAM_LEN:
blufi_sec->dh_param_len = ((data[1] << 8) | data[2]);
if (blufi_sec->dh_param) {
free(blufi_sec->dh_param);
blufi_sec->dh_param = NULL;
}
blufi_sec->dh_param = (uint8_t*)malloc(blufi_sec->dh_param_len);
if (blufi_sec->dh_param == NULL) {
btc_blufi_report_error(ESP_BLUFI_DH_MALLOC_ERROR);
Log.error(F("%s, malloc failed\n" CR), __func__);
return;
}
break;
case SEC_TYPE_DH_PARAM_DATA: {
if (blufi_sec->dh_param == NULL) {
Log.error(F("%s, blufi_sec->dh_param == NULL" CR), __func__);
btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR);
return;
}
uint8_t* param = blufi_sec->dh_param;
memcpy(blufi_sec->dh_param, &data[1], blufi_sec->dh_param_len);
ret = mbedtls_dhm_read_params(&blufi_sec->dhm, &param, &param[blufi_sec->dh_param_len]);
if (ret) {
Log.error(F("%s read param failed %d" CR), __func__, ret);
btc_blufi_report_error(ESP_BLUFI_READ_PARAM_ERROR);
return;
}
free(blufi_sec->dh_param);
blufi_sec->dh_param = NULL;
ret = mbedtls_dhm_make_public(&blufi_sec->dhm, (int)mbedtls_mpi_size(&blufi_sec->dhm.P), blufi_sec->self_public_key, blufi_sec->dhm.len, myrand, NULL);
if (ret) {
Log.error(F("%s make public failed %d" CR), __func__, ret);
btc_blufi_report_error(ESP_BLUFI_MAKE_PUBLIC_ERROR);
return;
}
ret = mbedtls_dhm_calc_secret(&blufi_sec->dhm,
blufi_sec->share_key,
SHARE_KEY_BIT_LEN,
&blufi_sec->share_len,
myrand, NULL);
if (ret) {
Log.error(F("%s mbedtls_dhm_calc_secret failed %d" CR), __func__, ret);
btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR);
return;
}
mbedtls_md5(blufi_sec->share_key, blufi_sec->share_len, blufi_sec->psk);
mbedtls_aes_setkey_enc(&blufi_sec->aes, blufi_sec->psk, 128);
/* alloc output data */
*output_data = &blufi_sec->self_public_key[0];
*output_len = blufi_sec->dhm.len;
*need_free = false;
} break;
case SEC_TYPE_DH_P:
break;
case SEC_TYPE_DH_G:
break;
case SEC_TYPE_DH_PUBLIC:
break;
}
}
int blufi_aes_encrypt(uint8_t iv8, uint8_t* crypt_data, int crypt_len) {
int ret;
size_t iv_offset = 0;
uint8_t iv0[16];
memcpy(iv0, blufi_sec->iv, sizeof(blufi_sec->iv));
iv0[0] = iv8; /* set iv8 as the iv0[0] */
ret = mbedtls_aes_crypt_cfb128(&blufi_sec->aes, MBEDTLS_AES_ENCRYPT, crypt_len, &iv_offset, iv0, crypt_data, crypt_data);
if (ret) {
return -1;
}
return crypt_len;
}
int blufi_aes_decrypt(uint8_t iv8, uint8_t* crypt_data, int crypt_len) {
int ret;
size_t iv_offset = 0;
uint8_t iv0[16];
memcpy(iv0, blufi_sec->iv, sizeof(blufi_sec->iv));
iv0[0] = iv8; /* set iv8 as the iv0[0] */
ret = mbedtls_aes_crypt_cfb128(&blufi_sec->aes, MBEDTLS_AES_DECRYPT, crypt_len, &iv_offset, iv0, crypt_data, crypt_data);
if (ret) {
return -1;
}
return crypt_len;
}
uint16_t blufi_crc_checksum(uint8_t iv8, uint8_t* data, int len) {
/* This iv8 ignore, not used */
return esp_crc16_be(0, data, len);
}
esp_err_t blufi_security_init(void) {
blufi_sec = (struct blufi_security*)malloc(sizeof(struct blufi_security));
if (blufi_sec == NULL) {
return ESP_FAIL;
}
memset(blufi_sec, 0x0, sizeof(struct blufi_security));
mbedtls_dhm_init(&blufi_sec->dhm);
mbedtls_aes_init(&blufi_sec->aes);
memset(blufi_sec->iv, 0x0, 16);
return 0;
}
void blufi_security_deinit(void) {
if (blufi_sec == NULL) {
return;
}
if (blufi_sec->dh_param) {
free(blufi_sec->dh_param);
blufi_sec->dh_param = NULL;
}
mbedtls_dhm_free(&blufi_sec->dhm);
mbedtls_aes_free(&blufi_sec->aes);
memset(blufi_sec, 0x0, sizeof(struct blufi_security));
free(blufi_sec);
blufi_sec = NULL;
}
#endif // defined(ESP32) && defined(USE_BLUFI)
+4 -1
View File
@@ -43,7 +43,6 @@ QueueHandle_t BLEQueue;
# include <decoder.h>
# include <driver/adc.h>
# include <esp_bt.h>
# include <esp_bt_main.h>
# include <esp_wifi.h>
# include <atomic>
@@ -892,7 +891,11 @@ void setupBTTasksAndBLE() {
xTaskCreatePinnedToCore(
procBLETask, /* Function to implement the task */
"procBLETask", /* Name of the task */
# ifdef USE_BLUFI
13000,
# else
8500, /* Stack size in bytes */
# endif
NULL, /* Task input parameter */
2, /* Priority of the task (set higher than core task) */
&xProcBLETaskHandle, /* Task handle. */
+1 -1
View File
@@ -76,7 +76,7 @@ void MeasureGPIOInput() {
}
# endif
Log.notice(F("Erasing ESP Config, restarting" CR));
setup_wifimanager(true);
setupwifi(true);
}
} else {
resetTime = 0;
+20 -6
View File
@@ -1133,14 +1133,14 @@ void setup() {
# ifdef ESP32_ETHERNET
setup_ethernet_esp32();
# endif
if (!failSafeMode && !ethConnected) setup_wifimanager(false);
if (!failSafeMode && !ethConnected) setupwifi(false);
} else {
# ifdef ESP32_ETHERNET
setup_ethernet_esp32();
# endif
Log.notice(F("No config in flash, launching wifi manager" CR));
// In failSafeMode we don't want to setup wifi manager as it has already been done before
if (!failSafeMode) setup_wifimanager(false);
if (!failSafeMode) setupwifi(false);
}
# endif
@@ -1362,6 +1362,13 @@ void setup() {
#if defined(ESP8266) || defined(ESP32)
// Bypass for ESP not reconnecting automaticaly the second time https://github.com/espressif/arduino-esp32/issues/2501
bool wifi_reconnect_bypass() {
# if defined(ESP32) && defined(USE_BLUFI)
extern bool omg_blufi_ble_connected;
if (omg_blufi_ble_connected) {
Log.notice(F("BLUFI is connected, bypassing wifi reconnect" CR));
return true;
}
# endif
uint8_t wifi_autoreconnect_cnt = 0;
# ifdef ESP32
while (WiFi.status() != WL_CONNECTED && wifi_autoreconnect_cnt < maxConnectionRetryNetwork) {
@@ -1628,7 +1635,7 @@ void blockingWaitForReset() {
Log.trace(F("mounted file system" CR));
if (SPIFFS.exists("/config.json")) {
Log.notice(F("Erasing ESP Config, restarting" CR));
setup_wifimanager(true);
setupwifi(true);
}
}
delay(30000);
@@ -1636,7 +1643,7 @@ void blockingWaitForReset() {
Log.notice(F("Going into failsafe mode without peripherals" CR));
// Failsafe mode enable to connect to Wifi or change the firmware without the peripherals setup
failSafeMode = true;
setup_wifimanager(false);
setupwifi(false);
}
}
}
@@ -1766,13 +1773,20 @@ bool loadConfigFromFlash() {
return result;
}
void setup_wifimanager(bool reset_settings) {
void setupwifi(bool reset_settings) {
delay(10);
WiFi.mode(WIFI_STA);
if (reset_settings)
eraseAndRestart();
# if defined(ESP32) && defined(USE_BLUFI)
if (!wifi_reconnect_bypass()) {
startBlufi();
return;
}
# endif
# ifdef USE_MAC_AS_GATEWAY_NAME
String s = WiFi.macAddress();
snprintf(WifiManager_ssid, MAC_NAME_MAX_LEN, "%s_%.2s%.2s", Gateway_Short_Name, s.c_str(), s.c_str() + 3);
@@ -2881,7 +2895,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
ESPRestart(5);
} else if (strstr(cmd, eraseCmd) != NULL) { //erase and restart
# ifndef ESPWifiManualSetup
setup_wifimanager(true);
setupwifi(true);
# endif
} else if (strstr(cmd, statusCmd) != NULL) { //erase and restart
stateMeasures();
+7
View File
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
spiffs, data, spiffs, 0x290000,0x160000,
coredump, data, coredump,0x3F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x140000
5 app1 app ota_1 0x150000 0x140000
6 spiffs data spiffs 0x290000 0x160000
7 coredump data coredump 0x3F0000 0x10000
+7
View File
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x640000,
app1, app, ota_1, 0x650000,0x640000,
spiffs, data, spiffs, 0xc90000,0x360000,
coredump, data, coredump,0xFF0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x640000
5 app1 app ota_1 0x650000 0x640000
6 spiffs data spiffs 0xc90000 0x360000
7 coredump data coredump 0xFF0000 0x10000
+7
View File
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x330000,
app1, app, ota_1, 0x340000,0x330000,
spiffs, data, spiffs, 0x670000,0x180000,
coredump, data, coredump,0x7F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x330000
5 app1 app ota_1 0x340000 0x330000
6 spiffs data spiffs 0x670000 0x180000
7 coredump data coredump 0x7F0000 0x10000
+7
View File
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1E0000,
app1, app, ota_1, 0x1F0000,0x1E0000,
spiffs, data, spiffs, 0x3D0000,0x20000,
coredump, data, coredump,0x3F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x1E0000
5 app1 app ota_1 0x1F0000 0x1E0000
6 spiffs data spiffs 0x3D0000 0x20000
7 coredump data coredump 0x3F0000 0x10000
+2 -1
View File
@@ -103,6 +103,7 @@ extra_configs =
;default_envs = lolin_c3_mini
;default_envs = thingpulse-espgateway
;default_envs = theengs-bridge
;default_envs = esp32dev-ble-idf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ENVIRONMENTS PARAMETERS ;
@@ -220,4 +221,4 @@ lib_deps =
${libraries.ethernet}
build_flags =
${env.build_flags}
'-DsimpleReceiving=false'
'-DsimpleReceiving=false'
+218
View File
@@ -0,0 +1,218 @@
CONFIG_FREERTOS_HZ=1000
CONFIG_COAP_MBEDTLS_PSK=y
#
# Bluetooth
#
CONFIG_BT_ENABLED=y
#
# Bluetooth controller
#
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set
# CONFIG_BTDM_CTRL_MODE_BTDM is not set
CONFIG_BTDM_CTRL_BLE_MAX_CONN=3
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0
CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0
CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0
CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0
CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y
# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set
CONFIG_BTDM_CTRL_PINNED_TO_CORE=0
CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set
#
# MODEM SLEEP Options
#
CONFIG_BTDM_CTRL_MODEM_SLEEP=y
CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=y
# CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED is not set
CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=y
# end of MODEM SLEEP Options
CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y
CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1
CONFIG_BTDM_BLE_SCAN_DUPL=y
CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y
# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set
# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set
CONFIG_BTDM_SCAN_DUPL_TYPE=0
CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=100
# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set
CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y
CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y
CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100
CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20
CONFIG_BTDM_RESERVE_DRAM=0xdb5c
CONFIG_BTDM_CTRL_HLI=y
# end of Bluetooth controller
# CONFIG_BT_BLUEDROID_ENABLED is not set
CONFIG_BT_NIMBLE_ENABLED=y
# CONFIG_BT_CONTROLLER_ONLY is not set
#
# NimBLE Options
#
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y
# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set
CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y
# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set
CONFIG_BT_NIMBLE_LOG_LEVEL=1
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3
CONFIG_BT_NIMBLE_MAX_BONDS=3
CONFIG_BT_NIMBLE_MAX_CCCDS=8
CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0
CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y
# CONFIG_BT_NIMBLE_PINNED_TO_CORE_1 is not set
CONFIG_BT_NIMBLE_PINNED_TO_CORE=0
CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096
CONFIG_BT_NIMBLE_ROLE_CENTRAL=y
CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y
CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y
CONFIG_BT_NIMBLE_ROLE_OBSERVER=y
CONFIG_BT_NIMBLE_NVS_PERSIST=y
CONFIG_BT_NIMBLE_SM_LEGACY=y
CONFIG_BT_NIMBLE_SM_SC=y
# CONFIG_BT_NIMBLE_DEBUG is not set
# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set
CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble"
CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31
CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256
CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0
CONFIG_BT_NIMBLE_ACL_BUF_COUNT=20
CONFIG_BT_NIMBLE_ACL_BUF_SIZE=255
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT=30
CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT=8
CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT=12
CONFIG_BT_NIMBLE_HS_FLOW_CTRL=y
CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL=1000
CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH=2
CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT=y
CONFIG_BT_NIMBLE_RPA_TIMEOUT=900
# CONFIG_BT_NIMBLE_MESH is not set
CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y
CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000
# CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT is not set
CONFIG_BT_NIMBLE_BLUFI_ENABLE=y
CONFIG_BT_NIMBLE_USE_ESP_TIMER=y
# end of NimBLE Options
# end of Bluetooth
#
# TLS Key Exchange Methods
#
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y
# end of TLS Key Exchange Methods
#
# Arduino Configuration
#
CONFIG_ARDUINO_VARIANT="esp32"
CONFIG_ENABLE_ARDUINO_DEPENDS=y
CONFIG_AUTOSTART_ARDUINO=y
# CONFIG_ARDUINO_RUN_CORE0 is not set
CONFIG_ARDUINO_RUN_CORE1=y
# CONFIG_ARDUINO_RUN_NO_AFFINITY is not set
CONFIG_ARDUINO_RUNNING_CORE=1
CONFIG_ARDUINO_LOOP_STACK_SIZE=8192
# CONFIG_ARDUINO_EVENT_RUN_CORE0 is not set
CONFIG_ARDUINO_EVENT_RUN_CORE1=y
# CONFIG_ARDUINO_EVENT_RUN_NO_AFFINITY is not set
CONFIG_ARDUINO_EVENT_RUNNING_CORE=1
# CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE0 is not set
# CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE1 is not set
CONFIG_ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY=y
CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE=-1
CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE=2048
CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY=24
CONFIG_ARDUINO_UDP_RUN_CORE0=y
# CONFIG_ARDUINO_UDP_RUN_CORE1 is not set
# CONFIG_ARDUINO_UDP_RUN_NO_AFFINITY is not set
CONFIG_ARDUINO_UDP_RUNNING_CORE=0
CONFIG_ARDUINO_UDP_TASK_PRIORITY=3
# CONFIG_ARDUINO_ISR_IRAM is not set
# CONFIG_DISABLE_HAL_LOCKS is not set
#
# Debug Log Configuration
#
# CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE is not set
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR=y
# CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_WARN is not set
# CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO is not set
# CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG is not set
# CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE is not set
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1
# CONFIG_ARDUHAL_LOG_COLORS is not set
# CONFIG_ARDUHAL_ESP_LOG is not set
# end of Debug Log Configuration
# CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT is not set
# CONFIG_ARDUHAL_PARTITION_SCHEME_MINIMAL is not set
# CONFIG_ARDUHAL_PARTITION_SCHEME_NO_OTA is not set
# CONFIG_ARDUHAL_PARTITION_SCHEME_HUGE_APP is not set
CONFIG_ARDUHAL_PARTITION_SCHEME_MIN_SPIFFS=y
CONFIG_ARDUHAL_PARTITION_SCHEME="min_spiffs"
# CONFIG_AUTOCONNECT_WIFI is not set
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
CONFIG_ARDUINO_SELECTIVE_ArduinoOTA=y
CONFIG_ARDUINO_SELECTIVE_AsyncUDP=y
# CONFIG_ARDUINO_SELECTIVE_AzureIoT is not set
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
CONFIG_ARDUINO_SELECTIVE_DNSServer=y
CONFIG_ARDUINO_SELECTIVE_EEPROM=y
CONFIG_ARDUINO_SELECTIVE_ESP32=y
CONFIG_ARDUINO_SELECTIVE_ESPmDNS=y
CONFIG_ARDUINO_SELECTIVE_FFat=y
CONFIG_ARDUINO_SELECTIVE_FS=y
CONFIG_ARDUINO_SELECTIVE_HTTPClient=y
CONFIG_ARDUINO_SELECTIVE_LITTLEFS=y
CONFIG_ARDUINO_SELECTIVE_NetBIOS=y
CONFIG_ARDUINO_SELECTIVE_Preferences=y
CONFIG_ARDUINO_SELECTIVE_SD=y
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
CONFIG_ARDUINO_SELECTIVE_SPI=y
CONFIG_ARDUINO_SELECTIVE_SPIFFS=y
CONFIG_ARDUINO_SELECTIVE_Ticker=y
CONFIG_ARDUINO_SELECTIVE_Update=y
CONFIG_ARDUINO_SELECTIVE_WebServer=y
CONFIG_ARDUINO_SELECTIVE_WiFi=y
CONFIG_ARDUINO_SELECTIVE_WiFiClientSecure=y
CONFIG_ARDUINO_SELECTIVE_WiFiProv=y
CONFIG_ARDUINO_SELECTIVE_Wire=y
# end of Arduino Configuration
# CONFIG_ESP32_WIFI_IRAM_OPT is not set
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
#
# SPI configuration
#
# CONFIG_SPI_MASTER_IN_IRAM is not set
# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set
# CONFIG_SPI_SLAVE_IN_IRAM is not set
# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set
# end of SPI configuration