mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 13:41:28 +00:00
Merge branch 'master' into detsensor_broadcast_changes
This commit is contained in:
commit
01d42d4728
90
.github/actions/build-variant/action.yml
vendored
Normal file
90
.github/actions/build-variant/action.yml
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
name: Setup Build Variant Composite Action
|
||||||
|
description: Variant build actions for Meshtastic Platform IO steps
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
board:
|
||||||
|
description: The board to build for
|
||||||
|
required: true
|
||||||
|
github_token:
|
||||||
|
description: GitHub token
|
||||||
|
required: true
|
||||||
|
build-script-path:
|
||||||
|
description: Path to the build script
|
||||||
|
required: true
|
||||||
|
remove-debug-flags:
|
||||||
|
description: A space separated list of files to remove debug flags from
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
ota-firmware-source:
|
||||||
|
description: The OTA firmware file to pull
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
ota-firmware-target:
|
||||||
|
description: The target path to store the OTA firmware file
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
artifact-paths:
|
||||||
|
description: A newline separated list of paths to store as artifacts
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
include-web-ui:
|
||||||
|
description: Include the web UI in the build
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Build base
|
||||||
|
id: base
|
||||||
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
|
- name: Pull web ui
|
||||||
|
if: inputs.include-web-ui == 'true'
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@master
|
||||||
|
with:
|
||||||
|
repo: meshtastic/web
|
||||||
|
file: build.tar
|
||||||
|
target: build.tar
|
||||||
|
token: ${{ inputs.github_token }}
|
||||||
|
|
||||||
|
- name: Unpack web ui
|
||||||
|
if: inputs.include-web-ui == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tar -xf build.tar -C data/static
|
||||||
|
rm build.tar
|
||||||
|
|
||||||
|
- name: Remove debug flags for release
|
||||||
|
shell: bash
|
||||||
|
if: inputs.remove-debug-flags != ''
|
||||||
|
run: |
|
||||||
|
for INI_FILE in ${{ inputs.remove-debug-flags }}; do
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ${INI_FILE}
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Build ${{ inputs.board }}
|
||||||
|
shell: bash
|
||||||
|
run: ${{ inputs.build-script-path }} ${{ inputs.board }}
|
||||||
|
|
||||||
|
- name: Pull OTA Firmware
|
||||||
|
if: inputs.ota-firmware-source != '' && inputs.ota-firmware-target != ''
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@master
|
||||||
|
with:
|
||||||
|
repo: meshtastic/firmware-ota
|
||||||
|
file: ${{ inputs.ota-firmware-source }}
|
||||||
|
target: ${{ inputs.ota-firmware-target }}
|
||||||
|
token: ${{ inputs.github_token }}
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
shell: bash
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
||||||
|
overwrite: true
|
||||||
|
path: |
|
||||||
|
${{ inputs.artifact-paths }}
|
58
.github/workflows/build_esp32.yml
vendored
58
.github/workflows/build_esp32.yml
vendored
@ -12,52 +12,22 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Pull web ui
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
|
||||||
repo: meshtastic/web
|
|
||||||
file: build.tar
|
|
||||||
target: build.tar
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Unpack web ui
|
|
||||||
run: |
|
|
||||||
tar -xf build.tar -C data/static
|
|
||||||
rm build.tar
|
|
||||||
|
|
||||||
- name: Remove debug flags for release
|
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
||||||
run: |
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
|
||||||
|
|
||||||
- name: Build ESP32
|
- name: Build ESP32
|
||||||
run: bin/build-esp32.sh ${{ inputs.board }}
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
- name: Pull OTA Firmware
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
with:
|
||||||
repo: meshtastic/firmware-ota
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: firmware.bin
|
board: ${{ inputs.board }}
|
||||||
target: release/bleota.bin
|
remove-debug-flags: >-
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
./arch/esp32/esp32.ini
|
||||||
|
./arch/esp32/esp32s2.ini
|
||||||
- name: Get release version string
|
./arch/esp32/esp32s3.ini
|
||||||
shell: bash
|
./arch/esp32/esp32c3.ini
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
build-script-path: bin/build-esp32.sh
|
||||||
id: version
|
ota-firmware-source: firmware.bin
|
||||||
|
ota-firmware-target: release/bleota.bin
|
||||||
- name: Store binaries as an artifact
|
artifact-paths: |
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
overwrite: true
|
|
||||||
path: |
|
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
|
include-web-ui: true
|
||||||
|
57
.github/workflows/build_esp32_c3.yml
vendored
57
.github/workflows/build_esp32_c3.yml
vendored
@ -14,50 +14,21 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Pull web ui
|
- name: Build ESP32-C3
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
with:
|
with:
|
||||||
repo: meshtastic/web
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: build.tar
|
board: ${{ inputs.board }}
|
||||||
target: build.tar
|
remove-debug-flags: >-
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
./arch/esp32/esp32.ini
|
||||||
|
./arch/esp32/esp32s2.ini
|
||||||
- name: Unpack web ui
|
./arch/esp32/esp32s3.ini
|
||||||
run: |
|
./arch/esp32/esp32c3.ini
|
||||||
tar -xf build.tar -C data/static
|
build-script-path: bin/build-esp32.sh
|
||||||
rm build.tar
|
ota-firmware-source: firmware-c3.bin
|
||||||
- name: Remove debug flags for release
|
ota-firmware-target: release/bleota-c3.bin
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
artifact-paths: |
|
||||||
run: |
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
|
||||||
- name: Build ESP32
|
|
||||||
run: bin/build-esp32.sh ${{ inputs.board }}
|
|
||||||
|
|
||||||
- name: Pull OTA Firmware
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
|
||||||
repo: meshtastic/firmware-ota
|
|
||||||
file: firmware-c3.bin
|
|
||||||
target: release/bleota-c3.bin
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
shell: bash
|
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
overwrite: true
|
|
||||||
path: |
|
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
|
58
.github/workflows/build_esp32_s3.yml
vendored
58
.github/workflows/build_esp32_s3.yml
vendored
@ -12,50 +12,22 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Pull web ui
|
- name: Build ESP32-S3
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
with:
|
with:
|
||||||
repo: meshtastic/web
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: build.tar
|
board: ${{ inputs.board }}
|
||||||
target: build.tar
|
remove-debug-flags: >-
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
./arch/esp32/esp32.ini
|
||||||
|
./arch/esp32/esp32s2.ini
|
||||||
- name: Unpack web ui
|
./arch/esp32/esp32s3.ini
|
||||||
run: |
|
./arch/esp32/esp32c3.ini
|
||||||
tar -xf build.tar -C data/static
|
build-script-path: bin/build-esp32.sh
|
||||||
rm build.tar
|
ota-firmware-source: firmware-s3.bin
|
||||||
- name: Remove debug flags for release
|
ota-firmware-target: release/bleota-s3.bin
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
artifact-paths: |
|
||||||
run: |
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
|
||||||
- name: Build ESP32
|
|
||||||
run: bin/build-esp32.sh ${{ inputs.board }}
|
|
||||||
|
|
||||||
- name: Pull OTA Firmware
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
|
||||||
repo: meshtastic/firmware-ota
|
|
||||||
file: firmware-s3.bin
|
|
||||||
target: release/bleota-s3.bin
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
shell: bash
|
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
overwrite: true
|
|
||||||
path: |
|
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
|
include-web-ui: true
|
||||||
|
20
.github/workflows/build_nrf52.yml
vendored
20
.github/workflows/build_nrf52.yml
vendored
@ -12,23 +12,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Build NRF52
|
- name: Build NRF52
|
||||||
run: bin/build-nrf52.sh ${{ inputs.board }}
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
- name: Get release version string
|
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
overwrite: true
|
board: ${{ inputs.board }}
|
||||||
path: |
|
build-script-path: bin/build-nrf52.sh
|
||||||
|
artifact-paths: |
|
||||||
release/*.hex
|
release/*.hex
|
||||||
release/*.uf2
|
release/*.uf2
|
||||||
release/*.elf
|
release/*.elf
|
||||||
|
20
.github/workflows/build_rpi2040.yml
vendored
20
.github/workflows/build_rpi2040.yml
vendored
@ -12,22 +12,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Build Raspberry Pi 2040
|
- name: Build Raspberry Pi 2040
|
||||||
run: ./bin/build-rpi2040.sh ${{ inputs.board }}
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
- name: Get release version string
|
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
overwrite: true
|
board: ${{ inputs.board }}
|
||||||
path: |
|
build-script-path: bin/build-rpi2040.sh
|
||||||
|
artifact-paths: |
|
||||||
release/*.uf2
|
release/*.uf2
|
||||||
release/*.elf
|
release/*.elf
|
||||||
|
22
.github/workflows/build_stm32.yml
vendored
22
.github/workflows/build_stm32.yml
vendored
@ -12,22 +12,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build base
|
|
||||||
id: base
|
|
||||||
uses: ./.github/actions/setup-base
|
|
||||||
|
|
||||||
- name: Build STM32
|
- name: Build Raspberry Pi 2040
|
||||||
run: bin/build-stm32.sh ${{ inputs.board }}
|
id: build
|
||||||
|
uses: ./.github/actions/build-variant
|
||||||
- name: Get release version string
|
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
overwrite: true
|
board: ${{ inputs.board }}
|
||||||
path: |
|
build-script-path: bin/build-stm32.sh
|
||||||
|
artifact-paths: |
|
||||||
release/*.hex
|
release/*.hex
|
||||||
release/*.bin
|
release/*.bin
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9b84907847b67047b72f9792f4b47532b308bbe4
|
Subproject commit 9651aa59eaa3b54d801b9c251efcfe842790db32
|
@ -74,7 +74,6 @@ void SerialConsole::flush()
|
|||||||
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
||||||
bool SerialConsole::checkIsConnected()
|
bool SerialConsole::checkIsConnected()
|
||||||
{
|
{
|
||||||
uint32_t now = millis();
|
|
||||||
return Throttle::isWithinTimespanMs(lastContactMsec, SERIAL_CONNECTION_TIMEOUT);
|
return Throttle::isWithinTimespanMs(lastContactMsec, SERIAL_CONNECTION_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,4 +121,4 @@ void SerialConsole::log_to_serial(const char *logLevel, const char *format, va_l
|
|||||||
emitLogRecord(ll, thread ? thread->ThreadName.c_str() : "", format, arg);
|
emitLogRecord(ll, thread ? thread->ThreadName.c_str() : "", format, arg);
|
||||||
} else
|
} else
|
||||||
RedirectablePrint::log_to_serial(logLevel, format, arg);
|
RedirectablePrint::log_to_serial(logLevel, format, arg);
|
||||||
}
|
}
|
@ -213,7 +213,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifndef WIRE_INTERFACES_COUNT
|
#ifndef WIRE_INTERFACES_COUNT
|
||||||
// Officially an NRF52 macro
|
// Officially an NRF52 macro
|
||||||
// Repurposed cross-platform to identify devices using Wire1
|
// Repurposed cross-platform to identify devices using Wire1
|
||||||
#if defined(I2C_SDA1) || defined(PIN_WIRE_SDA)
|
#if defined(I2C_SDA1) || defined(PIN_WIRE1_SDA)
|
||||||
#define WIRE_INTERFACES_COUNT 2
|
#define WIRE_INTERFACES_COUNT 2
|
||||||
#elif HAS_WIRE
|
#elif HAS_WIRE
|
||||||
#define WIRE_INTERFACES_COUNT 1
|
#define WIRE_INTERFACES_COUNT 1
|
||||||
|
@ -334,11 +334,10 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
|
|
||||||
// Check register 0x0F for 0x3300 response to ID LIS3DH chip.
|
// Check register 0x0F for 0x3300 response to ID LIS3DH chip.
|
||||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2);
|
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2);
|
||||||
if (registerValue == 0x3300) {
|
if (registerValue == 0x3300 || registerValue == 0x3333) { // RAK4631 WisBlock has LIS3DH register at 0x3333
|
||||||
type = LIS3DH;
|
type = LIS3DH;
|
||||||
LOG_INFO("LIS3DH accelerometer found\n");
|
LOG_INFO("LIS3DH accelerometer found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHT31_4x_ADDR:
|
case SHT31_4x_ADDR:
|
||||||
@ -435,4 +434,4 @@ size_t ScanI2CTwoWire::countDevices() const
|
|||||||
{
|
{
|
||||||
return foundDevices.size();
|
return foundDevices.size();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -92,6 +92,9 @@ class MeshService
|
|||||||
/// Return the next MqttClientProxyMessage packet destined to the phone.
|
/// Return the next MqttClientProxyMessage packet destined to the phone.
|
||||||
meshtastic_MqttClientProxyMessage *getMqttClientProxyMessageForPhone() { return toPhoneMqttProxyQueue.dequeuePtr(0); }
|
meshtastic_MqttClientProxyMessage *getMqttClientProxyMessageForPhone() { return toPhoneMqttProxyQueue.dequeuePtr(0); }
|
||||||
|
|
||||||
|
/// Return the next ClientNotification packet destined to the phone.
|
||||||
|
meshtastic_ClientNotification *getClientNotificationForPhone() { return toPhoneClientNotificationQueue.dequeuePtr(0); }
|
||||||
|
|
||||||
// search the queue for a request id and return the matching nodenum
|
// search the queue for a request id and return the matching nodenum
|
||||||
NodeNum getNodenumFromRequestId(uint32_t request_id);
|
NodeNum getNodenumFromRequestId(uint32_t request_id);
|
||||||
|
|
||||||
|
@ -657,9 +657,10 @@ void NodeDB::pickNewNodeNum()
|
|||||||
while (((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0) ||
|
while (((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0) ||
|
||||||
(nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) {
|
(nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) {
|
||||||
NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice
|
NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice
|
||||||
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, by MAC ending in 0x%02x%02x vs our 0x%02x%02x, so "
|
if (found)
|
||||||
"trying for 0x%x\n",
|
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, by MAC ending in 0x%02x%02x vs our 0x%02x%02x, so "
|
||||||
nodeNum, found->user.macaddr[4], found->user.macaddr[5], ourMacAddr[4], ourMacAddr[5], candidate);
|
"trying for 0x%x\n",
|
||||||
|
nodeNum, found->user.macaddr[4], found->user.macaddr[5], ourMacAddr[4], ourMacAddr[5], candidate);
|
||||||
nodeNum = candidate;
|
nodeNum = candidate;
|
||||||
}
|
}
|
||||||
LOG_DEBUG("Using nodenum 0x%x \n", nodeNum);
|
LOG_DEBUG("Using nodenum 0x%x \n", nodeNum);
|
||||||
|
@ -62,9 +62,11 @@ void PhoneAPI::handleStartConfig()
|
|||||||
|
|
||||||
void PhoneAPI::close()
|
void PhoneAPI::close()
|
||||||
{
|
{
|
||||||
|
LOG_INFO("PhoneAPI::close()\n");
|
||||||
|
|
||||||
if (state != STATE_SEND_NOTHING) {
|
if (state != STATE_SEND_NOTHING) {
|
||||||
state = STATE_SEND_NOTHING;
|
state = STATE_SEND_NOTHING;
|
||||||
|
resetReadIndex();
|
||||||
unobserve(&service->fromNumChanged);
|
unobserve(&service->fromNumChanged);
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
unobserve(&xModem.packetReady);
|
unobserve(&xModem.packetReady);
|
||||||
@ -72,8 +74,17 @@ void PhoneAPI::close()
|
|||||||
releasePhonePacket(); // Don't leak phone packets on shutdown
|
releasePhonePacket(); // Don't leak phone packets on shutdown
|
||||||
releaseQueueStatusPhonePacket();
|
releaseQueueStatusPhonePacket();
|
||||||
releaseMqttClientProxyPhonePacket();
|
releaseMqttClientProxyPhonePacket();
|
||||||
|
releaseClientNotification();
|
||||||
onConnectionChanged(false);
|
onConnectionChanged(false);
|
||||||
|
fromRadioScratch = {};
|
||||||
|
toRadioScratch = {};
|
||||||
|
nodeInfoForPhone = {};
|
||||||
|
packetForPhone = NULL;
|
||||||
|
filesManifest.clear();
|
||||||
|
fromRadioNum = 0;
|
||||||
|
config_nonce = 0;
|
||||||
|
config_state = 0;
|
||||||
|
pauseBluetoothLogging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +416,10 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_xmodemPacket_tag;
|
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_xmodemPacket_tag;
|
||||||
fromRadioScratch.xmodemPacket = xmodemPacketForPhone;
|
fromRadioScratch.xmodemPacket = xmodemPacketForPhone;
|
||||||
xmodemPacketForPhone = meshtastic_XModem_init_zero;
|
xmodemPacketForPhone = meshtastic_XModem_init_zero;
|
||||||
|
} else if (clientNotification) {
|
||||||
|
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_clientNotification_tag;
|
||||||
|
fromRadioScratch.clientNotification = *clientNotification;
|
||||||
|
releaseClientNotification();
|
||||||
} else if (packetForPhone) {
|
} else if (packetForPhone) {
|
||||||
printPacket("phone downloaded packet", packetForPhone);
|
printPacket("phone downloaded packet", packetForPhone);
|
||||||
|
|
||||||
@ -444,13 +459,6 @@ void PhoneAPI::sendConfigComplete()
|
|||||||
pauseBluetoothLogging = false;
|
pauseBluetoothLogging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhoneAPI::handleDisconnect()
|
|
||||||
{
|
|
||||||
filesManifest.clear();
|
|
||||||
pauseBluetoothLogging = false;
|
|
||||||
LOG_INFO("PhoneAPI disconnect\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhoneAPI::releasePhonePacket()
|
void PhoneAPI::releasePhonePacket()
|
||||||
{
|
{
|
||||||
if (packetForPhone) {
|
if (packetForPhone) {
|
||||||
@ -475,6 +483,14 @@ void PhoneAPI::releaseMqttClientProxyPhonePacket()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhoneAPI::releaseClientNotification()
|
||||||
|
{
|
||||||
|
if (clientNotification) {
|
||||||
|
service->releaseClientNotificationToPool(clientNotification);
|
||||||
|
clientNotification = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if we have data available to send to the phone
|
* Return true if we have data available to send to the phone
|
||||||
*/
|
*/
|
||||||
@ -509,7 +525,9 @@ bool PhoneAPI::available()
|
|||||||
queueStatusPacketForPhone = service->getQueueStatusForPhone();
|
queueStatusPacketForPhone = service->getQueueStatusForPhone();
|
||||||
if (!mqttClientProxyMessageForPhone)
|
if (!mqttClientProxyMessageForPhone)
|
||||||
mqttClientProxyMessageForPhone = service->getMqttClientProxyMessageForPhone();
|
mqttClientProxyMessageForPhone = service->getMqttClientProxyMessageForPhone();
|
||||||
bool hasPacket = !!queueStatusPacketForPhone || !!mqttClientProxyMessageForPhone;
|
if (!clientNotification)
|
||||||
|
clientNotification = service->getClientNotificationForPhone();
|
||||||
|
bool hasPacket = !!queueStatusPacketForPhone || !!mqttClientProxyMessageForPhone || !!clientNotification;
|
||||||
if (hasPacket)
|
if (hasPacket)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -552,7 +570,6 @@ void PhoneAPI::sendNotification(meshtastic_LogRecord_Level level, uint32_t reply
|
|||||||
cn->time = getValidTime(RTCQualityFromNet);
|
cn->time = getValidTime(RTCQualityFromNet);
|
||||||
strncpy(cn->message, message, sizeof(cn->message));
|
strncpy(cn->message, message, sizeof(cn->message));
|
||||||
service->sendClientNotification(cn);
|
service->sendClientNotification(cn);
|
||||||
delete cn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,11 +147,6 @@ class PhoneAPI
|
|||||||
*/
|
*/
|
||||||
virtual void onNowHasData(uint32_t fromRadioNum) {}
|
virtual void onNowHasData(uint32_t fromRadioNum) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclasses can use this to find out when a client drops the link
|
|
||||||
*/
|
|
||||||
virtual void handleDisconnect();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void releasePhonePacket();
|
void releasePhonePacket();
|
||||||
|
|
||||||
@ -159,6 +154,8 @@ class PhoneAPI
|
|||||||
|
|
||||||
void releaseMqttClientProxyPhonePacket();
|
void releaseMqttClientProxyPhonePacket();
|
||||||
|
|
||||||
|
void releaseClientNotification();
|
||||||
|
|
||||||
/// begin a new connection
|
/// begin a new connection
|
||||||
void handleStartConfig();
|
void handleStartConfig();
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ const RegionInfo regions[] = {
|
|||||||
const RegionInfo *myRegion;
|
const RegionInfo *myRegion;
|
||||||
bool RadioInterface::uses_default_frequency_slot = true;
|
bool RadioInterface::uses_default_frequency_slot = true;
|
||||||
|
|
||||||
static uint8_t bytes[MAX_RHPACKETLEN];
|
static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1];
|
||||||
|
|
||||||
void initRegion()
|
void initRegion()
|
||||||
{
|
{
|
||||||
@ -326,7 +326,7 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
|||||||
|
|
||||||
RadioInterface::RadioInterface()
|
RadioInterface::RadioInterface()
|
||||||
{
|
{
|
||||||
assert(sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
assert(sizeof(PacketHeader) == MESHTASTIC_HEADER_LENGTH); // make sure the compiler did what we expected
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadioInterface::reconfigure()
|
bool RadioInterface::reconfigure()
|
||||||
|
@ -9,8 +9,9 @@
|
|||||||
|
|
||||||
#define MAX_TX_QUEUE 16 // max number of packets which can be waiting for transmission
|
#define MAX_TX_QUEUE 16 // max number of packets which can be waiting for transmission
|
||||||
|
|
||||||
#define MAX_RHPACKETLEN 256
|
#define MAX_LORA_PAYLOAD_LEN 255 // max length of 255 per Semtech's datasheets on SX12xx
|
||||||
#define LORA_HEADER_LENGTH 16
|
#define MESHTASTIC_HEADER_LENGTH 16
|
||||||
|
#define MESHTASTIC_PKC_OVERHEAD 12
|
||||||
|
|
||||||
#define PACKET_FLAGS_HOP_LIMIT_MASK 0x07
|
#define PACKET_FLAGS_HOP_LIMIT_MASK 0x07
|
||||||
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
|
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
|
||||||
@ -90,7 +91,7 @@ class RadioInterface
|
|||||||
/**
|
/**
|
||||||
* A temporary buffer used for sending/receiving packets, sized to hold the biggest buffer we might need
|
* A temporary buffer used for sending/receiving packets, sized to hold the biggest buffer we might need
|
||||||
* */
|
* */
|
||||||
uint8_t radiobuf[MAX_RHPACKETLEN];
|
uint8_t radiobuf[MAX_LORA_PAYLOAD_LEN + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue a received packet for the registered receiver
|
* Enqueue a received packet for the registered receiver
|
||||||
|
@ -36,8 +36,8 @@ static MemoryDynamic<meshtastic_MeshPacket> staticPool;
|
|||||||
|
|
||||||
Allocator<meshtastic_MeshPacket> &packetPool = staticPool;
|
Allocator<meshtastic_MeshPacket> &packetPool = staticPool;
|
||||||
|
|
||||||
static uint8_t bytes[MAX_RHPACKETLEN];
|
static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1];
|
||||||
static uint8_t ScratchEncrypted[MAX_RHPACKETLEN];
|
static uint8_t ScratchEncrypted[MAX_LORA_PAYLOAD_LEN + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -330,13 +330,13 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
|
|||||||
// Attempt PKI decryption first
|
// Attempt PKI decryption first
|
||||||
if (p->channel == 0 && p->to == nodeDB->getNodeNum() && p->to > 0 && p->to != NODENUM_BROADCAST &&
|
if (p->channel == 0 && p->to == nodeDB->getNodeNum() && p->to > 0 && p->to != NODENUM_BROADCAST &&
|
||||||
nodeDB->getMeshNode(p->from) != nullptr && nodeDB->getMeshNode(p->from)->user.public_key.size > 0 &&
|
nodeDB->getMeshNode(p->from) != nullptr && nodeDB->getMeshNode(p->from)->user.public_key.size > 0 &&
|
||||||
nodeDB->getMeshNode(p->to)->user.public_key.size > 0 && rawSize > 12) {
|
nodeDB->getMeshNode(p->to)->user.public_key.size > 0 && rawSize > MESHTASTIC_PKC_OVERHEAD) {
|
||||||
LOG_DEBUG("Attempting PKI decryption\n");
|
LOG_DEBUG("Attempting PKI decryption\n");
|
||||||
|
|
||||||
if (crypto->decryptCurve25519(p->from, p->id, rawSize, ScratchEncrypted, bytes)) {
|
if (crypto->decryptCurve25519(p->from, p->id, rawSize, ScratchEncrypted, bytes)) {
|
||||||
LOG_INFO("PKI Decryption worked!\n");
|
LOG_INFO("PKI Decryption worked!\n");
|
||||||
memset(&p->decoded, 0, sizeof(p->decoded));
|
memset(&p->decoded, 0, sizeof(p->decoded));
|
||||||
rawSize -= 12;
|
rawSize -= MESHTASTIC_PKC_OVERHEAD;
|
||||||
if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded) &&
|
if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded) &&
|
||||||
p->decoded.portnum != meshtastic_PortNum_UNKNOWN_APP) {
|
p->decoded.portnum != meshtastic_PortNum_UNKNOWN_APP) {
|
||||||
decrypted = true;
|
decrypted = true;
|
||||||
@ -475,7 +475,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|
||||||
if (numbytes + LORA_HEADER_LENGTH > MAX_RHPACKETLEN)
|
if (numbytes + MESHTASTIC_HEADER_LENGTH > MAX_LORA_PAYLOAD_LEN)
|
||||||
return meshtastic_Routing_Error_TOO_LARGE;
|
return meshtastic_Routing_Error_TOO_LARGE;
|
||||||
|
|
||||||
// printBytes("plaintext", bytes, numbytes);
|
// printBytes("plaintext", bytes, numbytes);
|
||||||
@ -499,7 +499,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
|||||||
p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP && p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP &&
|
p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP && p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP &&
|
||||||
p->decoded.portnum != meshtastic_PortNum_ROUTING_APP && p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
|
p->decoded.portnum != meshtastic_PortNum_ROUTING_APP && p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
|
||||||
LOG_DEBUG("Using PKI!\n");
|
LOG_DEBUG("Using PKI!\n");
|
||||||
if (numbytes + LORA_HEADER_LENGTH + 12 > MAX_RHPACKETLEN)
|
if (numbytes + MESHTASTIC_HEADER_LENGTH + MESHTASTIC_PKC_OVERHEAD > MAX_LORA_PAYLOAD_LEN)
|
||||||
return meshtastic_Routing_Error_TOO_LARGE;
|
return meshtastic_Routing_Error_TOO_LARGE;
|
||||||
if (p->pki_encrypted && !memfll(p->public_key.bytes, 0, 32) &&
|
if (p->pki_encrypted && !memfll(p->public_key.bytes, 0, 32) &&
|
||||||
memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
|
memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
|
||||||
@ -508,7 +508,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
|||||||
return meshtastic_Routing_Error_PKI_FAILED;
|
return meshtastic_Routing_Error_PKI_FAILED;
|
||||||
}
|
}
|
||||||
crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted);
|
crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted);
|
||||||
numbytes += 12;
|
numbytes += MESHTASTIC_PKC_OVERHEAD;
|
||||||
memcpy(p->encrypted.bytes, ScratchEncrypted, numbytes);
|
memcpy(p->encrypted.bytes, ScratchEncrypted, numbytes);
|
||||||
p->channel = 0;
|
p->channel = 0;
|
||||||
p->pki_encrypted = true;
|
p->pki_encrypted = true;
|
||||||
|
@ -60,10 +60,17 @@ char *strnstr(const char *s, const char *find, size_t slen)
|
|||||||
|
|
||||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("%s: ", label);
|
char *messageBuffer;
|
||||||
for (size_t i = 0; i < numbytes; i++)
|
int labelSize = strlen(label);
|
||||||
LOG_DEBUG("%02x ", p[i]);
|
if (labelSize < 100 && numbytes < 64) {
|
||||||
LOG_DEBUG("\n");
|
messageBuffer = new char[labelSize + (numbytes * 3) + 2];
|
||||||
|
strncpy(messageBuffer, label, labelSize);
|
||||||
|
for (size_t i = 0; i < numbytes; i++)
|
||||||
|
snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
|
||||||
|
strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
|
||||||
|
LOG_DEBUG(messageBuffer);
|
||||||
|
delete messageBuffer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
||||||
|
@ -84,7 +84,6 @@ uint32_t NeighborInfoModule::collectNeighborInfo(meshtastic_NeighborInfo *neighb
|
|||||||
*/
|
*/
|
||||||
void NeighborInfoModule::cleanUpNeighbors()
|
void NeighborInfoModule::cleanUpNeighbors()
|
||||||
{
|
{
|
||||||
uint32_t now = getTime();
|
|
||||||
NodeNum my_node_id = nodeDB->getNodeNum();
|
NodeNum my_node_id = nodeDB->getNodeNum();
|
||||||
for (auto it = neighbors.rbegin(); it != neighbors.rend();) {
|
for (auto it = neighbors.rbegin(); it != neighbors.rend();) {
|
||||||
// We will remove a neighbor if we haven't heard from them in twice the broadcast interval
|
// We will remove a neighbor if we haven't heard from them in twice the broadcast interval
|
||||||
|
@ -115,7 +115,7 @@ void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
|
|
||||||
packetSequence++;
|
packetSequence++;
|
||||||
|
|
||||||
static char heartbeatString[MAX_RHPACKETLEN];
|
static char heartbeatString[MAX_LORA_PAYLOAD_LEN + 1];
|
||||||
snprintf(heartbeatString, sizeof(heartbeatString), "seq %u", packetSequence);
|
snprintf(heartbeatString, sizeof(heartbeatString), "seq %u", packetSequence);
|
||||||
|
|
||||||
p->decoded.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply
|
p->decoded.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply
|
||||||
|
@ -124,7 +124,14 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc) { LOG_INFO("BLE disconnect\n"); }
|
virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc)
|
||||||
|
{
|
||||||
|
LOG_INFO("BLE disconnect\n");
|
||||||
|
|
||||||
|
if (bluetoothPhoneAPI) {
|
||||||
|
bluetoothPhoneAPI->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static NimbleBluetoothToRadioCallback *toRadioCallbacks;
|
static NimbleBluetoothToRadioCallback *toRadioCallbacks;
|
||||||
|
@ -55,7 +55,6 @@ static BluetoothPhoneAPI *bluetoothPhoneAPI;
|
|||||||
|
|
||||||
void onConnect(uint16_t conn_handle)
|
void onConnect(uint16_t conn_handle)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get the reference to current connection
|
// Get the reference to current connection
|
||||||
BLEConnection *connection = Bluefruit.Connection(conn_handle);
|
BLEConnection *connection = Bluefruit.Connection(conn_handle);
|
||||||
connectionHandle = conn_handle;
|
connectionHandle = conn_handle;
|
||||||
@ -70,8 +69,10 @@ void onConnect(uint16_t conn_handle)
|
|||||||
*/
|
*/
|
||||||
void onDisconnect(uint16_t conn_handle, uint8_t reason)
|
void onDisconnect(uint16_t conn_handle, uint8_t reason)
|
||||||
{
|
{
|
||||||
// FIXME - we currently assume only one active connection
|
|
||||||
LOG_INFO("BLE Disconnected, reason = 0x%x\n", reason);
|
LOG_INFO("BLE Disconnected, reason = 0x%x\n", reason);
|
||||||
|
if (bluetoothPhoneAPI) {
|
||||||
|
bluetoothPhoneAPI->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
|
void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user