Mocktastic:Arduino 上的 Meshtastic 节点
Mocktastic: A Meshtastic Node on Arduino

原始链接: https://github.com/Vapmuz/Mocktastic

Mocktastic 是一个小型的、教育性质的 Meshtastic 兼容 LoRa 客户端,适用于 ESP32 开发板,已在配备 SX1276 无线电的 LilyGO T3 LoRa32 V1.6.1 上测试。它演示了在 C++ 中构建和解码 Meshtastic 数据包,并包含一个 DHT22 环境传感器示例。它支持两种编译时模式:DECODER 提供交互式串口 shell,用于在配置的频道上接收、解码和发送文本或直接消息;而 SENSOR 将开发板变为温湿度传感器,可发送测量数据并在私有频道上响应 `/dht` 消息。该项目使用 mbedTLS 和 Nano-Protobuf,并使用基于 Doctest 的主机测试来验证平台无关逻辑。设置需要在 `keys.h` 中配置 LoRa 引脚、无线电频率/预设以及频道/节点密钥。它旨在用于学习和原型开发,而非生产或安全关键用途;必须验证无线电法规和硬件行为。

Hacker News 最新 | 历史 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Mocktastic:Arduino 上的 Meshtastic 节点 ( github.com/vapmuz ) 28 分 由 kimi 11 小时前 | 隐藏 | 历史 | 收藏 | 1 条评论 帮助 croes 8 小时前 [–] 还有 ESP32 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

The sketch selects its mode at compile time. Near the top of meshtastic_decoder/meshtastic_decoder.ino, keep DECODER defined for the serial shell, or replace it with SENSOR for the DHT22 sensor variant:

For the sensor build, replace that line with:

Build and upload the sketch with Arduino IDE for your selected ESP32 board.

The DECODER variant is operated over the serial connection. Open the serial monitor at 115200 baud. Its commands are:

Command Description

/echo <text>

Print text to the serial console.

/pub <text>

Send a Meshtastic packet on the public channel.

/cantine <text>

Send a Meshtastic packet on the private channel.

/admn <text>

Send a private direct message to ADMIN.

/r

Repeat the previous command.

/rssi

Show the current LoRa RSSI.

/pwr17 <value>

Set LoRa transmit power.

/gain <value>

Set LoRa gain.

/help

Show the command help.

/send_key

Start direct messaging by sending this node’s public key.

/raw <text>

Send a prepared packet for testing.

For example, send /pub 42 is the answer to write on the public channel. To send hello, world! on the private channel, use /cantine hello, world!.

To enable direct messages with Admn, first send /send_key. This sends this node’s public key so that the official Meshtastic node can establish a private conversation. Then send a direct message with /admn hello, world!.

The SENSOR variant has no interactive shell. It can only be controlled by sending a Meshtastic message on the private channel configured in keys.h. Send /dht on that channel to make the sensor measure temperature and humidity; it sends the result back as a text message on the same channel.

Connect the DHT22 data pin to GPIO 21. A battery is also required for standalone operation.

Keep protocol and parsing logic separate from hardware effects where possible. The portable logic is exercised by host-side tests, while the .ino sketch handles radio, serial, GPIO, and sensor interactions.

For a new shell command, follow the existing pattern in meshtastic_decoder/lora_shell.h and meshtastic_decoder/lora_shell.cpp: add the command to the parser and command enum, then handle it in the dispatcher in meshtastic_decoder/meshtastic_decoder.ino. For higher-level packet operations, start with the functions in lora_shell and the interfaces in meshtastic.h; use functions.h for lower-level helpers.

Run make test from meshtastic_decoder/ after changing platform-independent logic. Hardware behavior still needs to be verified on the target board and against compatible Meshtastic nodes.

This code is a learning and prototyping project. It has limited field testing, does not provide the reliability or power efficiency of the official Meshtastic firmware, and is not recommended for safety-critical or production use. Its SENSOR battery life, channel handling, and regional radio configuration may need further work for a particular application.

联系我们 contact @ memedata.com