mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 03:00:56 +00:00
trunk roundhouse kick
This commit is contained in:
@@ -1,43 +1,46 @@
|
||||
#include "Arduino.h"
|
||||
#include "BleOta.h"
|
||||
#include "Arduino.h"
|
||||
#include <esp_ota_ops.h>
|
||||
|
||||
static const String MESHTASTIC_OTA_APP_PROJECT_NAME("Meshtastic-OTA");
|
||||
|
||||
const esp_partition_t* BleOta::findEspOtaAppPartition() {
|
||||
const esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, nullptr);
|
||||
const esp_partition_t *BleOta::findEspOtaAppPartition()
|
||||
{
|
||||
const esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, nullptr);
|
||||
|
||||
esp_app_desc_t app_desc;
|
||||
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
esp_app_desc_t app_desc;
|
||||
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
|
||||
if (ret != ESP_OK || MESHTASTIC_OTA_APP_PROJECT_NAME != app_desc.project_name) {
|
||||
part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, nullptr);
|
||||
ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
}
|
||||
if (ret != ESP_OK || MESHTASTIC_OTA_APP_PROJECT_NAME != app_desc.project_name) {
|
||||
part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, nullptr);
|
||||
ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
}
|
||||
|
||||
if (ret == ESP_OK && MESHTASTIC_OTA_APP_PROJECT_NAME == app_desc.project_name) {
|
||||
return part;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
if (ret == ESP_OK && MESHTASTIC_OTA_APP_PROJECT_NAME == app_desc.project_name) {
|
||||
return part;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
String BleOta::getOtaAppVersion() {
|
||||
const esp_partition_t *part = findEspOtaAppPartition();
|
||||
esp_app_desc_t app_desc;
|
||||
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
String version;
|
||||
if (ret == ESP_OK) {
|
||||
version = app_desc.version;
|
||||
}
|
||||
return version;
|
||||
String BleOta::getOtaAppVersion()
|
||||
{
|
||||
const esp_partition_t *part = findEspOtaAppPartition();
|
||||
esp_app_desc_t app_desc;
|
||||
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||
String version;
|
||||
if (ret == ESP_OK) {
|
||||
version = app_desc.version;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
bool BleOta::switchToOtaApp() {
|
||||
bool success = false;
|
||||
const esp_partition_t *part = findEspOtaAppPartition();
|
||||
if (part) {
|
||||
success = (ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_set_boot_partition(part)) == ESP_OK);
|
||||
}
|
||||
return success;
|
||||
bool BleOta::switchToOtaApp()
|
||||
{
|
||||
bool success = false;
|
||||
const esp_partition_t *part = findEspOtaAppPartition();
|
||||
if (part) {
|
||||
success = (ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_set_boot_partition(part)) == ESP_OK);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -3,9 +3,10 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
class BleOta {
|
||||
class BleOta
|
||||
{
|
||||
public:
|
||||
explicit BleOta() {};
|
||||
explicit BleOta(){};
|
||||
|
||||
static String getOtaAppVersion();
|
||||
static bool switchToOtaApp();
|
||||
@@ -15,4 +16,4 @@ class BleOta {
|
||||
static const esp_partition_t *findEspOtaAppPartition();
|
||||
};
|
||||
|
||||
#endif //BLEOTA_H
|
||||
#endif // BLEOTA_H
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
|
||||
|
||||
class ESP32CryptoEngine : public CryptoEngine
|
||||
{
|
||||
|
||||
@@ -42,7 +40,7 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
if (key.length > 0) {
|
||||
LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t)packetId, numBytes);
|
||||
initNonce(fromNode, packetId);
|
||||
if (numBytes <= MAX_BLOCKSIZE) {
|
||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||
@@ -50,7 +48,7 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
size_t nc_off = 0;
|
||||
memcpy(scratch, bytes, numBytes);
|
||||
memset(scratch + numBytes, 0,
|
||||
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||
|
||||
auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes);
|
||||
assert(!res);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "SimpleAllocator.h"
|
||||
#include "assert.h"
|
||||
#include "configuration.h"
|
||||
#include "SimpleAllocator.h"
|
||||
|
||||
SimpleAllocator::SimpleAllocator() { reset(); }
|
||||
SimpleAllocator::SimpleAllocator()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void *SimpleAllocator::alloc(size_t size)
|
||||
{
|
||||
@@ -14,7 +17,10 @@ void *SimpleAllocator::alloc(size_t size)
|
||||
return res;
|
||||
}
|
||||
|
||||
void SimpleAllocator::reset() { nextFree = 0; }
|
||||
void SimpleAllocator::reset()
|
||||
{
|
||||
nextFree = 0;
|
||||
}
|
||||
|
||||
void *operator new(size_t size, SimpleAllocator &p)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* It will panic if that buffer fills up.
|
||||
* If you are _sure_ no outstanding references to blocks in this buffer still exist, you can call
|
||||
* reset() to start from scratch.
|
||||
*
|
||||
*
|
||||
* Currently the only usecase for this class is the ESP32 bluetooth stack, where once we've called deinit(false)
|
||||
* we are sure all those bluetooth objects no longer exist, and we'll need to recreate them when we restart bluetooth
|
||||
*/
|
||||
@@ -18,14 +18,14 @@ class SimpleAllocator
|
||||
|
||||
uint32_t nextFree = 0;
|
||||
|
||||
public:
|
||||
public:
|
||||
SimpleAllocator();
|
||||
|
||||
void *alloc(size_t size);
|
||||
|
||||
/** If you are _sure_ no outstanding references to blocks in this buffer still exist, you can call
|
||||
* reset() to start from scratch.
|
||||
* */
|
||||
* reset() to start from scratch.
|
||||
* */
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -35,8 +35,9 @@ void *operator new(size_t size, SimpleAllocator &p);
|
||||
* Temporarily makes the specified Allocator be used for _all_ allocations. Useful when calling library routines
|
||||
* that don't know about pools
|
||||
*/
|
||||
class AllocatorScope {
|
||||
public:
|
||||
class AllocatorScope
|
||||
{
|
||||
public:
|
||||
explicit AllocatorScope(SimpleAllocator &a);
|
||||
~AllocatorScope();
|
||||
};
|
||||
|
||||
@@ -7,31 +7,31 @@
|
||||
//
|
||||
|
||||
#ifndef HAS_BLUETOOTH
|
||||
#define HAS_BLUETOOTH 1
|
||||
#define HAS_BLUETOOTH 1
|
||||
#endif
|
||||
#ifndef HAS_WIFI
|
||||
#define HAS_WIFI 1
|
||||
#define HAS_WIFI 1
|
||||
#endif
|
||||
#ifndef HAS_SCREEN
|
||||
#define HAS_SCREEN 1
|
||||
#define HAS_SCREEN 1
|
||||
#endif
|
||||
#ifndef HAS_WIRE
|
||||
#define HAS_WIRE 1
|
||||
#define HAS_WIRE 1
|
||||
#endif
|
||||
#ifndef HAS_GPS
|
||||
#define HAS_GPS 1
|
||||
#define HAS_GPS 1
|
||||
#endif
|
||||
#ifndef HAS_BUTTON
|
||||
#define HAS_BUTTON 1
|
||||
#define HAS_BUTTON 1
|
||||
#endif
|
||||
#ifndef HAS_TELEMETRY
|
||||
#define HAS_TELEMETRY 1
|
||||
#define HAS_TELEMETRY 1
|
||||
#endif
|
||||
#ifndef HAS_RADIO
|
||||
#define HAS_RADIO 1
|
||||
#define HAS_RADIO 1
|
||||
#endif
|
||||
#ifndef HAS_RTC
|
||||
#define HAS_RTC 1
|
||||
#define HAS_RTC 1
|
||||
#endif
|
||||
|
||||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
@@ -44,52 +44,52 @@
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
|
||||
#if defined(TBEAM_V10)
|
||||
#define HW_VENDOR HardwareModel_TBEAM
|
||||
#define HW_VENDOR HardwareModel_TBEAM
|
||||
#elif defined(TBEAM_V07)
|
||||
#define HW_VENDOR HardwareModel_TBEAM_V0P7
|
||||
#define HW_VENDOR HardwareModel_TBEAM_V0P7
|
||||
#elif defined(LILYGO_TBEAM_S3_CORE)
|
||||
#define HW_VENDOR HardwareModel_LILYGO_TBEAM_S3_CORE
|
||||
#define HW_VENDOR HardwareModel_LILYGO_TBEAM_S3_CORE
|
||||
#elif defined(DIY_V1)
|
||||
#define HW_VENDOR HardwareModel_DIY_V1
|
||||
#define HW_VENDOR HardwareModel_DIY_V1
|
||||
#elif defined(RAK_11200)
|
||||
#define HW_VENDOR HardwareModel_RAK11200
|
||||
#define HW_VENDOR HardwareModel_RAK11200
|
||||
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
||||
#ifdef HELTEC_V2_0
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
||||
#endif
|
||||
#ifdef HELTEC_V2_1
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
||||
#endif
|
||||
#ifdef HELTEC_V2_0
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
||||
#endif
|
||||
#ifdef HELTEC_V2_1
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
||||
#endif
|
||||
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V1
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V1
|
||||
#elif defined(TLORA_V1)
|
||||
#define HW_VENDOR HardwareModel_TLORA_V1
|
||||
#define HW_VENDOR HardwareModel_TLORA_V1
|
||||
#elif defined(TLORA_V2)
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2
|
||||
#elif defined(TLORA_V1_3)
|
||||
#define HW_VENDOR HardwareModel_TLORA_V1_1P3
|
||||
#define HW_VENDOR HardwareModel_TLORA_V1_1P3
|
||||
#elif defined(TLORA_V2_1_16)
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2_1_1P6
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2_1_1P6
|
||||
#elif defined(TLORA_V2_1_18)
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2_1_1P8
|
||||
#define HW_VENDOR HardwareModel_TLORA_V2_1_1P8
|
||||
#elif defined(GENIEBLOCKS)
|
||||
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
||||
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
||||
#elif defined(PRIVATE_HW)
|
||||
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||
#elif defined(NANO_G1)
|
||||
#define HW_VENDOR HardwareModel_NANO_G1
|
||||
#define HW_VENDOR HardwareModel_NANO_G1
|
||||
#elif defined(M5STACK)
|
||||
#define HW_VENDOR HardwareModel_M5STACK
|
||||
#define HW_VENDOR HardwareModel_M5STACK
|
||||
#elif defined(STATION_G1)
|
||||
#define HW_VENDOR HardwareModel_STATION_G1
|
||||
#define HW_VENDOR HardwareModel_STATION_G1
|
||||
#elif defined(DR_DEV)
|
||||
#define HW_VENDOR HardwareModel_DR_DEV
|
||||
#define HW_VENDOR HardwareModel_DR_DEV
|
||||
#elif defined(HELTEC_V3)
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V3
|
||||
#define HW_VENDOR HardwareModel_HELTEC_V3
|
||||
#elif defined(HELTEC_WSL_V3)
|
||||
#define HW_VENDOR HardwareModel_HELTEC_WSL_V3
|
||||
#define HW_VENDOR HardwareModel_HELTEC_WSL_V3
|
||||
#elif defined(TLORA_T3S3_V1)
|
||||
#define HW_VENDOR HardwareModel_TLORA_T3_S3
|
||||
#define HW_VENDOR HardwareModel_TLORA_T3_S3
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -121,4 +121,3 @@
|
||||
#endif
|
||||
|
||||
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
|
||||
|
||||
|
||||
@@ -10,18 +10,19 @@
|
||||
#include "mesh/http/WiFiAPClient.h"
|
||||
|
||||
#include "sleep.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "target_specific.h"
|
||||
#include "utils.h"
|
||||
#include <Preferences.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include <nvs.h>
|
||||
#include <nvs_flash.h>
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
NimbleBluetooth *nimbleBluetooth;
|
||||
|
||||
void setBluetoothEnable(bool on) {
|
||||
void setBluetoothEnable(bool on)
|
||||
{
|
||||
|
||||
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
|
||||
if (!nimbleBluetooth) {
|
||||
@@ -35,8 +36,8 @@ void setBluetoothEnable(bool on) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
void setBluetoothEnable(bool on) { }
|
||||
void updateBatteryLevel(uint8_t level) { }
|
||||
void setBluetoothEnable(bool on) {}
|
||||
void updateBatteryLevel(uint8_t level) {}
|
||||
#endif
|
||||
|
||||
void getMacAddr(uint8_t *dmac)
|
||||
@@ -76,12 +77,12 @@ void enableSlowCLK()
|
||||
CALIBRATE_ONE(RTC_CAL_RTC_MUX);
|
||||
CALIBRATE_ONE(RTC_CAL_32K_XTAL);
|
||||
if (rtc_clk_slow_freq_get() != RTC_SLOW_FREQ_32K_XTAL) {
|
||||
LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! \n"); return;
|
||||
LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! \n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void esp32Setup()
|
||||
{
|
||||
uint32_t seed = esp_random();
|
||||
@@ -96,8 +97,8 @@ void esp32Setup()
|
||||
nvs_stats_t nvs_stats;
|
||||
auto res = nvs_get_stats(NULL, &nvs_stats);
|
||||
assert(res == ESP_OK);
|
||||
LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d\n", nvs_stats.used_entries, nvs_stats.free_entries,
|
||||
nvs_stats.total_entries, nvs_stats.namespace_count);
|
||||
LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d\n", nvs_stats.used_entries,
|
||||
nvs_stats.free_entries, nvs_stats.total_entries, nvs_stats.namespace_count);
|
||||
|
||||
LOG_DEBUG("Setup Preferences in Flash Storage\n");
|
||||
|
||||
@@ -110,10 +111,10 @@ void esp32Setup()
|
||||
preferences.putUInt("rebootCounter", rebootCounter);
|
||||
preferences.end();
|
||||
LOG_DEBUG("Number of Device Reboots: %d\n", rebootCounter);
|
||||
String BLEOTA=BleOta::getOtaAppVersion();
|
||||
String BLEOTA = BleOta::getOtaAppVersion();
|
||||
if (BLEOTA.isEmpty()) {
|
||||
LOG_DEBUG("No OTA firmware available\n");
|
||||
}else{
|
||||
} else {
|
||||
LOG_DEBUG("OTA firmware version %s\n", BLEOTA.c_str());
|
||||
}
|
||||
|
||||
@@ -155,7 +156,6 @@ uint32_t axpDebugRead()
|
||||
Periodic axpDebugOutput(axpDebugRead);
|
||||
#endif
|
||||
|
||||
|
||||
/// loop code specific to ESP32 targets
|
||||
void esp32Loop()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user