Skip to content

Commit ea6f6c3

Browse files
committed
First stab at ESP32-C6 support for TLora-C6
1 parent 51b2263 commit ea6f6c3

File tree

19 files changed

+150
-40
lines changed

19 files changed

+150
-40
lines changed

arch/esp32/esp32c6.ini

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[esp32c6_base]
2+
extends = esp32_base
3+
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
4+
build_flags =
5+
${arduino_base.build_flags}
6+
-Wall
7+
-Wextra
8+
-Isrc/platform/esp32
9+
-std=c++11
10+
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
11+
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
12+
-DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
13+
-DAXP_DEBUG_PORT=Serial
14+
-DCONFIG_BT_NIMBLE_ENABLED
15+
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
16+
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
17+
-DSERIAL_BUFFER_SIZE=4096
18+
-DLIBPAX_ARDUINO
19+
-DLIBPAX_WIFI
20+
-DLIBPAX_BLE
21+
-DMESHTASTIC_EXCLUDE_WEBSERVER
22+
;-DDEBUG_HEAP
23+
; TEMP
24+
-DHAS_BLUETOOTH=0
25+
-DMESHTASTIC_EXCLUDE_PAXCOUNTER
26+
-DMESHTASTIC_EXCLUDE_BLUETOOTH
27+
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
28+
29+
lib_deps =
30+
${arduino_base.lib_deps}
31+
${networking_base.lib_deps}
32+
${environmental_base.lib_deps}
33+
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
34+
https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f
35+
rweather/Crypto@^0.4.0
36+
37+
build_src_filter =
38+
${esp32_base.build_src_filter} -<mesh/http>
39+
40+
monitor_speed = 115200
41+
monitor_filters = esp32_c3_exception_decoder
42+
43+
lib_ignore =
44+
NonBlockingRTTTL
45+
NimBLE-Arduino
46+
libpax
47+

src/gps/GPS.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const char *getGPSPowerStateString(GPSPowerState state)
5858
case GPS_OFF:
5959
return "OFF";
6060
default:
61-
assert(false); // Unhandled enum value..
61+
assert(false); // Unhandled enum value..
62+
return "FALSE"; // to make new ESP-IDF happy
6263
}
6364
}
6465

@@ -328,7 +329,7 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
328329
{
329330
uint16_t ubxFrameCounter = 0;
330331
uint32_t startTime = millis();
331-
uint16_t needRead;
332+
uint16_t needRead = 0;
332333

333334
while (millis() - startTime < waitMillis) {
334335
if (_serial_gps->available()) {

src/graphics/Screen.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,55 +1004,55 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
10041004

10051005
display->setColor(WHITE);
10061006
#ifndef EXCLUDE_EMOJI
1007-
if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F44D") == 0) {
1007+
if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F44D") == 0) {
10081008
display->drawXbm(x + (SCREEN_WIDTH - thumbs_width) / 2,
10091009
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - thumbs_height) / 2 + 2 + 5, thumbs_width, thumbs_height,
10101010
thumbup);
1011-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F44E") == 0) {
1011+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F44E") == 0) {
10121012
display->drawXbm(x + (SCREEN_WIDTH - thumbs_width) / 2,
10131013
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - thumbs_height) / 2 + 2 + 5, thumbs_width, thumbs_height,
10141014
thumbdown);
1015-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"") == 0) {
1015+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "") == 0) {
10161016
display->drawXbm(x + (SCREEN_WIDTH - question_width) / 2,
10171017
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - question_height) / 2 + 2 + 5, question_width, question_height,
10181018
question);
1019-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"‼️") == 0) {
1019+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "‼️") == 0) {
10201020
display->drawXbm(x + (SCREEN_WIDTH - bang_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - bang_height) / 2 + 2 + 5,
10211021
bang_width, bang_height, bang);
1022-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F4A9") == 0) {
1022+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F4A9") == 0) {
10231023
display->drawXbm(x + (SCREEN_WIDTH - poo_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - poo_height) / 2 + 2 + 5,
10241024
poo_width, poo_height, poo);
10251025
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\xf0\x9f\xa4\xa3") == 0) {
10261026
display->drawXbm(x + (SCREEN_WIDTH - haha_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - haha_height) / 2 + 2 + 5,
10271027
haha_width, haha_height, haha);
1028-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F44B") == 0) {
1028+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F44B") == 0) {
10291029
display->drawXbm(x + (SCREEN_WIDTH - wave_icon_width) / 2,
10301030
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - wave_icon_height) / 2 + 2 + 5, wave_icon_width,
10311031
wave_icon_height, wave_icon);
1032-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F920") == 0) {
1032+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F920") == 0) {
10331033
display->drawXbm(x + (SCREEN_WIDTH - cowboy_width) / 2,
10341034
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - cowboy_height) / 2 + 2 + 5, cowboy_width, cowboy_height,
10351035
cowboy);
1036-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F42D") == 0) {
1036+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\U0001F42D") == 0) {
10371037
display->drawXbm(x + (SCREEN_WIDTH - deadmau5_width) / 2,
10381038
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - deadmau5_height) / 2 + 2 + 5, deadmau5_width, deadmau5_height,
10391039
deadmau5);
1040-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\xE2\x98\x80\xEF\xB8\x8F") == 0) {
1040+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\xE2\x98\x80\xEF\xB8\x8F") == 0) {
10411041
display->drawXbm(x + (SCREEN_WIDTH - sun_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - sun_height) / 2 + 2 + 5,
10421042
sun_width, sun_height, sun);
1043-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\u2614") == 0) {
1043+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\u2614") == 0) {
10441044
display->drawXbm(x + (SCREEN_WIDTH - rain_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - rain_height) / 2 + 2 + 10,
10451045
rain_width, rain_height, rain);
1046-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"☁️") == 0) {
1046+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "☁️") == 0) {
10471047
display->drawXbm(x + (SCREEN_WIDTH - cloud_width) / 2,
10481048
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - cloud_height) / 2 + 2 + 5, cloud_width, cloud_height, cloud);
1049-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"🌫️") == 0) {
1049+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "🌫️") == 0) {
10501050
display->drawXbm(x + (SCREEN_WIDTH - fog_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - fog_height) / 2 + 2 + 5,
10511051
fog_width, fog_height, fog);
1052-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\xf0\x9f\x98\x88") == 0) {
1052+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "\xf0\x9f\x98\x88") == 0) {
10531053
display->drawXbm(x + (SCREEN_WIDTH - devil_width) / 2,
10541054
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - devil_height) / 2 + 2 + 5, devil_width, devil_height, devil);
1055-
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"♥️") == 0) {
1055+
} else if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), "♥️") == 0) {
10561056
display->drawXbm(x + (SCREEN_WIDTH - heart_width) / 2,
10571057
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - heart_height) / 2 + 2 + 5, heart_width, heart_height, heart);
10581058
} else {

src/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,19 @@ void setup()
322322
#ifdef BUTTON_PIN
323323
#ifdef ARCH_ESP32
324324

325-
// If the button is connected to GPIO 12, don't enable the ability to use
326-
// meshtasticAdmin on the device.
327-
pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT);
328-
325+
#if ESP_ARDUINO_VERSION_MAJOR >= 3
326+
#ifdef BUTTON_NEED_PULLUP
327+
pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT_PULLUP);
328+
#else
329+
pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT); // default to BUTTON_PIN
330+
#endif
331+
#else
332+
pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT); // default to BUTTON_PIN
329333
#ifdef BUTTON_NEED_PULLUP
330334
gpio_pullup_en((gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN));
331335
delay(10);
332336
#endif
333-
337+
#endif
334338
#endif
335339
#endif
336340

