This is for you if you are writing your own LoRa device firmware and want the official Meshtastic phone app to connect to it over Bluetooth Low Energy (BLE) as if it were a Meshtastic node. At the end you will have the GATT table, the two-round config handshake the current app expects, ESP32 code for each piece, a way to decode the traffic, and every place the iOS app stalled or dropped the connection on me. I assume you can build ESP32 Arduino firmware and know what a protobuf is.
I got the full handshake working with the iOS app from my own firmware on a two-board node: an Adafruit ESP32 Feather V2 (HUZZAH32) handles BLE and talks binary UART to an Adafruit Feather RP2040 RFM95, which handles LoRa. Nothing below depends on that split except the bridge section.
Last verified: December 2026. Checked against Meshtastic firmware master at 8c56924 (2.8.4 in development; latest tag v2.8.3, an alpha pre-release), the protobufs repository at 1a7bec1 (November 30, 2026), Meshtastic-Apple main at eef0214 (2.7.31 in development; latest tag 2.7.30), and the arduino-esp32 BLE library at 2.0.17, 3.3.13 and 4.0.0. My own testing used the iOS app from the App Store in April and May 2026. The firmware listings are documentation-verified against those sources, not compiled for this article.
What Happened
In April 2026 I built the UART bridge and a bare BLE peripheral that advertised the Meshtastic service. In May I worked through the handshake from serial logs. The problems, roughly in the order I hit them:
- The app connected and wrote a
want_config_id, but my firmware did not answer with a config stream, so the app never finished connecting. - An AI assistant gave me “corrected” service and FromNum UUIDs from memory. They were wrong: the app still connected but never wrote to ToRadio. The originals, copied from the firmware, were right.
- Once my firmware answered, the app got as far as “receiving nodes” and then dropped. The log showed it asking for
want_config_id69421 three times and my firmware ignoring it. - The handshake worked only at one inter-packet delay. 500 ms worked; when I tuned it, 375 ms and 425 ms failed while 390 ms and 400 ms worked. I settled on 390.
- The connection cycled: connect, “Config sent”, disconnect, repeat. A
config_in_progressflag stopped my main loop injecting packets into the config stream. - At times it only worked after I deleted the app and set Location to “Always Allow”, and it failed while my second test board was transmitting LoRa packets every 3 seconds.
After I expanded the reply to the full set (MyNodeInfo, NodeInfo, metadata, all eight channels, seven configs, eight module configs and config_complete_id), reconnects worked without resetting anything. One session stayed up for about three hours, and the full path worked in both directions: app to ESP32 to RP2040 to LoRa, and back. Fitting an external 2.4 GHz antenna to the ESP32 board improved BLE reliability a lot. Still outstanding: the delay is a blocking delay(390), the LoRa payload is not encrypted yet, and I have not tested against a real Meshtastic node.
Reading the current firmware and app source afterwards suggests explanations for most of this. What follows is the protocol as it stands today.
How It Works
Your node is the GATT server (the BLE peripheral). GATT, the Generic Attribute Profile, organizes a device’s data into services holding characteristics: small values a client can read, write or subscribe to. The app is the client (the central). It scans for one service UUID and connects.
| Name | UUID | Properties in firmware | Purpose |
|---|---|---|---|
| Mesh service | 6ba1b218-15a8-461f-9fa8-5dcae273eafd |
(service) | The app scans for this UUID |
| ToRadio | f75c76d2-129e-4dad-a1dd-7866124401e7 |
Write | Phone writes one serialized ToRadio protobuf per write |
| FromRadio | 2c55e69e-4993-11ed-b878-0242ac120002 |
Read | Each read returns the next queued FromRadio, or 0 bytes when the queue is empty (during config the firmware holds the read until data is ready instead) |
| FromNum | ed9da18c-a800-4f66-a670-aa7547e34453 |
Notify, Read | A little-endian uint32 counter; a notification means “data is waiting” |
| LogRadio | 5a3d6e49-06e6-4423-9944-e9de8cdf9547 |
Notify, Read | Device logs as LogRecord protobufs; optional |
| Legacy log | 6c6fd238-78fa-436b-aacf-15c5be1ef2e2 |
(not created) | Raw log strings; deprecated |
In PIN pairing modes the firmware also requires an authenticated, encrypted link for all four. The current iOS app requires ToRadio, FromRadio and FromNum, subscribes to FromNum, FromRadio and LogRadio, and waits until the FromNum subscription is confirmed.
Framing. Over BLE there is none. The value of a ToRadio write or a FromRadio read is exactly one serialized protobuf, with no length prefix. (The serial and TCP transports wrap each message in a 4-byte header, 0x94 0xC3 and a 16-bit length; do not copy that onto BLE.) The firmware caps both message types at 512 bytes.
How the phone learns data is waiting. The device increments a counter and notifies FromNum. The app then reads FromRadio repeatedly until a read returns 0 bytes. It also starts that read loop right after each want_config_id write. That pull model matters more than anything else on this page. In the current app source, a FromRadio value update is handed to a read the app has pending, and dropped if no read is pending; the code does not tell a notification apart from a read response. That is my reading of the source, not something I tested. The firmware deliberately leaves Notify off FromRadio; a comment in its BLE code says adding it appears to break things and is not backwards compatible.
MTU. The MTU (maximum transmission unit) is the largest ATT packet the link carries. The client API docs say the device works with any MTU but strongly recommend 512. The firmware requests 517. On iOS the operating system negotiates the MTU; the app only reads the resulting limit.
Pairing and bonding. Config.BluetoothConfig.PairingMode is RANDOM_PIN (0), FIXED_PIN (1) or NO_PIN (2, “Just Works”). With a PIN, the firmware requires bonding, MITM protection and Secure Connections; iOS shows the PIN sheet while subscribing, and the app allows 90 seconds for that on a first bond (5 seconds after). My firmware used no security, the NO_PIN case: anyone in range can connect and read your config. Do that only on a bench.
The handshake. The app writes a heartbeat, then want_config_id. The device streams FromRadio messages and ends with config_complete_id set to the same number. The current app does this twice with two fixed values that the firmware treats specially:
69420(SPECIAL_NONCE_ONLY_CONFIG): configuration only, no node database.69421(SPECIAL_NONCE_ONLY_NODES): your own NodeInfo, then every other node’s NodeInfo, thenconfig_complete_id69421.
For 69420 the firmware currently sends, in order: my_info, deviceuiConfig, your own node_info, metadata, region_presets, eight channel messages, config for device, position, power, network, display, lora, bluetooth, security and sessionkey (device_ui is a no-op), one moduleConfig per module type, fileInfo entries, then config_complete_id. The client docs say not to depend on exact order and to handle each message by type. The current app does depend on two things: my_info must arrive before channels (it supplies the node number), and your own node_info, with user set and num equal to that node number, must arrive before any config (it supplies the device name), or the app logs “Attempt to process channel information when no connected device.” and throws the message away.
The two want_config_id rounds the current iOS app performs. Every FromRadio is pulled by a read.
Keepalive. ToRadio.heartbeat exists “to keep the device connection awake on serial”. The iOS app sends one before each want_config_id, with a random nonce of 2 or more (firmware treats nonce 1 as a request to rebroadcast its NodeInfo). Over TCP and serial the app also sends one after 15 seconds of silence and expects a reply. Over BLE it sends no periodic heartbeat and leaves link supervision to Core Bluetooth. Firmware 2.7.4 and later answers a heartbeat with a queueStatus message.
Version gate. The app reads DeviceMetadata.firmware_version, formatted major.minor.patch.commit (for example 2.8.0.3a0c08b). The app cuts the string at its last dot, so include the commit part; a version with no dot at all fails the version check. Below the app’s minimum (2.5.14 in the current source) it blocks everything except the firmware update screen. The app also turns features on by version, so report the version whose protocol you actually implement.
What changed since my build. The firmware added the region_presets message in June 2026; the current app treats it as optional. The client API page still describes an older flow (“RadioConfig”, “endConfig”) and lists FromNum as writable, which the firmware does not implement. The firmware and app source are the reference. On the library side, arduino-esp32 4.0.0 (tagged November 2026) replaced the BLE API my code uses; see Step 2.
Prerequisites
- An ESP32 board with BLE, and the arduino-esp32 core. My listings use the
BLEDeviceAPI from cores 2.x and 3.x; they do not compile on 4.0, which removed it. - The Meshtastic app on a phone with Bluetooth on. I tested only the iOS app; the Android app has its own client code.
- nanopb 0.4.9 (the version the firmware’s
bin/regen-protos.shnames) and a clone ofgithub.com/meshtastic/protobufs. Your firmware also needs nanopb’s runtime files (pb.h,pb_common,pb_encode,pb_decode,.cand.h) from the same nanopb directory, copied into your project, for example underlib/nanopb/. - A serial monitor at 115200 baud (PlatformIO’s
pio device monitorworks). - Values to choose up front: a node number (
0x<8 hex digits>), a long name (24 bytes of UTF-8 at most) and short name (4 bytes at most), and your LoRa region code.
Step 1: Generate the Protobuf Code with nanopb
nanopb generates small C structs and encoders suitable for a microcontroller. The .options files in the protobufs repo set string and array sizes, so run the generator from the repo root the way the firmware’s own script does. nanopb’s prebuilt release includes a protoc with the plugin wired in. Give <YOUR_PROJECT> as an absolute path, because the commands run from inside the protobufs clone.
git clone https://github.com/meshtastic/protobufs.git
cd protobufs
mkdir -p <YOUR_PROJECT>/lib/meshtastic
<NANOPB_DIR>/generator-bin/protoc --experimental_allow_proto3_optional \
--nanopb_out=<YOUR_PROJECT>/lib/meshtastic -I . meshtastic/*.proto
You get meshtastic/mesh.pb.h, meshtastic/mesh.pb.c and the rest under that directory. Note the union naming, which cost me a compile error: the options mark ToRadio, FromRadio and MeshPacket oneofs as anonymous, so you write fr.config, but Config and ModuleConfig keep a named union, so you write fr.config.payload_variant.lora.
Step 2: Define the GATT Service
Copy the UUIDs from the firmware source (src/BluetoothCommon.h), not from memory.
/* config.h: UUIDs from meshtastic/firmware src/BluetoothCommon.h */
#define MESHTASTIC_SERVICE_UUID "6ba1b218-15a8-461f-9fa8-5dcae273eafd"
#define TORADIO_UUID "f75c76d2-129e-4dad-a1dd-7866124401e7"
#define FROMRADIO_UUID "2c55e69e-4993-11ed-b878-0242ac120002"
#define FROMNUM_UUID "ed9da18c-a800-4f66-a670-aa7547e34453"
#define NODE_LONG_NAME "Tamo"
#define MY_NODE_NUM <YOUR_NODE_NUM> /* 0x followed by 8 hex digits */
This is my service setup, trimmed. It shows FromRadio with Notify, which is how my build pushed data. Step 5 explains why I would remove Notify now.
#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include "meshtastic/mesh.pb.h"
#include "config.h"
/* the callback classes from Step 3 go here, above ble_init() */
static BLEServer *pServer = NULL;
static BLECharacteristic *pFromRadio = NULL;
static BLECharacteristic *pFromNum = NULL;
static BLECharacteristic *pToRadio = NULL;
bool ble_init(void)
{
BLEDevice::init(NODE_LONG_NAME);
BLEDevice::setMTU(517); /* not in my build; the firmware requests 517 */
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MeshServerCallbacks());
BLEService *pService = pServer->createService(MESHTASTIC_SERVICE_UUID);
pFromRadio = pService->createCharacteristic(FROMRADIO_UUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
pFromRadio->addDescriptor(new BLE2902());
pFromNum = pService->createCharacteristic(FROMNUM_UUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
pFromNum->addDescriptor(new BLE2902());
pToRadio = pService->createCharacteristic(TORADIO_UUID,
BLECharacteristic::PROPERTY_WRITE);
pToRadio->setCallbacks(new ToRadioCallbacks());
pService->start();
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(MESHTASTIC_SERVICE_UUID);
pAdvertising->setScanResponse(true);
BLEDevice::startAdvertising();
return true;
}
BLE2902 is the Client Characteristic Configuration Descriptor (CCCD), the switch a client flips to enable notifications. The API has moved under this code:
| Concern | arduino-esp32 2.x / 3.x (Bluedroid) | 3.x on NimBLE chips | arduino-esp32 4.0.0 | NimBLE-Arduino 2.6.0 |
|---|---|---|---|---|
| Init | BLEDevice::init(name) |
same | BLE.begin(name) |
NimBLEDevice::init(name) |
| CCCD | addDescriptor(new BLE2902()) required |
automatic; BLE2902 deprecated |
automatic for Notify | automatic; manual 0x2902 does not work |
| Write callback | onWrite(BLECharacteristic*) in a callbacks class |
onWrite(BLECharacteristic*, ble_gap_conn_desc*) also available |
chr.onWrite([](BLECharacteristic &c, const BLEConnInfo &conn) {...}) |
onWrite(NimBLECharacteristic*, NimBLEConnInfo&) |
| Read value | getData() / getLength(); getValue() is std::string in 2.x, String in 3.x |
same | getValue(&len) returns const uint8_t* |
getValue(); getData() removed |
| Properties | PROPERTY_READ etc. |
PROPERTY_READ_AUTHEN etc. |
BLEProperty::Read plus a required BLEPermission such as ReadOpen |
NIMBLE_PROPERTY::READ etc. |
| Start | pService->start() |
same | server.start() once, after all services |
start() kept as a no-op |
The 4.0.0 column comes from the library’s v3-to-v4 migration guide. NimBLE-Arduino’s development branch (3.0) changes onWrite again, so pin your library version. On 4.0.0, access is closed by default: a characteristic without a matching BLEPermission is not readable or writable, which looks exactly like “the app connects and does nothing”.
Step 3: Decode ToRadio Writes
Each write is one ToRadio. Decode it, act on want_config_id, and get out of the callback quickly, because it runs in the Bluetooth stack’s task, not your loop(). The firmware’s own write callback carries a comment telling you to do nothing there except hand the data to the main task.
static volatile bool connected = false;
static volatile bool config_in_progress = false;
static volatile bool want_config = false;
static volatile uint32_t config_nonce = 0;
class MeshServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer *s) {
connected = true;
Serial.println("BLE connected");
}
void onDisconnect(BLEServer *s) {
connected = false;
Serial.println("BLE disconnected");
BLEDevice::startAdvertising();
}
};
class ToRadioCallbacks : public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *c) {
uint8_t *data = c->getData();
size_t len = c->getLength();
Serial.print("ToRadio bytes: ");
for (size_t i = 0; i < len; i++) { Serial.print("0x"); Serial.print(data[i], HEX); Serial.print(" "); }
Serial.println();
meshtastic_ToRadio to_radio = meshtastic_ToRadio_init_zero;
pb_istream_t stream = pb_istream_from_buffer(data, len);
if (!pb_decode(&stream, meshtastic_ToRadio_fields, &to_radio)) {
Serial.println("ToRadio decode failed");
return;
}
if (to_radio.which_payload_variant == meshtastic_ToRadio_want_config_id_tag) {
/* changed from my build, see below */
config_nonce = to_radio.want_config_id;
want_config = true; /* loop() calls send_config(config_nonce) */
}
}
};
At the time of the 69421 problem, my build called send_config() right there, behind a guard that ignored every want_config_id after the first. That guard threw away the whole 69421 round (see Troubleshooting). Answer each want_config_id according to its value, and only ignore an exact repeat while you are still streaming the reply to it. The firmware also drops a write that is byte-for-byte identical to the previous one.
Step 4: Answer want_config_id
Build each reply as a FromRadio, encode it, and queue it. This is condensed from my send_config(); the order is the one that worked with the app. Values in angle brackets are yours.
static meshtastic_FromRadio fr; /* large union: keep it off the task stack */
#define CLEAR_FR() memset(&fr, 0, sizeof(fr)) /* same as _init_zero, no temporary */
static void queue_fr(void)
{
uint8_t buf[512];
pb_ostream_t os = pb_ostream_from_buffer(buf, sizeof(buf));
if (pb_encode(&os, meshtastic_FromRadio_fields, &fr))
queue_from_radio(buf, os.bytes_written); /* ring buffer, Step 5 */
}
static void send_config(uint32_t nonce)
{
config_in_progress = true;
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_my_info_tag;
fr.my_info.my_node_num = MY_NODE_NUM;
queue_fr();
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_node_info_tag;
fr.node_info.num = MY_NODE_NUM;
fr.node_info.has_user = true;
strncpy(fr.node_info.user.long_name, NODE_LONG_NAME, sizeof(fr.node_info.user.long_name) - 1);
strncpy(fr.node_info.user.short_name, "<SHRT>", sizeof(fr.node_info.user.short_name) - 1);
fr.node_info.user.hw_model = meshtastic_HardwareModel_PRIVATE_HW;
queue_fr();
if (nonce != 69421) { /* added since: 69421 wants nodes only */
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_metadata_tag;
strncpy(fr.metadata.firmware_version, "<MAJOR.MINOR.PATCH.COMMIT>", sizeof(fr.metadata.firmware_version) - 1);
fr.metadata.hw_model = meshtastic_HardwareModel_PRIVATE_HW;
queue_fr();
for (int i = 0; i < 8; i++) {
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_channel_tag;
fr.channel.index = i;
fr.channel.role = (i == 0) ? meshtastic_Channel_Role_PRIMARY : meshtastic_Channel_Role_DISABLED;
fr.channel.has_settings = true;
fr.channel.settings.psk.size = 1;
fr.channel.settings.psk.bytes[0] = 1; /* 1 = the default channel key */
queue_fr();
}
const pb_size_t cfg[] = { meshtastic_Config_device_tag, meshtastic_Config_position_tag,
meshtastic_Config_power_tag, meshtastic_Config_network_tag, meshtastic_Config_display_tag,
meshtastic_Config_lora_tag, meshtastic_Config_bluetooth_tag };
for (pb_size_t tag : cfg) {
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_config_tag;
fr.config.which_payload_variant = tag;
if (tag == meshtastic_Config_lora_tag) {
fr.config.payload_variant.lora.use_preset = true;
fr.config.payload_variant.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
fr.config.payload_variant.lora.region = <YOUR_REGION_CODE>;
fr.config.payload_variant.lora.hop_limit = 3;
fr.config.payload_variant.lora.tx_enabled = true;
}
queue_fr();
}
const pb_size_t mod[] = { meshtastic_ModuleConfig_mqtt_tag, meshtastic_ModuleConfig_serial_tag,
meshtastic_ModuleConfig_external_notification_tag, meshtastic_ModuleConfig_store_forward_tag,
meshtastic_ModuleConfig_range_test_tag, meshtastic_ModuleConfig_telemetry_tag,
meshtastic_ModuleConfig_canned_message_tag, meshtastic_ModuleConfig_audio_tag };
for (pb_size_t tag : mod) {
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_moduleConfig_tag;
fr.moduleConfig.which_payload_variant = tag; /* all-default module config */
queue_fr();
}
}
/* for 69421, queue a node_info here for every other node you know */
CLEAR_FR();
fr.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
fr.config_complete_id = nonce;
queue_fr();
config_in_progress = false;
}
A sub-message with only which_payload_variant set encodes as an empty message, which the app reads as all defaults. This config only reports settings to the app; the radio itself is configured on the LoRa side. Legal frequencies, power limits and duty cycle depend on the region, so report the region your radio actually uses (a meshtastic_Config_LoRaConfig_RegionCode_* value) and set the radio up for the rules where you transmit. In loop(), call send_config(config_nonce) when want_config is set, then clear the flag.
Step 5: Serve FromRadio from a Queue
This is the part I would change first. My build pushed each packet: set FromRadio’s value, notify FromRadio, bump and notify FromNum, then delay(390) before the next one.
/* my build: push one packet, then wait */
pFromRadio->setValue(from_radio_queue[from_radio_head], from_radio_queue_len[from_radio_head]);
pFromRadio->notify();
from_radio_head = (from_radio_head + 1) % FROM_RADIO_QUEUE_SIZE;
from_num++;
pFromNum->setValue((uint8_t *)&from_num, 4); /* little-endian on ESP32 */
pFromNum->notify();
delay(390);
In the current app source, each FromNum notification starts FromRadio reads that continue until one returns 0 bytes, and a FromRadio value that arrives with no read pending is dropped. With my push design a read returned whatever value I had set last, so too fast would overwrite a value before the app read it, and too slow would let the app read the same packet twice. That is my reading of the source, not a tested result, and my best explanation for why only a narrow delay worked. I have not run the fix below on the board yet, so treat it as the direction, not a tested listing.
Make FromRadio read-only and let each read pop the queue. An empty queue returns 0 bytes, which ends the app’s loop.
class FromRadioCallbacks : public BLECharacteristicCallbacks {
void onRead(BLECharacteristic *c) {
static Frame f; /* { uint16_t len; uint8_t data[512]; } */
if (xQueueReceive(from_radio_q, &f, 0) == pdTRUE)
c->setValue(f.data, f.len);
else
c->setValue((uint8_t *)"", 0); /* empty read: drained */
}
};
/* in ble_init(), replacing the FromRadio lines (no Notify, no BLE2902) */
pFromRadio = pService->createCharacteristic(FROMRADIO_UUID, BLECharacteristic::PROPERTY_READ);
pFromRadio->setCallbacks(new FromRadioCallbacks());
from_radio_q is a FreeRTOS queue (xQueueCreate(32, sizeof(Frame))), safe to fill from loop() and drain from the Bluetooth task. queue_from_radio() sends into it; after a batch, increment from_num and notify FromNum once. In the arduino-esp32 Bluedroid code, onRead runs before the response is built and long values are served from that snapshot, so setting the value there works. The real firmware goes further: PhoneAPI::getFromRadio() is a state machine that encodes the next handshake message only when a read asks for it.
Step 6: Bridge to the LoRa Board
The phone only ever sees the ESP32. The UART framing is mine, not part of Meshtastic.
The bridge frame is a magic byte 0xAA, a type byte (0x01 for ESP32 to RP2040, 0x02 back), a two-byte length with the high byte first, then the payload. The ESP32 uses Serial2 on TX GPIO 27 and RX GPIO 33; the Feather RP2040 uses Serial1. Wire TX to RX, RX to TX, and a common ground. Before writing any protocol code I sent one byte (0x42) and checked it echoed back.
bool bridge_send(uint8_t type, const uint8_t *payload, uint16_t len)
{
BRIDGE_SERIAL.write(BRIDGE_MAGIC);
BRIDGE_SERIAL.write(type);
BRIDGE_SERIAL.write((uint8_t)(len >> 8));
BRIDGE_SERIAL.write((uint8_t)(len & 0xFF));
if (len > 0 && payload != NULL)
BRIDGE_SERIAL.write(payload, len);
return true;
}
The receiver is a five-state machine: magic, type, length high, length low, payload. Drop any frame longer than your buffer; my first version stored only what fit but reported the full length. There is no CRC yet, so a corrupted length byte can swallow the next frame.
One text message on its way out. Layers 1 and 2 are Meshtastic formats; layer 4 shows what a real node sends, which my build does not match yet.
Two bridge mistakes hit the Bluetooth work directly:
- Pin names that collide with message names. I called
Serial2.begin(115200, SERIAL_8N1, BRIDGE_RX, BRIDGE_TX), whereBRIDGE_RXandBRIDGE_TXwere the message-type constants (2 and 1), notBRIDGE_RX_PINandBRIDGE_TX_PIN. The UART came up on GPIO 2 and 1 instead of 33 and 27, and the bridge did not work. Name pins and message types so they cannot be confused. - Bridge writes inside the BLE callback. Once ToRadio packets were forwarded straight from
onWrite, connecting from the app became difficult again. I moved thebridge_send()intoloop()behind a flag, as the firmware’s own callback comment advises, after which the forward path worked, though the first connection attempt still sometimes dropped during the config flush. I did not prove the callback was the cause.
Step 7: Watch the Exchange
Use three views at once.
A BLE explorer app. nRF Connect for Mobile or LightBlue shows your service, UUIDs and properties, and lets you subscribe to FromNum and read FromRadio by hand. Close the Meshtastic app first so it does not hold the connection.
Serial logging. Print every ToRadio write as hex, plus each state change. A real excerpt from my log:
BLE connected
ToRadio bytes: 0x3A 0x6 0x8 0xBE 0x85 0xFA 0xB1 0xB
ToRadio bytes: 0x18 0xAC 0x9E 0x4
want_config_id: 69420
Sending config...
Sending config_complete_id: 69420
Config sent
Decoding the bytes. 0x18 is field 3 with the varint wire type (3 << 3 | 0), which is want_config_id; 0xAC 0x9E 0x04 is the varint 69420. 0x3A is field 7, length-delimited: a heartbeat. To decode against the official schema with protoc (a system install such as Debian and Ubuntu’s protobuf-compiler package; this command was not run for this article). The octal escapes are the same four bytes and work in any POSIX printf:
cd protobufs
printf '\030\254\236\004' | protoc -I . --decode=meshtastic.ToRadio meshtastic/mesh.proto
Expected output:
want_config_id: 69420
protoc --decode_raw works without any schema when you only need field numbers. In Python, the meshtastic package (pip install meshtastic) ships classes generated from the official definitions:
from meshtastic.protobuf import mesh_pb2
for h in ["18 ac 9e 04", "18 ad 9e 04", "3a 00"]:
m = mesh_pb2.ToRadio()
m.ParseFromString(bytes.fromhex(h))
print(h, "->", m.WhichOneof("payload_variant"), str(m).strip())
reply = mesh_pb2.FromRadio(config_complete_id=69420)
print("config_complete_id reply:", reply.SerializeToString().hex(" "))
The same code, run on a Linux test machine (not my hardware) with protobuf 7.36.1 against the generated files in the meshtastic/python repository (commit 795a0f0, November 20, 2026) rather than an installed package, printed:
18 ac 9e 04 -> want_config_id want_config_id: 69420
18 ad 9e 04 -> want_config_id want_config_id: 69421
3a 00 -> heartbeat heartbeat {
}
config_complete_id reply: 38 ac 9e 04
So the reply to 69420 your firmware must produce is the four bytes 38 ac 9e 04 (field 7, config_complete_id), and to 69421 it is 38 ad 9e 04.
Verify
- In the explorer app, the service
6ba1b218-...-5dcae273eafdshows ToRadio (Write), FromRadio (Read) and FromNum (Notify, Read). Subscribing to FromNum succeeds. - In the Meshtastic app, connect. Your serial log shows a heartbeat,
want_config_id: 69420, your reply, then a heartbeat andwant_config_id: 69421with a reply ending inconfig_complete_id69421. - The app shows your node with its long name as connected and stays connected after you leave it idle for a few minutes.
- Send a text message from the app. The serial log shows a ToRadio write starting
0x0A(field 1,packet), and the bridge forwards it.
Troubleshooting
Each item is marked Documented (from the Meshtastic docs, protobuf comments, or firmware and app source) or Observed (what I saw with the iOS app in April and May 2026; the app has changed since).
- App connects, then never finishes (Observed). It wrote
want_config_id: 69420and waited; my firmware did not reply with a config stream. The app expects the full stream ending inconfig_complete_idwith the same number (Documented in thewant_config_idprotobuf comment). Fix: Step 4. - App connects but never writes to ToRadio (Observed). I had swapped in wrong service and FromNum UUIDs. The app filters discovery by exact UUID, so it found nothing to write to. Fix: copy the UUIDs from
src/BluetoothCommon.h. - “Receiving nodes”, then back to the start, then a drop (Observed). The log showed the app sending
want_config_id: 69421three times while my guard ignored each one as a duplicate. The current app source waits 10 seconds for the first NodeInfo after 69421, retries that step three times, and then waits up to 120 seconds forconfig_complete_id69421 (Documented). Fix: answer 69421 with your NodeInfo, any other nodes, andconfig_complete_id69421. - Works only at one inter-packet delay (Observed). 375 ms and 425 ms failed; 390 ms and 400 ms worked. Nothing in the docs or source sets such a window. My reading is that it comes from pushing FromRadio by notification instead of serving reads (Step 5). Fix: serve FromRadio from reads and drop the delay.
- Connect, “Config sent”, disconnect, repeat (Observed). My config flush blocked for several seconds (a 390 ms delay after each of more than 20 packets), and
ble_flush_pending()inloop()could inject extra packets into the stream. Adding aconfig_in_progressflag checked inble_flush_pending()got connections through, though a first attempt still sometimes dropped mid-flush. The read-driven design removes the blocking loop entirely. - “Attempt to process channel information when no connected device.” (Observed message; cause Documented.) In the current app source this is logged when a Channel arrives before MyNodeInfo, or a Config arrives before your own NodeInfo (with
userset and a matchingnum), and the message is discarded. Sendmy_infoand your ownnode_infofirst, and do not drop packets. AccessoryError Code=9(Observed). The app’s error enum has changed since, and I could not map that code to a case reliably.- Works only after deleting the app and setting Location to “Always Allow” (Observed). The app does request Always permission, but I found nothing that gates the handshake on it, and I did not isolate which action mattered. Stale node records cached by the app are a plausible cause, unconfirmed.
- Handshake fails while another board transmits LoRa (Observed). A test transmitter sending every 3 seconds broke the handshake; unplugging it during connection worked around it. Each received packet went through my bridge path mid-stream, so the interleaving problem above is a likely link, unconfirmed.
- “The radio has deleted its stored pairing information” (Documented). The current app reports this when the device lost a bond the phone still holds, for example after a reflash with PIN pairing on. Forget the device under Settings > Bluetooth and reconnect.
- Weak or flaky BLE link (Observed). A 5 dBi 2.4 GHz dipole on the ESP32 board’s external antenna connector improved reliability a lot. (Adafruit’s antenna version of this board uses w.FL, which is not u.FL.)
Licenses, Trademark and Naming
The firmware, the protobufs and the iOS app are all licensed under the GNU GPL version 3. Copying firmware source into your project brings GPL obligations with it. Whether C code generated from the GPL .proto files makes your firmware a covered work is a question for your own reading of the license or a lawyer. This is not legal advice.
“Meshtastic” is a registered trademark of Meshtastic LLC. The project’s trademark page does not allow the mark in your product’s branding or in domain names, prohibits confusingly similar names, and requires written permission for physical goods. It offers community “M-Powered” logos for compatible projects in good standing under its Code of Conduct, which need no grant and do not imply endorsement. In practice: give your firmware and device their own name (mine is Tamo), describe compatibility in plain words, and check the current policy before you print anything. Questions go to the trademark supervisor listed on that page.
Sources and further reading
- Meshtastic client API docs GATT UUIDs and properties, MTU recommendation, FromNum and read-until-empty model, serial framing; partly out of date.
- meshtastic/protobufs
mesh.proto(ToRadio,FromRadio,Heartbeat),config.proto(PairingMode),channel.proto(PSK shorthand),.optionsfiles, GPL-3.0 license. - meshtastic/firmware
src/BluetoothCommon.h(UUIDs),src/nimble/NimbleBluetooth.cpp(GATT setup, pairing, MTU, FromNum notify),src/mesh/PhoneAPI.cppandPhoneAPI.h(handshake states, special nonces),src/mesh/RadioInterface.h(16-byte LoRa header). - meshtastic/Meshtastic-Apple
AccessoryManager+Connect.swift(connection steps and timeouts),BLEConnection.swift(discovery, subscriptions, read loop),AccessoryManager+FromRadio.swift(ordering checks). - Meshtastic licensing and trademark trademark owner, naming rules, M-Powered logos.
- arduino-esp32 BLE migration guide, v3 to v4 API changes in 4.0.0.
- Espressif: Arduino Bluetooth refactor background on the 4.0 BLE API and backends.
- NimBLE-Arduino migration guide, 2.6.0 moving from the Bluedroid API: callback signatures, automatic CCCD,
getData()removed. - nanopb the C protobuf generator the firmware uses.
- meshtastic/python the
meshtasticpackage with generated Python protobuf classes.