mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Open-source Flutter client for MeshCore LoRa mesh networking devices. Features: - BLE device scanning and connection - Nordic UART Service (NUS) integration - Material 3 design with system theme support - Provider-based state management - Placeholder screens for chat, contacts, and settings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4.4 KiB
4.4 KiB
Repository Guidelines
Project Structure & Module Organization
- Core Flutter code is in
lib/, with BLE protocol definitions inlib/connector/meshcore_protocol.dartand BLE transport/state inlib/connector/meshcore_connector.dart. - UI lives in
lib/screens/andlib/widgets/, models inlib/models/, tests intest/, and platform runners inandroid/,ios/,macos/,linux/,windows/,web/.
BLE Frames & Protocol Notes
- Nordic UART Service (NUS) UUIDs: Service
6e400001-b5a3-f393-e0a9-e50e24dcca9e, RX6e400002-b5a3-f393-e0a9-e50e24dcca9e, TX6e400003-b5a3-f393-e0a9-e50e24dcca9e. - Discovery: scans for device name prefix
MeshCore-and filters byplatformName/advertisementData.advName. - Frames are capped at
maxFrameSize = 172bytes; byte 0 is the command/response/push code. I/O isMeshCoreConnector.sendFrameandMeshCoreConnector.receivedFrames. - Command codes (to device):
cmdAppStart=1,cmdSendTxtMsg=2,cmdSendChannelTxtMsg=3,cmdGetContacts=4,cmdGetDeviceTime=5,cmdSetDeviceTime=6,cmdSendSelfAdvert=7,cmdSetAdvertName=8,cmdAddUpdateContact=9,cmdSyncNextMessage=10,cmdSetRadioParams=11,cmdSetRadioTxPower=12,cmdResetPath=13,cmdSetAdvertLatLon=14,cmdRemoveContact=15,cmdShareContact=16,cmdExportContact=17,cmdImportContact=18,cmdReboot=19,cmdSendLogin=26,cmdGetChannel=31,cmdSetChannel=32,cmdGetRadioSettings=57. - Response codes (from device):
respCodeOk=0,respCodeErr=1,respCodeContactsStart=2,respCodeContact=3,respCodeEndOfContacts=4,respCodeSelfInfo=5,respCodeSent=6,respCodeContactMsgRecv=7,respCodeChannelMsgRecv=8,respCodeCurrTime=9,respCodeNoMoreMessages=10,respCodeContactMsgRecvV3=16,respCodeChannelMsgRecvV3=17,respCodeChannelInfo=18,respCodeRadioSettings=25. - Push codes (async):
pushCodeAdvert=0x80,pushCodePathUpdated=0x81,pushCodeSendConfirmed=0x82,pushCodeMsgWaiting=0x83,pushCodeLoginSuccess=0x85,pushCodeLoginFail=0x86,pushCodeLogRxData=0x88,pushCodeNewAdvert=0x8A. - Device info:
cmdAppStarttriggersrespCodeSelfInfowith tx power, pubkey, lat/lon, telemetry flags, radio params, and node name (see offsets inlib/connector/meshcore_connector.dart). - Radio/time helpers:
cmdGetRadioSettings→respCodeRadioSettings;cmdGetDeviceTime→respCodeCurrTime;cmdSetDeviceTimeupdates device time. - Reboot: the UI sends
sendCliCommand('reboot')(the rawcmdRebootcode exists but no frame builder is wired in yet). - Companion radio format:
cmdSendTxtMsgexpects[cmd][txt_type][attempt][timestamp x4][pub_key_prefix x6][text...](no flags/full pubkey). CLI commands usetxtTypeCliDatain the same format, and the app mapsforceFloodto attempt3when sending. - Group text packets (
PAYLOAD_TYPE_GRP_TXT): payload is[channel_hash (1)][MAC (2)][encrypted data...]. Decrypted data layout is[timestamp x4][txt_type][text...]where text is"sender: message"(see MeshCoreBaseChatMesh::sendGroupMessage). Sender identity is not in the payload; usePUSH_CODE_LOG_RX_DATAraw packet path bytes for origin hash when available. - Identity hash:
PATH_HASH_SIZEis 1 byte; it is the prefix of the public key (seeIdentity::copyHashTo). Flooded packets append this hash to the path as they traverse hops. Self-identification via log data should compare sender name and presence of self pubkey prefix within the path bytes.
Build, Test, and Development Commands
~/flutter/bin/flutter pub getinstalls dependencies (orflutter pub getif Flutter is on PATH).~/flutter/bin/flutter runlaunches the app;~/flutter/bin/flutter build apk|iosproduces release builds.~/flutter/bin/flutter analyzeand~/flutter/bin/flutter testrun linting and tests.
Coding Style & Naming Conventions
- Follow
flutter_lints, uselowerCamelCase/UpperCamelCase/snake_case, preferStatelessWidget+Consumer, and useconstconstructors. - Material widgets only; keep screens simple, handle disconnects by returning to the scanner, and avoid premature abstractions.
Testing Guidelines
- Tests use
flutter_test; add*_test.dartundertest/and runflutter testbefore UI/protocol changes.
Commit & Pull Request Guidelines
- Keep commit subjects short and action-focused; PRs should describe behavior changes, link issues, include screenshots for UI changes, and call out BLE protocol changes explicitly.