src/mesh/NodeDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
NodeDB *nodeDB = nullptr;
5050

5151
// we have plenty of ram so statically alloc this tempbuf (for now)
52-
EXT_RAM_ATTR meshtastic_DeviceState devicestate;
52+
EXT_RAM_BSS_ATTR meshtastic_DeviceState devicestate;
5353
meshtastic_MyNodeInfo &myNodeInfo = devicestate.my_node;
5454
meshtastic_LocalConfig config;
5555
meshtastic_LocalModuleConfig moduleConfig;

src/mesh/TypedQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
template <class T> class TypedQueue
1616
{
17-
static_assert(std::is_pod<T>::value, "T must be pod");
17+
static_assert(std::is_standard_layout<T>::value, "T must be standard layout");
1818
QueueHandle_t h;
1919
concurrency::OSThread *reader = NULL;
2020

src/mesh/api/ServerAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ template <class T, class U> void APIServerPort<T, U>::init()
4545

4646
template <class T, class U> int32_t APIServerPort<T, U>::runOnce()
4747
{
48-
auto client = U::available();
48+
auto client = U::accept();
4949
if (client) {
5050
// Close any previous connection (see FIXME in header file)
5151
if (openAPI) {

src/mesh/wifi/WiFiAPClient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ static void WiFiEvent(WiFiEvent_t event)
309309
onNetworkConnected();
310310
break;
311311
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
312-
LOG_INFO("Obtained IP6 address: %s\n", WiFi.localIPv6().toString().c_str());
312+
LOG_INFO("Obtained Local IP6 address: %s\n", WiFi.linkLocalIPv6().toString().c_str());
313+
LOG_INFO("Obtained GlobalIP6 address: %s\n", WiFi.globalIPv6().toString().c_str());
313314
break;
314315
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
315316
LOG_INFO("Lost IP address and IP address is reset to 0\n");

src/modules/ExternalNotificationModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "SinglePortModule.h"
44
#include "concurrency/OSThread.h"
55
#include "configuration.h"
6-
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
6+
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6)
77
#include <NonBlockingRtttl.h>
88
#else
99
// Noop class for portduino.

src/modules/PositionModule.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli()
273273

274274
meshtastic_TAKPacket takPacket = {.is_compressed = true,
275275
.has_contact = true,
276-
.contact = {0},
276+
.contact = meshtastic_Contact_init_default,
277277
.has_group = true,
278278
.group = {meshtastic_MemberRole_TeamMember, meshtastic_Team_Cyan},
279279
.has_status = true,
@@ -282,13 +282,13 @@ meshtastic_MeshPacket *PositionModule::allocAtakPli()
282282
.battery = powerStatus->getBatteryChargePercent(),
283283
},
284284
.which_payload_variant = meshtastic_TAKPacket_pli_tag,
285-
{.pli = {
286-
.latitude_i = localPosition.latitude_i,
287-
.longitude_i = localPosition.longitude_i,
288-
.altitude = localPosition.altitude_hae,
289-
.speed = localPosition.ground_speed,
290-
.course = static_cast<uint16_t>(localPosition.ground_track),
291-
}}};
285+
.payload_variant = {.pli = {
286+
.latitude_i = localPosition.latitude_i,
287+
.longitude_i = localPosition.longitude_i,
288+
.altitude = localPosition.altitude_hae,
289+
.speed = localPosition.ground_speed,
290+
.course = static_cast<uint16_t>(localPosition.ground_track),
291+
}}};
292292

293293
auto length = unishox2_compress_lines(owner.long_name, strlen(owner.long_name), takPacket.contact.device_callsign,
294294
sizeof(takPacket.contact.device_callsign) - 1, USX_PSET_DFLT, NULL);

0 commit comments

Comments
 (0)