Merge pull request #8928 from meshtastic/develop
This commit is contained in:
@@ -2,4 +2,5 @@
|
|||||||
self-hosted-runner:
|
self-hosted-runner:
|
||||||
# Labels of self-hosted runner in array of strings.
|
# Labels of self-hosted runner in array of strings.
|
||||||
labels:
|
labels:
|
||||||
|
- arctastic
|
||||||
- test-runner
|
- test-runner
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ permissions: read-all
|
|||||||
jobs:
|
jobs:
|
||||||
pio-build:
|
pio-build:
|
||||||
name: build-${{ inputs.platform }}
|
name: build-${{ inputs.platform }}
|
||||||
runs-on: ubuntu-24.04
|
# Use 'arctastic' self-hosted runner pool when building in the main repo
|
||||||
|
runs-on: ${{ github.repository_owner == 'meshtastic' && 'arctastic' || 'ubuntu-latest' }}
|
||||||
outputs:
|
outputs:
|
||||||
artifact-id: ${{ steps.upload.outputs.artifact-id }}
|
artifact-id: ${{ steps.upload.outputs.artifact-id }}
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh || true
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh || true
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -9 -r ./firmware-${{inputs.target}}-${{ needs.version.outputs.long }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{inputs.target}}-${{ needs.version.outputs.long }}.zip ./output
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh || true
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh || true
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||||
@@ -280,9 +280,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate Release manifest
|
- name: Generate Release manifest
|
||||||
run: |
|
run: |
|
||||||
jq -n --arg ver "${{ needs.version.outputs.long }}" --arg targets "${{ toJson(needs.setup.outputs.all) }}" '{
|
jq -n --arg ver "${{ needs.version.outputs.long }}" --argjson targets ${{ toJson(needs.setup.outputs.all) }} '{
|
||||||
"version": $ver,
|
"version": $ver,
|
||||||
"targets": ($targets | fromjson)
|
"targets": $targets
|
||||||
}' > firmware-${{ needs.version.outputs.long }}.json
|
}' > firmware-${{ needs.version.outputs.long }}.json
|
||||||
|
|
||||||
- name: Save Release manifest artifact
|
- name: Save Release manifest artifact
|
||||||
@@ -338,8 +338,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh || true
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh || true
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||||
|
|||||||
@@ -188,8 +188,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh || true
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh || true
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||||
@@ -303,8 +303,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh || true
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh || true
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ TOOLS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BACKTRACE_REGEX = re.compile(
|
BACKTRACE_REGEX = re.compile(
|
||||||
r"(?:\s+(0x40[0-2](?:\d|[a-f]|[A-F]){5}):0x(?:\d|[a-f]|[A-F]){8})\b"
|
r"\b(0x4[0-9a-fA-F]{7,8}):0x[0-9a-fA-F]{8}\b"
|
||||||
)
|
)
|
||||||
EXCEPTION_REGEX = re.compile("^Exception \\((?P<exc>[0-9]*)\\):$")
|
EXCEPTION_REGEX = re.compile("^Exception \\((?P<exc>[0-9]*)\\):$")
|
||||||
COUNTER_REGEX = re.compile(
|
COUNTER_REGEX = re.compile(
|
||||||
@@ -89,7 +89,7 @@ POINTER_REGEX = re.compile(
|
|||||||
STACK_BEGIN = ">>>stack>>>"
|
STACK_BEGIN = ">>>stack>>>"
|
||||||
STACK_END = "<<<stack<<<"
|
STACK_END = "<<<stack<<<"
|
||||||
STACK_REGEX = re.compile(
|
STACK_REGEX = re.compile(
|
||||||
"^(?P<off>[0-9a-f]+):\W+(?P<c1>[0-9a-f]+) (?P<c2>[0-9a-f]+) (?P<c3>[0-9a-f]+) (?P<c4>[0-9a-f]+)(\W.*)?$"
|
r"^(?P<off>[0-9a-f]+):\W+(?P<c1>[0-9a-f]+) (?P<c2>[0-9a-f]+) (?P<c3>[0-9a-f]+) (?P<c4>[0-9a-f]+)(\W.*)?$"
|
||||||
)
|
)
|
||||||
|
|
||||||
StackLine = namedtuple("StackLine", ["offset", "content"])
|
StackLine = namedtuple("StackLine", ["offset", "content"])
|
||||||
@@ -223,7 +223,7 @@ class AddressResolver(object):
|
|||||||
if match is None:
|
if match is None:
|
||||||
if last is not None and line.startswith("(inlined by)"):
|
if last is not None and line.startswith("(inlined by)"):
|
||||||
line = line[12:].strip()
|
line = line[12:].strip()
|
||||||
self._address_map[last] += "\n \-> inlined by: " + line
|
self._address_map[last] += "\n \\-> inlined by: " + line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if match.group("result") == "?? ??:0":
|
if match.group("result") == "?? ??:0":
|
||||||
|
|||||||
+1
-1
@@ -207,7 +207,7 @@ lib_deps =
|
|||||||
# renovate: datasource=custom.pio depName=SparkFun Qwiic Scale NAU7802 packageName=sparkfun/library/SparkFun Qwiic Scale NAU7802 Arduino Library
|
# renovate: datasource=custom.pio depName=SparkFun Qwiic Scale NAU7802 packageName=sparkfun/library/SparkFun Qwiic Scale NAU7802 Arduino Library
|
||||||
sparkfun/SparkFun Qwiic Scale NAU7802 Arduino Library@1.0.6
|
sparkfun/SparkFun Qwiic Scale NAU7802 Arduino Library@1.0.6
|
||||||
# renovate: datasource=custom.pio depName=ClosedCube OPT3001 packageName=closedcube/library/ClosedCube OPT3001
|
# renovate: datasource=custom.pio depName=ClosedCube OPT3001 packageName=closedcube/library/ClosedCube OPT3001
|
||||||
ClosedCube OPT3001@1.1.2
|
closedcube/ClosedCube OPT3001@1.1.2
|
||||||
# renovate: datasource=custom.pio depName=Bosch BSEC2 packageName=boschsensortec/library/bsec2
|
# renovate: datasource=custom.pio depName=Bosch BSEC2 packageName=boschsensortec/library/bsec2
|
||||||
boschsensortec/bsec2@1.10.2610
|
boschsensortec/bsec2@1.10.2610
|
||||||
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
|
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
|
||||||
|
|||||||
@@ -532,8 +532,10 @@ void drawSystemScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x
|
|||||||
const int labelX = x;
|
const int labelX = x;
|
||||||
int barsOffset = (isHighResolution) ? 24 : 0;
|
int barsOffset = (isHighResolution) ? 24 : 0;
|
||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
|
#ifndef T_DECK_PRO
|
||||||
barsOffset -= 12;
|
barsOffset -= 12;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if defined(M5STACK_UNITC6L)
|
#if defined(M5STACK_UNITC6L)
|
||||||
const int barX = x + 45 + barsOffset;
|
const int barX = x + 45 + barsOffset;
|
||||||
#else
|
#else
|
||||||
@@ -574,7 +576,7 @@ void drawSystemScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x
|
|||||||
#endif
|
#endif
|
||||||
// Value string
|
// Value string
|
||||||
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||||
display->drawString(SCREEN_WIDTH - 2, getTextPositions(display)[line], combinedStr);
|
display->drawString(SCREEN_WIDTH, getTextPositions(display)[line], combinedStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
// === Memory values ===
|
// === Memory values ===
|
||||||
|
|||||||
@@ -1041,12 +1041,13 @@ void menuHandler::switchToMUIMenu()
|
|||||||
|
|
||||||
void menuHandler::TFTColorPickerMenu(OLEDDisplay *display)
|
void menuHandler::TFTColorPickerMenu(OLEDDisplay *display)
|
||||||
{
|
{
|
||||||
static const char *optionsArray[] = {"Back", "Default", "Meshtastic Green", "Yellow", "Red", "Orange", "Purple", "Teal",
|
static const char *optionsArray[] = {
|
||||||
"Pink", "White"};
|
"Back", "Default", "Meshtastic Green", "Yellow", "Red", "Orange", "Purple", "Blue", "Teal", "Cyan", "Ice", "Pink",
|
||||||
|
"White", "Gray"};
|
||||||
BannerOverlayOptions bannerOptions;
|
BannerOverlayOptions bannerOptions;
|
||||||
bannerOptions.message = "Select Screen Color";
|
bannerOptions.message = "Select Screen Color";
|
||||||
bannerOptions.optionsArrayPtr = optionsArray;
|
bannerOptions.optionsArrayPtr = optionsArray;
|
||||||
bannerOptions.optionsCount = 10;
|
bannerOptions.optionsCount = 14;
|
||||||
bannerOptions.bannerCallback = [display](int selected) -> void {
|
bannerOptions.bannerCallback = [display](int selected) -> void {
|
||||||
#if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) || defined(T_DECK) || defined(T_LORA_PAGER) || \
|
#if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) || defined(T_DECK) || defined(T_LORA_PAGER) || \
|
||||||
HAS_TFT || defined(HACKADAY_COMMUNICATOR)
|
HAS_TFT || defined(HACKADAY_COMMUNICATOR)
|
||||||
@@ -1082,20 +1083,40 @@ void menuHandler::TFTColorPickerMenu(OLEDDisplay *display)
|
|||||||
TFT_MESH_g = 153;
|
TFT_MESH_g = 153;
|
||||||
TFT_MESH_b = 255;
|
TFT_MESH_b = 255;
|
||||||
} else if (selected == 7) {
|
} else if (selected == 7) {
|
||||||
LOG_INFO("Setting color to Teal");
|
LOG_INFO("Setting color to Blue");
|
||||||
TFT_MESH_r = 64;
|
TFT_MESH_r = 0;
|
||||||
TFT_MESH_g = 224;
|
TFT_MESH_g = 0;
|
||||||
TFT_MESH_b = 208;
|
TFT_MESH_b = 255;
|
||||||
} else if (selected == 8) {
|
} else if (selected == 8) {
|
||||||
|
LOG_INFO("Setting color to Teal");
|
||||||
|
TFT_MESH_r = 16;
|
||||||
|
TFT_MESH_g = 102;
|
||||||
|
TFT_MESH_b = 102;
|
||||||
|
} else if (selected == 9) {
|
||||||
|
LOG_INFO("Setting color to Cyan");
|
||||||
|
TFT_MESH_r = 0;
|
||||||
|
TFT_MESH_g = 255;
|
||||||
|
TFT_MESH_b = 255;
|
||||||
|
} else if (selected == 10) {
|
||||||
|
LOG_INFO("Setting color to Ice");
|
||||||
|
TFT_MESH_r = 173;
|
||||||
|
TFT_MESH_g = 216;
|
||||||
|
TFT_MESH_b = 230;
|
||||||
|
} else if (selected == 11) {
|
||||||
LOG_INFO("Setting color to Pink");
|
LOG_INFO("Setting color to Pink");
|
||||||
TFT_MESH_r = 255;
|
TFT_MESH_r = 255;
|
||||||
TFT_MESH_g = 105;
|
TFT_MESH_g = 105;
|
||||||
TFT_MESH_b = 180;
|
TFT_MESH_b = 180;
|
||||||
} else if (selected == 9) {
|
} else if (selected == 12) {
|
||||||
LOG_INFO("Setting color to White");
|
LOG_INFO("Setting color to White");
|
||||||
TFT_MESH_r = 255;
|
TFT_MESH_r = 255;
|
||||||
TFT_MESH_g = 255;
|
TFT_MESH_g = 255;
|
||||||
TFT_MESH_b = 255;
|
TFT_MESH_b = 255;
|
||||||
|
} else if (selected == 13) {
|
||||||
|
LOG_INFO("Setting color to Gray");
|
||||||
|
TFT_MESH_r = 128;
|
||||||
|
TFT_MESH_g = 128;
|
||||||
|
TFT_MESH_b = 128;
|
||||||
} else {
|
} else {
|
||||||
menuQueue = system_base_menu;
|
menuQueue = system_base_menu;
|
||||||
screen->runNow();
|
screen->runNow();
|
||||||
|
|||||||
@@ -439,6 +439,11 @@ void setup()
|
|||||||
|
|
||||||
LOG_INFO("\n\n//\\ E S H T /\\ S T / C\n");
|
LOG_INFO("\n\n//\\ E S H T /\\ S T / C\n");
|
||||||
|
|
||||||
|
#if defined(ARCH_ESP32) && defined(BOARD_HAS_PSRAM)
|
||||||
|
// use PSRAM for malloc calls > 256 bytes
|
||||||
|
heap_caps_malloc_extmem_enable(256);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG_MUTE) && defined(DEBUG_PORT)
|
#if defined(DEBUG_MUTE) && defined(DEBUG_PORT)
|
||||||
DEBUG_PORT.printf("\r\n\r\n//\\ E S H T /\\ S T / C\r\n");
|
DEBUG_PORT.printf("\r\n\r\n//\\ E S H T /\\ S T / C\r\n");
|
||||||
DEBUG_PORT.printf("Version %s for %s from %s\r\n", optstr(APP_VERSION), optstr(APP_ENV), optstr(APP_REPO));
|
DEBUG_PORT.printf("Version %s for %s from %s\r\n", optstr(APP_VERSION), optstr(APP_ENV), optstr(APP_REPO));
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,8 @@
|
|||||||
|
|
||||||
static MemoryDynamic<meshtastic_MeshPacket> dynamicPool;
|
static MemoryDynamic<meshtastic_MeshPacket> dynamicPool;
|
||||||
Allocator<meshtastic_MeshPacket> &packetPool = dynamicPool;
|
Allocator<meshtastic_MeshPacket> &packetPool = dynamicPool;
|
||||||
#elif defined(ARCH_STM32WL)
|
#elif defined(ARCH_STM32WL) || defined(BOARD_HAS_PSRAM)
|
||||||
// On STM32 there isn't enough heap left over for the rest of the firmware if we allocate this statically.
|
// On STM32 and boards with PSRAM, there isn't enough heap left over for the rest of the firmware if we allocate this statically.
|
||||||
// For now, make it dynamic again.
|
// For now, make it dynamic again.
|
||||||
#define MAX_PACKETS \
|
#define MAX_PACKETS \
|
||||||
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
||||||
|
|||||||
@@ -45,8 +45,12 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
|||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
|
|
||||||
// If inbound message is a replay (or spoof!) of our own messages, we shouldn't process
|
const auto transport = mp.transport_mechanism;
|
||||||
// (why use second-hand sources for our own data?)
|
if (isFromUs(&mp) && !IS_ONE_OF(transport, meshtastic_MeshPacket_TransportMechanism_TRANSPORT_INTERNAL,
|
||||||
|
meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API)) {
|
||||||
|
LOG_WARN("Ignoring packet supposedly from us over external transport");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME this can in fact happen with packets sent from EUD (src=RX_SRC_USER)
|
// FIXME this can in fact happen with packets sent from EUD (src=RX_SRC_USER)
|
||||||
// to set fixed location, EUD-GPS location or just the time (see also issue #900)
|
// to set fixed location, EUD-GPS location or just the time (see also issue #900)
|
||||||
@@ -472,19 +476,53 @@ void PositionModule::sendLostAndFoundText()
|
|||||||
delete[] message;
|
delete[] message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper: return imprecise (truncated + centered) lat/lon as int32 using current precision
|
||||||
|
static inline void computeImpreciseLatLon(int32_t inLat, int32_t inLon, uint8_t precisionBits, int32_t &outLat, int32_t &outLon)
|
||||||
|
{
|
||||||
|
if (precisionBits > 0 && precisionBits < 32) {
|
||||||
|
// Build mask for top 'precisionBits' bits of a 32-bit unsigned field
|
||||||
|
const uint32_t mask = (precisionBits == 32) ? UINT32_MAX : (UINT32_MAX << (32 - precisionBits));
|
||||||
|
// Note: latitude_i/longitude_i are stored as signed 32-bit in meshtastic code but
|
||||||
|
// the bitmask logic used previously operated as unsigned—preserve that behavior by
|
||||||
|
// casting to uint32_t for masking, then back to int32_t.
|
||||||
|
uint32_t lat_u = static_cast<uint32_t>(inLat) & mask;
|
||||||
|
uint32_t lon_u = static_cast<uint32_t>(inLon) & mask;
|
||||||
|
|
||||||
|
// Add the "center of cell" offset used elsewhere:
|
||||||
|
// The code previously added (1 << (31 - precision)) to produce the middle of the possible location.
|
||||||
|
uint32_t center_offset = (1u << (31 - precisionBits));
|
||||||
|
lat_u += center_offset;
|
||||||
|
lon_u += center_offset;
|
||||||
|
|
||||||
|
outLat = static_cast<int32_t>(lat_u);
|
||||||
|
outLon = static_cast<int32_t>(lon_u);
|
||||||
|
} else {
|
||||||
|
// full precision: return input unchanged
|
||||||
|
outLat = inLat;
|
||||||
|
outLon = inLon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct SmartPosition PositionModule::getDistanceTraveledSinceLastSend(meshtastic_PositionLite currentPosition)
|
struct SmartPosition PositionModule::getDistanceTraveledSinceLastSend(meshtastic_PositionLite currentPosition)
|
||||||
{
|
{
|
||||||
// The minimum distance to travel before we are able to send a new position packet.
|
|
||||||
const uint32_t distanceTravelThreshold =
|
const uint32_t distanceTravelThreshold =
|
||||||
Default::getConfiguredOrDefault(config.position.broadcast_smart_minimum_distance, 100);
|
Default::getConfiguredOrDefault(config.position.broadcast_smart_minimum_distance, 100);
|
||||||
|
|
||||||
// Determine the distance in meters between two points on the globe
|
int32_t lastLatImprecise, lastLonImprecise;
|
||||||
float distanceTraveledSinceLastSend = GeoCoord::latLongToMeter(
|
int32_t currentLatImprecise, currentLonImprecise;
|
||||||
lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7, currentPosition.latitude_i * 1e-7, currentPosition.longitude_i * 1e-7);
|
|
||||||
|
|
||||||
return SmartPosition{.distanceTraveled = abs(distanceTraveledSinceLastSend),
|
computeImpreciseLatLon(lastGpsLatitude, lastGpsLongitude, precision, lastLatImprecise, lastLonImprecise);
|
||||||
|
computeImpreciseLatLon(currentPosition.latitude_i, currentPosition.longitude_i, precision, currentLatImprecise,
|
||||||
|
currentLonImprecise);
|
||||||
|
|
||||||
|
float distMeters = GeoCoord::latLongToMeter(lastLatImprecise * 1e-7, lastLonImprecise * 1e-7, currentLatImprecise * 1e-7,
|
||||||
|
currentLonImprecise * 1e-7);
|
||||||
|
|
||||||
|
float distanceTraveled = fabsf(distMeters);
|
||||||
|
|
||||||
|
return SmartPosition{.distanceTraveled = distanceTraveled,
|
||||||
.distanceThreshold = distanceTravelThreshold,
|
.distanceThreshold = distanceTravelThreshold,
|
||||||
.hasTraveledOverThreshold = abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold};
|
.hasTraveledOverThreshold = distanceTraveled >= distanceTravelThreshold};
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionModule::handleNewPosition()
|
void PositionModule::handleNewPosition()
|
||||||
|
|||||||
@@ -64,16 +64,6 @@ void onConnect(uint16_t conn_handle)
|
|||||||
connection->getPeerName(central_name, sizeof(central_name));
|
connection->getPeerName(central_name, sizeof(central_name));
|
||||||
LOG_INFO("BLE Connected to %s", central_name);
|
LOG_INFO("BLE Connected to %s", central_name);
|
||||||
|
|
||||||
// negotiate connections params as soon as possible
|
|
||||||
|
|
||||||
ble_gap_conn_params_t newParams;
|
|
||||||
newParams.min_conn_interval = 24;
|
|
||||||
newParams.max_conn_interval = 40;
|
|
||||||
newParams.slave_latency = 5;
|
|
||||||
newParams.conn_sup_timeout = 400;
|
|
||||||
|
|
||||||
sd_ble_gap_conn_param_update(conn_handle, &newParams);
|
|
||||||
|
|
||||||
// Notify UI (or any other interested firmware components)
|
// Notify UI (or any other interested firmware components)
|
||||||
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::CONNECTED);
|
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::CONNECTED);
|
||||||
bluetoothStatus->updateStatus(&newStatus);
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
@@ -129,7 +119,7 @@ void startAdv(void)
|
|||||||
Bluefruit.Advertising.addService(meshBleService);
|
Bluefruit.Advertising.addService(meshBleService);
|
||||||
/* Start Advertising
|
/* Start Advertising
|
||||||
* - Enable auto advertising if disconnected
|
* - Enable auto advertising if disconnected
|
||||||
* - Interval: fast mode = 20 ms, slow mode = 417,5 ms
|
* - Interval: fast mode = 20 ms, slow mode = 152.5 ms
|
||||||
* - Timeout for fast mode is 30 seconds
|
* - Timeout for fast mode is 30 seconds
|
||||||
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
|
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
|
||||||
*
|
*
|
||||||
@@ -137,7 +127,7 @@ void startAdv(void)
|
|||||||
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
||||||
*/
|
*/
|
||||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||||
Bluefruit.Advertising.setInterval(32, 668); // in unit of 0.625 ms
|
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
||||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds. FIXME, we should stop advertising after X
|
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds. FIXME, we should stop advertising after X
|
||||||
}
|
}
|
||||||
@@ -282,24 +272,6 @@ void NRF52Bluetooth::setup()
|
|||||||
// Set the connect/disconnect callback handlers
|
// Set the connect/disconnect callback handlers
|
||||||
Bluefruit.Periph.setConnectCallback(onConnect);
|
Bluefruit.Periph.setConnectCallback(onConnect);
|
||||||
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
|
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
|
||||||
|
|
||||||
// Set slave latency to 5 to conserve power
|
|
||||||
// Despite name this does not impact data transfer
|
|
||||||
// https://docs.silabs.com/bluetooth/2.13/bluetooth-general-system-and-performance/optimizing-current-consumption-in-bluetooth-low-energy-devices
|
|
||||||
|
|
||||||
Bluefruit.Periph.setConnSlaveLatency(5);
|
|
||||||
|
|
||||||
// TODO: Adafruit defaul min, max interval seems to be (20,30) [in 1.25 ms units] -> (25.00, 31.25) milliseconds
|
|
||||||
// so using formula Interval Max * (Slave Latency + 1) ≤ 2 seconds
|
|
||||||
// max slave latency we can use is 30 (max available in BLE)
|
|
||||||
// and even double max inteval (see apple doc linked above for formulas)
|
|
||||||
// See Periph.SetConnInterval method
|
|
||||||
|
|
||||||
// Tweak this later for even more power savings once those changes are confirmed to work well.
|
|
||||||
// Changing min, max interval may slow BLE transfer a bit - bumping slave latency will most likely not.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BLE_DFU_SECURE
|
#ifndef BLE_DFU_SECURE
|
||||||
bledfu.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM);
|
bledfu.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM);
|
||||||
bledfu.begin(); // Install the DFU helper
|
bledfu.begin(); // Install the DFU helper
|
||||||
@@ -328,7 +300,7 @@ void NRF52Bluetooth::setup()
|
|||||||
void NRF52Bluetooth::resumeAdvertising()
|
void NRF52Bluetooth::resumeAdvertising()
|
||||||
{
|
{
|
||||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||||
Bluefruit.Advertising.setInterval(32, 668); // in unit of 0.625 ms
|
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
||||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||||
Bluefruit.Advertising.start(0);
|
Bluefruit.Advertising.start(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
/** Master clock frequency */
|
/** Master clock frequency */
|
||||||
#define VARIANT_MCK (64000000ul)
|
#define VARIANT_MCK (64000000ul)
|
||||||
|
|
||||||
//#define USE_LFXO // Board uses 32khz crystal for LF
|
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||||
#define USE_LFRC // Board uses RC for LF
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* Headers
|
* Headers
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
/** Master clock frequency */
|
/** Master clock frequency */
|
||||||
#define VARIANT_MCK (64000000ul)
|
#define VARIANT_MCK (64000000ul)
|
||||||
|
|
||||||
//#define USE_LFXO // Board uses 32khz crystal for LF
|
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||||
|
|
||||||
#define USE_LFRC
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* Headers
|
* Headers
|
||||||
|
|||||||
Reference in New Issue
Block a user