mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 14:55:46 +00:00
Compare commits
90 Commits
companion-
...
room-serve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4449fd3a24 | ||
|
|
0bad7ee106 | ||
|
|
cf9861e683 | ||
|
|
5cb2ba8c62 | ||
|
|
900de5befe | ||
|
|
72d2b05664 | ||
|
|
f8b45ec01e | ||
|
|
0defa837d8 | ||
|
|
3b41d863c8 | ||
|
|
5987e95ce9 | ||
|
|
7dc8a52784 | ||
|
|
fe8db0f9ff | ||
|
|
4fc0a67e58 | ||
|
|
5630533d22 | ||
|
|
400c4353dc | ||
|
|
efa2b4b1b7 | ||
|
|
23f54dd924 | ||
|
|
a2ff22dffb | ||
|
|
22b80a9be7 | ||
|
|
c7fe211840 | ||
|
|
f9473235c6 | ||
|
|
8ecb5def87 | ||
|
|
a466d3cf80 | ||
|
|
02b6f4a285 | ||
|
|
c4df0ed1c5 | ||
|
|
5a0ac2a031 | ||
|
|
375a31a436 | ||
|
|
af0d55548c | ||
|
|
98d94d9423 | ||
|
|
a29b099150 | ||
|
|
7839cb29a1 | ||
|
|
1c8aaebb90 | ||
|
|
009173ab9e | ||
|
|
726273f548 | ||
|
|
036caaba86 | ||
|
|
9a0b6e5326 | ||
|
|
16a283ac5b | ||
|
|
e14ea72699 | ||
|
|
d42c3f91a2 | ||
|
|
3dff284db6 | ||
|
|
d9c1cffac2 | ||
|
|
ecfeb2ff63 | ||
|
|
7507f889a5 | ||
|
|
f82844f43f | ||
|
|
56b84408e4 | ||
|
|
e5376f0c0a | ||
|
|
c31c48025a | ||
|
|
7e90d386e2 | ||
|
|
4a60548b7d | ||
|
|
be88bea42d | ||
|
|
b202580ae2 | ||
|
|
43f09f302c | ||
|
|
4a90042b08 | ||
|
|
5d9e7b4567 | ||
|
|
3cf78a952b | ||
|
|
a950343f05 | ||
|
|
8a27743e43 | ||
|
|
f9c0056955 | ||
|
|
5d0a8d9d7c | ||
|
|
d5eb83a921 | ||
|
|
fa0456549a | ||
|
|
a73eb9823d | ||
|
|
bc4e0b52fa | ||
|
|
519ebb549b | ||
|
|
4e70bc5af8 | ||
|
|
54c3f019b8 | ||
|
|
d4e6ece75d | ||
|
|
a79e9a79e0 | ||
|
|
a155587b7f | ||
|
|
b59606d5b5 | ||
|
|
ee41d6e2d3 | ||
|
|
7e14fb3f65 | ||
|
|
9048142f63 | ||
|
|
37ee90b20f | ||
|
|
86d1c80704 | ||
|
|
69a70c4f71 | ||
|
|
bb5650a998 | ||
|
|
aa272ecc0c | ||
|
|
2f5cc94d04 | ||
|
|
885cfe9667 | ||
|
|
d13ff7ea84 | ||
|
|
8f1afbbe58 | ||
|
|
4196fd4ab7 | ||
|
|
25b534a29d | ||
|
|
e5925e5f41 | ||
|
|
22ee164ff6 | ||
|
|
14ffde567a | ||
|
|
f1df9f7c3b | ||
|
|
e7872fb4d3 | ||
|
|
faf043327d |
61
README.md
61
README.md
@@ -25,18 +25,52 @@ MeshCore provides the ability to create wireless mesh networks, similar to Mesht
|
||||
|
||||
## 🚀 How to Get Started
|
||||
|
||||
Andy Kirby has published a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) which explains the steps for beginners.
|
||||
- Watch the [MeshCore Intro Video](https://www.youtube.com/watch?v=t1qne8uJBAc) by Andy Kirby.
|
||||
- Read through our [Frequently Asked Questions](./docs/faq.md) section.
|
||||
- Flash the MeshCore firmware on a supported device.
|
||||
- Connect with a supported client.
|
||||
|
||||
For developers, install [PlatformIO](https://docs.platformio.org) in Visual Studio Code.
|
||||
Download & Open the MeshCore repository.
|
||||
Select a Sample Application: Choose from chat, repeater, other example app.
|
||||
Monitor & Communicate using the Serial Monitor (e.g., Serial USB Terminal on Android).
|
||||
For developers;
|
||||
|
||||
📁 Included Example Applications
|
||||
* 📡 Terminal Chat: Secure text communication between devices.
|
||||
* 📡 Simple Repeater: Extends network coverage by relaying messages.
|
||||
* 📡 Companion Radio: For use with an external chat app, over BLE or USB.
|
||||
* 📡 Room Server: A simple BBS server for shared Posts.
|
||||
- Install [PlatformIO](https://docs.platformio.org) in [Visual Studio Code](https://code.visualstudio.com).
|
||||
- Clone and open the MeshCore repository in Visual Studio Code.
|
||||
- See the example applications you can modify and run:
|
||||
- [Companion Radio](./examples/companion_radio) - For use with an external chat app, over BLE, USB or WiFi.
|
||||
- [Simple Repeater](./examples/simple_repeater) - Extends network coverage by relaying messages.
|
||||
- [Simple Room Server](./examples/simple_room_server) - A simple BBS server for shared Posts.
|
||||
- [Simple Secure Chat](./examples/simple_secure_chat) - Secure terminal based text communication between devices.
|
||||
|
||||
The Simple Secure Chat example can be interacted with through the Serial Monitor in Visual Studio Code, or with a Serial USB Terminal on Android.
|
||||
|
||||
## ⚡️ MeshCore Flasher
|
||||
|
||||
We have prebuilt firmware ready to flash on supported devices.
|
||||
|
||||
- Launch https://flasher.meshcore.co.uk
|
||||
- Select a supported device
|
||||
- Flash one of the firmware types:
|
||||
- Companion, Repeater or Room Server
|
||||
- Once flashing is complete, you can connect with one of the MeshCore clients below.
|
||||
|
||||
## 📱 MeshCore Clients
|
||||
|
||||
**Companion Firmware**
|
||||
|
||||
The companion firmware can be connected to via BLE, USB or WiFi depending on the firmware type you flashed.
|
||||
|
||||
- Web: https://app.meshcore.nz
|
||||
- Android: https://play.google.com/store/apps/details?id=com.liamcottle.meshcore.android
|
||||
- iOS: https://apps.apple.com/us/app/meshcore/id6742354151?platform=iphone
|
||||
- NodeJS: https://github.com/liamcottle/meshcore.js
|
||||
- Python: https://github.com/fdlamotte/meshcore-cli
|
||||
|
||||
**Repeater and Room Server Firmware**
|
||||
|
||||
The repeater and room server firmwares can be setup via USB in the web config tool.
|
||||
|
||||
- https://config.meshcore.dev
|
||||
|
||||
They can also be managed via LoRa in the mobile app by using the Remote Management feature.
|
||||
|
||||
## 🛠 Hardware Compatibility
|
||||
|
||||
@@ -53,6 +87,7 @@ MeshCore is designed for use with:
|
||||
* LilyGo TLora32 v1.6
|
||||
|
||||
## 📜 License
|
||||
|
||||
MeshCore is open-source software released under the MIT License. You are free to use, modify, and distribute it for personal and commercial projects.
|
||||
|
||||
## Contributing
|
||||
@@ -62,9 +97,9 @@ For minor changes just submit your PR and I'll try to review it, but for anythin
|
||||
|
||||
## 📞 Get Support
|
||||
|
||||
Check out the GitHub Issues page to report bugs or request features.
|
||||
|
||||
You will be able to find additional guides and components at [my site](https://buymeacoffee.com/ripplebiz), or [join Andy Kirby's Discord](https://discord.gg/GBxVx2JMAy) for discussions.
|
||||
- Report bugs and request features on the [GitHub Issues](https://github.com/ripplebiz/MeshCore/issues) page.
|
||||
- Find additional guides and components on [my site](https://buymeacoffee.com/ripplebiz).
|
||||
- Join [Andy Kirby's Discord](https://discord.gg/GBxVx2JMAy) to chat with the developers and get help from the community.
|
||||
|
||||
## RAK Wireless Board Support in PlatformIO
|
||||
|
||||
|
||||
72
boards/nano-g2-ultra.json
Normal file
72
boards/nano-g2-ultra.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "nrf52840_s140_v6.ld"
|
||||
},
|
||||
"core": "nRF5",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
|
||||
"f_cpu": "64000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x239A",
|
||||
"0x8029"
|
||||
],
|
||||
[
|
||||
"0x239A",
|
||||
"0x0029"
|
||||
],
|
||||
[
|
||||
"0x239A",
|
||||
"0x002A"
|
||||
],
|
||||
[
|
||||
"0x239A",
|
||||
"0x802A"
|
||||
]
|
||||
],
|
||||
"usb_product": "BQ nRF52840",
|
||||
"mcu": "nrf52840",
|
||||
"variant": "nano-g2-ultra",
|
||||
"bsp": {
|
||||
"name": "adafruit"
|
||||
},
|
||||
"softdevice": {
|
||||
"sd_flags": "-DS140",
|
||||
"sd_name": "s140",
|
||||
"sd_version": "6.1.1",
|
||||
"sd_fwid": "0x00B6"
|
||||
},
|
||||
"bootloader": {
|
||||
"settings_addr": "0xFF000"
|
||||
}
|
||||
},
|
||||
"connectivity": [
|
||||
"bluetooth"
|
||||
],
|
||||
"debug": {
|
||||
"jlink_device": "nRF52840_xxAA",
|
||||
"svd_path": "nrf52840.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino"
|
||||
],
|
||||
"name": "BQ nRF52840",
|
||||
"upload": {
|
||||
"maximum_ram_size": 248832,
|
||||
"maximum_size": 815104,
|
||||
"speed": 115200,
|
||||
"protocol": "nrfutil",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"nrfjprog",
|
||||
"nrfutil",
|
||||
"stlink"
|
||||
],
|
||||
"use_1200bps_touch": true,
|
||||
"require_upload_port": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://wiki.uniteng.com/en/meshtastic/nano-g2-ultra",
|
||||
"vendor": "BQ Consulting"
|
||||
}
|
||||
33
boards/rak3172.json
Normal file
33
boards/rak3172.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"variant_h": "variant_RAK3172_MODULE.h"
|
||||
},
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32WL -DSTM32WLxx -DSTM32WLE5xx",
|
||||
"framework_extra_flags": {
|
||||
"arduino": "-DUSE_CM4_STARTUP_FILE -DARDUINO_RAK3172_MODULE"
|
||||
},
|
||||
"f_cpu": "48000000L",
|
||||
"mcu": "stm32wle5ccu",
|
||||
"product_line": "STM32WLE5xx",
|
||||
"variant": "STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": ["stlink"],
|
||||
"jlink_device": "STM32WLE5CC",
|
||||
"openocd_target": "stm32wlx",
|
||||
"svd_path": "STM32WLE5_CM4.svd"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "BB-STM32WL",
|
||||
"upload": {
|
||||
"maximum_ram_size": 65536,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "stlink",
|
||||
"protocols": ["stlink", "jlink"]
|
||||
},
|
||||
"url": "https://store.rakwireless.com/products/wisduo-lpwan-module-rak3172",
|
||||
"vendor": "RAK"
|
||||
}
|
||||
388
docs/faq.md
388
docs/faq.md
@@ -1,13 +1,75 @@
|
||||
# MeshCore-FAQ
|
||||
**MeshCore-FAQ**<!-- omit from toc -->
|
||||
A list of frequently-asked questions and answers for MeshCore
|
||||
|
||||
The current version of this MeshCore FAQ is at https://github.com/ripplebiz/MeshCore/blob/main/docs/faq.md.
|
||||
This MeshCore FAQ is also mirrored at https://github.com/LitBomb/MeshCore-FAQ and might have newer updates if pull requests on Scott's MeshCore repo are not approved yet.
|
||||
|
||||
author: https://github.com/LitBomb
|
||||
author: https://github.com/LitBomb<!-- omit from toc -->
|
||||
---
|
||||
|
||||
## Q: What is MeshCore?
|
||||
- [1. Introduction](#1-introduction)
|
||||
- [1.1. Q: What is MeshCore?](#11-q-what-is-meshcore)
|
||||
- [1.2. Q: What do you need to start using MeshCore?](#12-q-what-do-you-need-to-start-using-meshcore)
|
||||
- [1.2.1. Hardware](#121-hardware)
|
||||
- [1.2.2. Firmware](#122-firmware)
|
||||
- [1.2.3. Companion Radio Firmware](#123-companion-radio-firmware)
|
||||
- [1.2.4. Repeater](#124-repeater)
|
||||
- [1.2.5. Room Server](#125-room-server)
|
||||
- [2. Initial Setup](#2-initial-setup)
|
||||
- [2.1. Q: How many devices do I need to start using MeshCore?](#21-q-how-many-devices-do-i-need-to-start-using-meshcore)
|
||||
- [2.2. Q: Does MeshCore cost any money?](#22-q-does-meshcore-cost-any-money)
|
||||
- [2.3. Q: What frequencies are supported by MeshCore?](#23-q-what-frequencies-are-supported-by-meshcore)
|
||||
- [2.4. Q: What is an "advert" in MeshCore?](#24-q-what-is-an-advert-in-meshcore)
|
||||
- [2.5. Q: Is there a hop limit?](#25-q-is-there-a-hop-limit)
|
||||
- [3. Server Administration](#3-server-administration)
|
||||
- [3.1. Q: How do you configure a repeater or a room server?](#31-q-how-do-you-configure-a-repeater-or-a-room-server)
|
||||
- [3.2. Q: Do I need to set the location for a repeater?](#32-q-do-i-need-to-set-the-location-for-a-repeater)
|
||||
- [3.3. Q: What is the password to administer a repeater or a room server?](#33-q-what-is-the-password-to-administer-a-repeater-or-a-room-server)
|
||||
- [3.4. Q: What is the password to join a room server?](#34-q-what-is-the-password-to-join-a-room-server)
|
||||
- [4. T-Deck Related](#4-t-deck-related)
|
||||
- [4.1. Q: What are the steps to get a T-Deck into DFU (Device Firmware Update) mode?](#41-q-what-are-the-steps-to-get-a-t-deck-into-dfu-device-firmware-update-mode)
|
||||
- [4.2. Q: Why is my T-Deck Plus not getting any satellite lock?](#42-q-why-is-my-t-deck-plus-not-getting-any-satellite-lock)
|
||||
- [4.3. Q: Why is my OG (non-Plus) T-Deck not getting any satellite lock?](#43-q-why-is-my-og-non-plus-t-deck-not-getting-any-satellite-lock)
|
||||
- [4.4. Q: What size of SD card does the T-Deck support?](#44-q-what-size-of-sd-card-does-the-t-deck-support)
|
||||
- [4.5. Q: How do I get maps on T-Deck?](#45-q-how-do-i-get-maps-on-t-deck)
|
||||
- [4.6. Q: Where do the map tiles go?](#46-q-where-do-the-map-tiles-go)
|
||||
- [4.7. Q: How to unlock deeper map zoom and server management features on T-Deck?](#47-q-how-to-unlock-deeper-map-zoom-and-server-management-features-on-t-deck)
|
||||
- [4.8. Q: How to decipher the diagnostics screen on T-Deck?](#48-q-how-to-decipher-the-diagnostics-screen-on-t-deck)
|
||||
- [4.9. Q: The T-Deck sound is too loud?](#49-q-the-t-deck-sound-is-too-loud)
|
||||
- [4.10. Q: Can you customize the sound?](#410-q-can-you-customize-the-sound)
|
||||
- [4.11. Q: What is the 'Import from Clipboard' feature on the t-deck and is there a way to manually add nodes without having to receive adverts?](#411-q-what-is-the-import-from-clipboard-feature-on-the-t-deck-and-is-there-a-way-to-manually-add-nodes-without-having-to-receive-adverts)
|
||||
- [5. General](#5-general)
|
||||
- [5.1. Q: What are BW, SF, and CR?](#51-q-what-are-bw-sf-and-cr)
|
||||
- [5.2. Q: Do MeshCore clients repeat?](#52-q-do-meshcore-clients-repeat)
|
||||
- [5.3. Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone?](#53-q-what-happens-when-a-node-learns-a-route-via-a-mobile-repeater-and-that-repeater-is-gone)
|
||||
- [5.4. Q: How does a node discovery a path to its destination and then use it to send messages in the future, instead of flooding every message it sends like Meshtastic?](#54-q-how-does-a-node-discovery-a-path-to-its-destination-and-then-use-it-to-send-messages-in-the-future-instead-of-flooding-every-message-it-sends-like-meshtastic)
|
||||
- [5.5. Q: Do public channels always flood? Do private channels always flood?](#55-q-do-public-channels-always-flood-do-private-channels-always-flood)
|
||||
- [5.6. Q: what is the public key for the default public channel?](#56-q-what-is-the-public-key-for-the-default-public-channel)
|
||||
- [5.7. Q: Is MeshCore open source?](#57-q-is-meshcore-open-source)
|
||||
- [5.8. Q: How can I support MeshCore?](#58-q-how-can-i-support-meshcore)
|
||||
- [5.9. Q: How do I build MeshCore firmware from source?](#59-q-how-do-i-build-meshcore-firmware-from-source)
|
||||
- [5.10. Q: Are there other MeshCore related open source projects?](#510-q-are-there-other-meshcore-related-open-source-projects)
|
||||
- [5.11. Q: Does MeshCore support ATAK](#511-q-does-meshcore-support-atak)
|
||||
- [5.12. Q: How do I add a node to the MeshCore Map](#512-q-how-do-i-add-a-node-to-the-meshcore-map)
|
||||
- [5.13. Q: Can I use a Raspberry Pi to update a MeshCore radio?](#513-q-can-i-use-a-raspberry-pi-to-update-a-meshcore-radio)
|
||||
- [5.14. Q: Are there are projects built around MeshCore?](#514-q-are-there-are-projects-built-around-meshcore)
|
||||
- [5.14.1. meshcoremqtt](#5141-meshcoremqtt)
|
||||
- [5.14.2. MeshCore for Home Assistant](#5142-meshcore-for-home-assistant)
|
||||
- [5.14.3. Python MeshCore](#5143-python-meshcore)
|
||||
- [5.14.4. meshcore-cli](#5144-meshcore-cli)
|
||||
- [5.14.5. meshcore.js](#5145-meshcorejs)
|
||||
- [6. Troubleshooting](#6-troubleshooting)
|
||||
- [6.1. Q: My client says another client or a repeater or a room server was last seen many, many days ago.](#61-q-my-client-says-another-client-or-a-repeater-or-a-room-server-was-last-seen-many-many-days-ago)
|
||||
- [6.2. Q: A repeater or a client or a room server I expect to see on my discover list (on T-Deck) or contact list (on a smart device client) are not listed.](#62-q-a-repeater-or-a-client-or-a-room-server-i-expect-to-see-on-my-discover-list-on-t-deck-or-contact-list-on-a-smart-device-client-are-not-listed)
|
||||
- [6.3. Q: How to connect to a repeater via BLE (Bluetooth)?](#63-q-how-to-connect-to-a-repeater-via-ble-bluetooth)
|
||||
- [6.4. Q: I can't connect via Bluetooth, what is the Bluetooth pairing code?](#64-q-i-cant-connect-via-bluetooth-what-is-the-bluetooth-pairing-code)
|
||||
- [6.5. Q: My Heltec V3 keeps disconnecting from my smartphone. It can't hold a solid Bluetooth connection.](#65-q-my-heltec-v3-keeps-disconnecting-from-my-smartphone--it-cant-hold-a-solid-bluetooth-connection)
|
||||
- [7. Other Questions:](#7-other-questions)
|
||||
- [7.1. Q: How to Update repeater and room server firmware over the air?](#71-q-how-to--update-repeater-and-room-server-firmware-over-the-air)
|
||||
|
||||
## 1. Introduction
|
||||
|
||||
### 1.1. Q: What is MeshCore?
|
||||
|
||||
**A:** MeshCore is free and open source
|
||||
* MeshCore is the routing and firmware etc, available on GitHub under MIT license
|
||||
@@ -22,27 +84,27 @@ These features are completely optional and aren't needed for the core messaging
|
||||
|
||||
Anyone is able to build anything they like on top of MeshCore without paying anything.
|
||||
|
||||
## Q: What do you need to start using MeshCore?
|
||||
### 1.2. Q: What do you need to start using MeshCore?
|
||||
**A:** Everything you need for MeshCore is available at:
|
||||
Main web site: [https://meshcore.co.uk/](https://meshcore.co.uk/)
|
||||
Firmware Flasher: https://flasher.meshcore.co.uk/
|
||||
Phone Client Applications: https://meshcore.co.uk/apps.html
|
||||
MeshCore Fimrware Github: https://github.com/ripplebiz/MeshCore
|
||||
MeshCore Fimrware GitHub: https://github.com/ripplebiz/MeshCore
|
||||
|
||||
NOTE: Andy Kirby has a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) for beginners.
|
||||
|
||||
|
||||
You need LoRa hardware devices to run MeshCore firmware as clients or server (repeater and room server).
|
||||
|
||||
### Hardware
|
||||
#### 1.2.1. Hardware
|
||||
To use MeshCore without using a phone as the client interface, you can run MeshCore on a T-Deck or T-Deck Plus. It is a complete off-grid secure communication solution.
|
||||
|
||||
MeshCore is also available on a variety of 868MHz and 915MHz LoRa devices. For example, RAK4631 devices (19003, 19007, 19026), Heltec V3, Xiao S3 WIO, Xiao C3, Heltec T114, Station G2, Seeed Studio T1000-E. More devices will be supported later.
|
||||
|
||||
### Firmware
|
||||
#### 1.2.2. Firmware
|
||||
MeshCore has four firmware types that are not available on other LoRa systems. MeshCore has the following:
|
||||
|
||||
#### Companion Radio Firmware
|
||||
#### 1.2.3. Companion Radio Firmware
|
||||
Companion radios are for connecting to the Android app or web app as a messenger client. There are two different companion radio firmware versions:
|
||||
|
||||
1. **BLE Companion**
|
||||
@@ -54,19 +116,19 @@ Companion radios are for connecting to the Android app or web app as a messenger
|
||||
<https://meshcore.liamcottle.net/#/>
|
||||
<https://client.meshcore.co.uk/tabs/devices>
|
||||
|
||||
#### Repeater
|
||||
#### 1.2.4. Repeater
|
||||
Repeaters are used to extend the range of a MeshCore network. Repeater firmware runs on the same devices that run client firmware. A repeater's job is to forward MeshCore packets to the destination device. It does **not** forward or retransmit every packet it receives, unlike other LoRa mesh systems.
|
||||
|
||||
A repeater can be remotely administered using a T-Deck running the MeshCore firwmware with remote admistration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
|
||||
A repeater can be remotely administered using a T-Deck running the MeshCore firmware with remote administration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
|
||||
|
||||
#### Room Server
|
||||
#### 1.2.5. Room Server
|
||||
A room server is a simple BBS server for sharing posts. T-Deck devices running MeshCore firmware or a BLE Companion client connected to a smartphone running the MeshCore app can connect to a room server.
|
||||
|
||||
room servers store message history on them, and push the stored messages to users. Room servers allow roaming users to come back later and retrieve message history. Contrast to channels, messages are either received when it's sent, or not received and missed if the a room user is out of range. You can think of room servers like email servers where you can come back later and get your emails from your mail server
|
||||
Room servers store message history on them and push the stored messages to users. Room servers allow roaming users to come back later and retrieve message history. With channels, messages are either received when it's sent, or not received and missed if the channel user is out of range. Room servers are different and more like email servers where you can come back later and get your emails from your mail server.
|
||||
|
||||
A room server can be remotely administered using a T-Deck running the MeshCore firwmware with remote admistration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
|
||||
A room server can be remotely administered using a T-Deck running the MeshCore firmware with remote administration features unlocked, or from a BLE Companion client connected to a smartphone running the MeshCore app.
|
||||
|
||||
When a client logs into a room server, the client will receive the previously 16 unseen messages.
|
||||
When a client logs into a room server, the client will receive the previously 32 unseen messages.
|
||||
|
||||
A room server can also take on the repeater role. To enable repeater role on a room server, use this command:
|
||||
|
||||
@@ -74,58 +136,64 @@ A room server can also take on the repeater role. To enable repeater role on a
|
||||
|
||||
---
|
||||
|
||||
## Initial Setup
|
||||
## 2. Initial Setup
|
||||
|
||||
### Q: How many devices do I need to start using meshcore?
|
||||
**A:** If you have one supported device, flash the BLE Companion firmware and use your device as a client. You can connect to the device using the Android client via bluetooth (iOS client will be available later). You can start communiating with other MeshCore users near you.
|
||||
### 2.1. Q: How many devices do I need to start using MeshCore?
|
||||
**A:** If you have one supported device, flash the BLE Companion firmware and use your device as a client. You can connect to the device using the Android client via Bluetooth (iOS client will be available later). You can start communicating with other MeshCore users near you.
|
||||
|
||||
If you have two supported devices, and there are not many MeshCore users near you, flash both of them to BLE Companion firmware so you can use your devices to communiate with your near-by friends and family.
|
||||
If you have two supported devices, and there are not many MeshCore users near you, flash both to BLE Companion firmware so you can use your devices to communicate with your near-by friends and family.
|
||||
|
||||
If you have two supported devices, and there are other MeshcCore users near by, you can flash one of your devices with BLE Companion firmware, and flash another supported device to repeater firmware. Place the repeater high above ground o extend your MeshCore network's reach.
|
||||
If you have two supported devices, and there are other MeshcCore users nearby, you can flash one of your devices with BLE Companion firmware and flash another supported device to repeater firmware. Place the repeater high above ground to extend your MeshCore network's reach.
|
||||
|
||||
After you flashed the latest firmware onto your repeater device, keep the device connected to your computer via USB serial, use the console feature on the web flasher and set the frequency for your region or country, so your client can remote administer the rpeater or room server over RF:
|
||||
After you flashed the latest firmware onto your repeater device, keep the device connected to your computer via USB serial, use the console feature on the web flasher and set the frequency for your region or country, so your client can remote administer the repeater or room server over RF:
|
||||
|
||||
`set freq {frequency}`
|
||||
|
||||
The repeater and room server CLI reference is here: https://github.com/ripplebiz/MeshCore/wiki/Repeater-&-Room-Server-CLI-Reference
|
||||
|
||||
If you have more supported devices, you can use your additional deivces with the room server firmware.
|
||||
If you have more supported devices, you can use your additional devices with the room server firmware.
|
||||
|
||||
### Q: Does MeshCore cost any money?
|
||||
### 2.2. Q: Does MeshCore cost any money?
|
||||
|
||||
**A:** All radio firmware versions (e.g. for Heltec V3, RAK, T-1000E, etc) are free and open source developed by Scott at Ripple Radios.
|
||||
|
||||
The native Android and iOS client uses the freemium model and is developed by Liam Cottle, developer of meshtastic map at [meshtastic.liamcottle.net](https://meshtastic.liamcottle.net) on [github ](https://github.com/liamcottle/meshtastic-map)and [reticulum-meshchat on github](https://github.com/liamcottle/reticulum-meshchat).
|
||||
The native Android and iOS client uses the freemium model and is developed by Liam Cottle, developer of meshtastic map at [meshtastic.liamcottle.net](https://meshtastic.liamcottle.net) on [GitHub](https://github.com/liamcottle/meshtastic-map) and [reticulum-meshchat on github](https://github.com/liamcottle/reticulum-meshchat).
|
||||
|
||||
The T-Deck firmware is free to download and most features are available without cost. To support the firmware developer, you can pay for a registration key to unlock your T-Deck for deeper map zoom and remote server administration over RF using the T-Deck. You do not need to pay for the registration to use your T-Deck for direct messaging and connecting to repeaters and room servers.
|
||||
|
||||
|
||||
### Q: What frequencies are supported by MeshCore?
|
||||
### 2.3. Q: What frequencies are supported by MeshCore?
|
||||
**A:** It supports the 868MHz range in the UK/EU and the 915MHz range in New Zealand, Australia, and the USA. Countries and regions in these two frequency ranges are also supported. The firmware and client allow users to set their preferred frequency.
|
||||
- Australia and New Zealand are on **915.8MHz**
|
||||
- UK and EU are on **869.525MHz**
|
||||
- Canada and USA are on **910.525MHz**
|
||||
- For other regions and countries, please check your local LoRa frequency
|
||||
|
||||
In UK and EU, 867.5MHz is not allowed to use 250kHz bandwidth and it only allows 2.5% duty cycle for clients. 869.525Mhz allows an airtime of 10%, 250KHz bandwidth, and a higher EIRP, therefore MeshCore nodes can send more often and with more power. That is why this frequency is chosen for UK and EU. This is also why Meshtastic also uses this frequency.
|
||||
|
||||
[Source]([https://](https://discord.com/channels/826570251612323860/1330643963501351004/1356540643853209641))
|
||||
|
||||
the rest of the radio settings are the same for all frequencies:
|
||||
- Spread Factor (SF): 10
|
||||
- Spread Factor (SF): 11
|
||||
- Coding Rate (CR): 5
|
||||
- Bandwidth (BW): 250.00
|
||||
|
||||
### Q: What is an "advert" in MeshCore?
|
||||
(Originally MeshCore started with SF 10. recently (as of late April 2025) the community has advocated SF 11 also a viable option for longer range but a little slower transmission. Currently there are MeshCore meshes with SF 10 and SF 11. Liam Cottle's smartphone app's presets now recommend SF 10 for Australia and SF 11 for all other regions and countries. EU and UK has SF 10 and SF 11 presets. Work with your local meshers on deciding with SF number is best for your use cases. In the future, there may be bridge nodes that can bridge SF 10 and SF 11 (or even different frequencies) traffic.)
|
||||
|
||||
### 2.4. Q: What is an "advert" in MeshCore?
|
||||
**A:**
|
||||
Advert means to advertise yourself on the network. In Reticulum terms it would be to announce. In Meshtastic terms it would be the node sending it's node info.
|
||||
Advert means to advertise yourself on the network. In Reticulum terms it would be to announce. In Meshtastic terms it would be the node sending its node info.
|
||||
|
||||
MeshCore allows you to manually broadcast your name, position and public encryption key, which is also signed to prevent spoofing. When you click the advert button, it broadcasts that data over LoRa. MeshCore calls that an Advert. There's two ways to advert, "zero hop" and "flood".
|
||||
|
||||
* Zero hop means your advert is broadcasted out to anyone that can hear it, and that's it.
|
||||
* Flooded means it's broadcasted out, and then repeated by all the repeaters that hear it.
|
||||
* Flooded means it's broadcasted out and then repeated by all the repeaters that hear it.
|
||||
|
||||
MeshCore clients only advertise themselves when the user initiates it. A repeater (and room server?) advertises its presence once every 240 minutes. This interval can be configured using the following command:
|
||||
|
||||
`set advert.interval {minutes}`
|
||||
|
||||
### Q: Is there a hop limit?
|
||||
### 2.5. Q: Is there a hop limit?
|
||||
|
||||
**A:** Internally the firmware has maximum limit of 64 hops. In real world settings it will be difficult to get close to the limit due to the environments and timing as packets travel further and further. We want to hear how far your MeshCore conversations go.
|
||||
|
||||
@@ -133,30 +201,43 @@ MeshCore clients only advertise themselves when the user initiates it. A repeate
|
||||
---
|
||||
|
||||
|
||||
## Server Administration
|
||||
## 3. Server Administration
|
||||
|
||||
### Q: How do you configure a repeater or a room server?
|
||||
**A:** One of these servers can be administered with one of the options below:
|
||||
### 3.1. Q: How do you configure a repeater or a room server?
|
||||
|
||||
**A:** - When MeshCore is flashed onto a LoRa device is for the first time, it is necessary to set the server device's frequency to make it utilize the frequency that is legal in your country or region.
|
||||
|
||||
Repeater or room server can be administered with one of the options below:
|
||||
|
||||
- After a repeater or room server firmware is flashed on to a LoRa device, go to <https://config.meshcore.dev> and use the web user interface to connect to the LoRa device via USB serial. From there you can set the name of the server, its frequency and other related settings, location, passwords etc.
|
||||
|
||||

|
||||
|
||||
|
||||
- Connect the server device using a USB cable to a computer running Chrome on https://flasher.meshcore.co.uk/, then use the `console` feature to connect to the device
|
||||
- this is necessary to set the server device's frequency if it doesn't match the frequency for your local region or country
|
||||
- MeshCore smart device clients have the ability to remotely administer servers.
|
||||
- A T-Deck running unlocked/registered MeshCore firmware. Remote server administration is enabled through registering your T-Deck with Ripple Radios. It is one of the ways to support MeshCore development. You can register your T-Deck at:
|
||||
<https://buymeacoffee.com/ripplebiz/e/249834>
|
||||
|
||||
### Q: Do I need to set the location for a repeater?
|
||||
- Use a MeshCore smartphone clients to remotely administer servers via LoRa.
|
||||
|
||||
- A T-Deck running unlocked/registered MeshCore firmware. Remote server administration is enabled through registering your T-Deck with Ripple Radios. It is one of the ways to support MeshCore development. You can register your T-Deck at:
|
||||
|
||||
<https://buymeacoffee.com/ripplebiz/e/249834>
|
||||
|
||||
|
||||
|
||||
### 3.2. Q: Do I need to set the location for a repeater?
|
||||
**A:** With location set for a repeater, it can show up on a MeshCore map in the future. Set location with the following commands:
|
||||
|
||||
`set lat <GPS Lat> set long <GPS Lon>`
|
||||
|
||||
You can get the latitude and longitude from Google Maps by right-clicking the location you are at on the map.
|
||||
|
||||
### Q: What is the password to administer a repeater or a room server?
|
||||
### 3.3. Q: What is the password to administer a repeater or a room server?
|
||||
**A:** The default admin password to a repeater and room server is `password`. Use the following command to change the admin password:
|
||||
|
||||
`password {new-password}`
|
||||
|
||||
|
||||
### Q: What is the password to join a room server?
|
||||
### 3.4. Q: What is the password to join a room server?
|
||||
**A:** The default guest password to a room server is `hello`. Use the following command to change the guest password:
|
||||
|
||||
`set guest.password {guest-password}`
|
||||
@@ -164,9 +245,9 @@ You can get the latitude and longitude from Google Maps by right-clicking the lo
|
||||
|
||||
---
|
||||
|
||||
## T-Deck Related
|
||||
## 4. T-Deck Related
|
||||
|
||||
### Q: What are the steps to get a T-Deck into DFU (Device Firmware Update) mode?
|
||||
### 4.1. Q: What are the steps to get a T-Deck into DFU (Device Firmware Update) mode?
|
||||
**A:**
|
||||
1. Device off
|
||||
2. Connect USB cable to device
|
||||
@@ -177,16 +258,20 @@ You can get the latitude and longitude from Google Maps by right-clicking the lo
|
||||
7. T-Deck in DFU mode now
|
||||
8. At this point you can begin flashing using <https://flasher.meshcore.co.uk/>
|
||||
|
||||
### Q: Why is my T-Deck Plus not getting any satellite lock?
|
||||
**A:** For T-Deck Plus, the GPS baud rate should be set to **38400**. Also, a number of T-Deck Plus devices were found to have the GPS module installed upside down, with the GPS antenna facing down instead of up. If your T-Deck Plus still doesn't get any satellite lock after setting the baud rate to 38400, you might need to open up the device to check the GPS orientation.
|
||||
### 4.2. Q: Why is my T-Deck Plus not getting any satellite lock?
|
||||
**A:** For T-Deck Plus, the GPS baud rate should be set to **38400**. Also, some T-Deck Plus devices were found to have the GPS module installed upside down, with the GPS antenna facing down instead of up. If your T-Deck Plus still doesn't get any satellite lock after setting the baud rate to 38400, you might need to open the device to check the GPS orientation.
|
||||
|
||||
### Q: Why is my OG (non-Plus) T-Deck not getting any satellite lock?
|
||||
GPS on T-Deck is always enabled. You can skip the "GPS clock sync" and the T-Deck will continue to try to get a GPS lock. You can go to the `GPS Info` screen; you should see the `Sentences:` counter increasing if the baud rate is correct.
|
||||
|
||||
[Source]([https://](https://discord.com/channels/826570251612323860/1330643963501351004/1356609240302616689))
|
||||
|
||||
### 4.3. Q: Why is my OG (non-Plus) T-Deck not getting any satellite lock?
|
||||
**A:** The OG (non-Plus) T-Deck doesn't come with a GPS. If you added a GPS to your OG T-Deck, please refer to the manual of your GPS to see what baud rate it requires. Alternatively, you can try to set the baud rate from 9600, 19200, etc., and up to 115200 to see which one works.
|
||||
|
||||
### Q: What size of SD card does the T-Deck support?
|
||||
### 4.4. Q: What size of SD card does the T-Deck support?
|
||||
**A:** Users have had no issues using 16GB or 32GB SD cards. Format the SD card to **FAT32**.
|
||||
|
||||
### Q: How do I get maps on T-Deck?
|
||||
### 4.5. Q: How do I get maps on T-Deck?
|
||||
**A:** You need map tiles. You can get pre-downloaded map tiles here (a good way to support development):
|
||||
- <https://buymeacoffee.com/ripplebiz/e/342543> (Europe)
|
||||
- <https://buymeacoffee.com/ripplebiz/e/342542> (US)
|
||||
@@ -200,28 +285,46 @@ There is also a modified script that adds additional error handling and parallel
|
||||
UK map tiles are available separately from Andy Kirby on his discord server:
|
||||
<https://discord.com/channels/826570251612323860/1330643963501351004/1331346597367386224>
|
||||
|
||||
### Q: Where do the map tiles go?
|
||||
### 4.6. Q: Where do the map tiles go?
|
||||
Once you have the tiles downloaded, copy the `\tiles` folder to the root of your T-Deck's SD card.
|
||||
|
||||
### Q: How to unlock deeper map zoom and server management features on T-Deck?
|
||||
### 4.7. Q: How to unlock deeper map zoom and server management features on T-Deck?
|
||||
**A:** You can download, install, and use the T-Deck firmware for free, but it has some features (map zoom, server administration) that are enabled if you purchase an unlock code for \$10 per T-Deck device.
|
||||
Unlock page: <https://buymeacoffee.com/ripplebiz/e/249834>
|
||||
|
||||
### 4.8. Q: How to decipher the diagnostics screen on T-Deck?
|
||||
|
||||
### Q: The T-Deck sound is too loud?
|
||||
### Q: Can you customize the sound?
|
||||
**A: ** Space is tight on T-Deck's screen, so the information is a bit cryptic. The format is :
|
||||
`{hops} l:{packet-length}({payload-len}) t:{packet-type} snr:{n} rssi:{n}`
|
||||
|
||||
See here for packet-type: [https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19](https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19 "https://github.com/ripplebiz/MeshCore/blob/main/src/Packet.h#L19")
|
||||
|
||||
|
||||
#define PAYLOAD_TYPE_REQ 0x00 // request (prefixed with dest/src hashes, MAC) (enc data: timestamp, blob)
|
||||
#define PAYLOAD_TYPE_RESPONSE 0x01 // response to REQ or ANON_REQ (prefixed with dest/src hashes, MAC) (enc data: timestamp, blob)
|
||||
#define PAYLOAD_TYPE_TXT_MSG 0x02 // a plain text message (prefixed with dest/src hashes, MAC) (enc data: timestamp, text)
|
||||
#define PAYLOAD_TYPE_ACK 0x03 // a simple ack #define PAYLOAD_TYPE_ADVERT 0x04 // a node advertising its Identity
|
||||
#define PAYLOAD_TYPE_GRP_TXT 0x05 // an (unverified) group text message (prefixed with channel hash, MAC) (enc data: timestamp, "name: msg")
|
||||
#define PAYLOAD_TYPE_GRP_DATA 0x06 // an (unverified) group datagram (prefixed with channel hash, MAC) (enc data: timestamp, blob)
|
||||
#define PAYLOAD_TYPE_ANON_REQ 0x07 // generic request (prefixed with dest_hash, ephemeral pub_key, MAC) (enc data: ...)
|
||||
#define PAYLOAD_TYPE_PATH 0x08 // returned path (prefixed with dest/src hashes, MAC) (enc data: path, extra)
|
||||
|
||||
[Source](https://discord.com/channels/1343693475589263471/1343693475589263474/1350611321040932966)
|
||||
|
||||
### 4.9. Q: The T-Deck sound is too loud?
|
||||
### 4.10. Q: Can you customize the sound?
|
||||
|
||||
**A:** You can customise the sounds on the T-Deck, just by placing `.mp3` files onto the `root` dir of the SD card. `startup.mp3`, `alert.mp3` and `new-advert.mp3`
|
||||
|
||||
### Q: What is the 'Import from Clipboard' feature on the t-deck and is there a way to manually add nodes without having to receive adverts?
|
||||
### 4.11. Q: What is the 'Import from Clipboard' feature on the t-deck and is there a way to manually add nodes without having to receive adverts?
|
||||
|
||||
**A:** 'Import from Clipboard' is for importing a contact via a file named 'clipboard.txt' on the SD card. The opposite, is in the Identity screen, the 'Card to Clipboard' menu, which writes to 'clipboard.txt' so you can share yourself (call these 'biz cards', that start with "meshcore://...")
|
||||
|
||||
---
|
||||
|
||||
## General
|
||||
## 5. General
|
||||
|
||||
### Q: What are BW, SF, and CR?
|
||||
### 5.1. Q: What are BW, SF, and CR?
|
||||
|
||||
**A:**
|
||||
|
||||
@@ -234,86 +337,214 @@ Making the bandwidth 2x wider (from BW125 to BW250) allows you to send 2x more b
|
||||
|
||||
Lowering the spreading factor makes it more difficult for the gateway to receive a transmission, as it will be more sensitive to noise. You could compare this to two people taking in a noisy place (a bar for example). If you’re far from each other, you have to talk slow (SF10), but if you’re close, you can talk faster (SF7)
|
||||
|
||||
So it's balancing act between speed of the transmission and resistance to noise.
|
||||
So, it's balancing act between speed of the transmission and resistance to noise.
|
||||
things network is mainly focused on LoRaWAN, but the LoRa low-level stuff still checks out for any LoRa project
|
||||
|
||||
### Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone?
|
||||
### 5.2. Q: Do MeshCore clients repeat?
|
||||
**A:** No, MeshCore clients do not repeat. This is the core of MeshCore's messaging-first design. This is to avoid devices flooding the air ware and create endless collisions, so messages sent aren't received.
|
||||
In MeshCore, only repeaters and room server with `set repeat on` repeat.
|
||||
|
||||
### 5.3. Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone?
|
||||
|
||||
**A:** If you used to reach a node through a repeater and the repeater is no longer reachable, the client will send the message using the existing (but now broken) known path, the message will fail after 3 retries, and the app will reset the path and send the message as flood on the last retry by default. This can be turned off in settings. If the destination is reachable directly or through another repeater, the new path will be used going forward. Or you can set the path manually if you know a specific repeater to use to reach that destination.
|
||||
|
||||
In the case if users are moving around frequently, and the paths are breaking, they just see the phone client retries and revert to flood to attempt to reestablish a path.
|
||||
|
||||
### 5.4. Q: How does a node discovery a path to its destination and then use it to send messages in the future, instead of flooding every message it sends like Meshtastic?
|
||||
|
||||
### Q: Is MeshCore open source?
|
||||
Routes are stored in sender's contact list. When you send a message the first time, the message first gets to your destination by flood routing. When your destination node gets the message, it will send back a delivery report to the sender with all repeaters that the original message went through. This delivery report is flood-routed back to you the sender and is a basis for future direct path. When you send the next message, the path will get embedded into the packet and be evaluated by repeaters. If the hop and address of the repeater matches, it will retransmit the message, otherwise it will not retransmit, hence minimizing utilization.
|
||||
|
||||
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1351279141630119996)
|
||||
|
||||
### 5.5. Q: Do public channels always flood? Do private channels always flood?
|
||||
|
||||
**A:** Yes, group channels are A to B, so there is no defined path. They have to flood. Repeaters can however deny flood traffic up to some hop limit, with the `set flood.max` CLI command. Administrators of repeaters get to set the rules of their repeaters.
|
||||
|
||||
[Source](https://discord.com/channels/1343693475589263471/1343693475589263474/1350023009527664672)
|
||||
|
||||
|
||||
### 5.6. Q: what is the public key for the default public channel?
|
||||
**A:** The smartphone app key is in hex:
|
||||
` 8b3387e9c5cdea6ac9e5edbaa115cd72`
|
||||
|
||||
T-Deck uses the same key but in base64
|
||||
`izOH6cXN6mrJ5e26oRXNcg==`
|
||||
The third character is the capital letter 'O', not zero `0`
|
||||
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1354194409213792388)
|
||||
|
||||
### 5.7. Q: Is MeshCore open source?
|
||||
**A:** Most of the firmware is freely available. Everything is open source except the T-Deck firmware and Liam's native mobile apps.
|
||||
- Firmware repo: <https://github.com/ripplebiz/MeshCore>
|
||||
|
||||
### Q: How can I support MeshCore?
|
||||
### 5.8. Q: How can I support MeshCore?
|
||||
**A:** Provide your honest feedback on GitHub and on AndyKirby's Discord server <http://discord.com/invite/H62Re4DCeD>. Spread the word of MeshCore to your friends and communities; help them get started with MeshCore. Support Scott's MeshCore development at <https://buymeacoffee.com/ripplebiz>.
|
||||
|
||||
Support Liam Cottle's smartphone client development by unlocking the server administration wait gate with in-app purchase
|
||||
|
||||
Support Rastislav Vysoky (recrof)'s flasher web site and the map web site development through [PayPal](https://www.paypal.com/donate/?business=DREHF5HM265ES&no_recurring=0&item_name=If+you+enjoy+my+work%2C+you+can+support+me+here%3A¤cy_code=EUR) or [Revolut](https://revolut.me/recrof)
|
||||
|
||||
### Q: How do I build MeshCore firmware from source?
|
||||
### 5.9. Q: How do I build MeshCore firmware from source?
|
||||
**A:** See instructions here:
|
||||
<https://discord.com/channels/826570251612323860/1330643963501351004/1342120825251299388>
|
||||
https://discord.com/channels/826570251612323860/1330643963501351004/1341826372120608769
|
||||
|
||||
Build instructions for MeshCore:
|
||||
|
||||
For Windows, first install WSL and Python+pip via: https://plainenglish.io/blog/setting-up-python-on-windows-subsystem-for-linux-wsl-26510f1b2d80
|
||||
|
||||
(Linux, Windows+WSL) In the terminal/shell:
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt install libpython3-dev
|
||||
sudo apt install python3-venv
|
||||
```
|
||||
Mac: python3 should be already installed.
|
||||
|
||||
Then it should be the same for all platforms:
|
||||
```
|
||||
python3 -m venv meshcore
|
||||
cd meshcore && source bin/activate
|
||||
pip install -U platformio
|
||||
git clone https://github.com/ripplebiz/MeshCore.git
|
||||
cd MeshCore
|
||||
```
|
||||
open platformio.ini and in `[arduino_base]` edit the `LORA_FREQ=867.5`
|
||||
save, then run:
|
||||
```
|
||||
pio run -e RAK_4631_Repeater
|
||||
```
|
||||
then you'll find `firmware.zip` in `.pio/build/RAK_4631_Repeater`
|
||||
|
||||
Andy also has a video on how to build using VS Code:
|
||||
*How to build and flash Meshcore repeater firmware | Heltec V3*
|
||||
<https://www.youtube.com/watch?v=WJvg6dt13hk> *(Link referenced in the Discord post)*
|
||||
|
||||
### Q: Are there other MeshCore related open source projects?
|
||||
### 5.10. Q: Are there other MeshCore related open source projects?
|
||||
|
||||
**A:** [Liam Cottle](https://liamcottle.net)'s MeshCore web client and MeshCore Javascript libary are open source under MIT license.
|
||||
|
||||
Web client: https://github.com/liamcottle/meshcore-web
|
||||
Javascript: https://github.com/liamcottle/meshcore.js
|
||||
|
||||
### Q: Does MeshCore support ATAK
|
||||
### 5.11. Q: Does MeshCore support ATAK
|
||||
**A:** ATAK is not currently on MeshCore's roadmap.
|
||||
|
||||
### Q: How do I add a node to the [MeshCore Map]([url](https://meshcore.co.uk/map.html))
|
||||
Meshcore would not be best suited to ATAK because MeshCore:
|
||||
clients do not repeat and therefore you would need a network of repeaters in place
|
||||
will not have a stable path where all clients are constantly moving between repeaters
|
||||
|
||||
MeshCore clients would need to reset path constantly and flood traffic across the network which could lead to lots of collisions with something as chatty as ATAK.
|
||||
|
||||
This could change in the future if MeshCore develops a client firmware that repeats.
|
||||
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1354780032140054659)
|
||||
|
||||
### 5.12. Q: How do I add a node to the [MeshCore Map]([url](https://meshcore.co.uk/map.html))
|
||||
**A:** From the smartphone app, connect to a BLE Companion radio
|
||||
- To add the BLE Companion radio your smartphone is connected to to the map, tap the `advert` icon, then tap `Advert (To Clipboard)`.
|
||||
- To add a Repeater or Room Server to the map, tap the 3 dots next to the Repeater or Room Server you want to add to the map, then tap `Share (To Clipboard)`.
|
||||
- Go to the [MeshCore Map web site]([url](https://meshcore.co.uk/map.html)), tap the plus sign on the lower right corner and paste in the meshcore://... blob, then tap `Add Node`
|
||||
|
||||
|
||||
### 5.13. Q: Can I use a Raspberry Pi to update a MeshCore radio?
|
||||
** A:** Yes.
|
||||
You will need to install picocom on the pi.
|
||||
`sudo apt install picocom`
|
||||
|
||||
Then run the following commands to setup the repeater.
|
||||
```
|
||||
picocom -b 115200 /dev/ttyUSB0 --imap lfcrlf
|
||||
set name your_repeater_name
|
||||
time epoch_time
|
||||
password your_unique_password
|
||||
set advert.interval 240
|
||||
advert
|
||||
```
|
||||
Note: If using a RAK the path will most likely be /dev/ttyACM0
|
||||
|
||||
Epoch time comes from https://www.epochconverter.com/
|
||||
|
||||
You can also flash the repeater using esptool. You will need to install esptool with the following command...
|
||||
|
||||
`pip install esptool --break-system-packages`
|
||||
|
||||
Then to flash the firmware to Heltec, obtain the .bin file from https://flasher.meshcore.co.uk/ (download all firmware link)
|
||||
|
||||
For Heltec:
|
||||
`esptool.py -p /dev/ttyUSB0 --chip esp32-s3 write_flash 0x00000 firmware.bin`
|
||||
|
||||
If flashing a visual studio code build bin file, flash with the following offset:
|
||||
`esptool.py -p /dev/ttyUSB0 --chip esp32-s3 write_flash 0x10000 firmware.bin`
|
||||
|
||||
For Pi
|
||||
Download the zip from the online flasher website and use the following command:
|
||||
|
||||
Note: Requires adafruit-nrfutil command which can be installed as follows.
|
||||
`pip install adafruit-nrfutil --break-system-packages`
|
||||
|
||||
```
|
||||
adafruit-nrfutil --verbose dfu serial --package t1000_e_bootloader-0.9.1-5-g488711a_s140_7.3.0.zip -p /dev/ttyACM0 -b 115200 --singlebank --touch 1200
|
||||
```
|
||||
|
||||
[Source](https://discord.com/channels/826570251612323860/1330643963501351004/1342120825251299388)
|
||||
|
||||
### 5.14. Q: Are there are projects built around MeshCore?
|
||||
|
||||
**A:** Yes. See the following:
|
||||
|
||||
#### 5.14.1. meshcoremqtt
|
||||
A Python script to send meshore debug and packet capture data to MQTT for analysis
|
||||
https://github.com/Andrew-a-g/meshcoretomqtt
|
||||
|
||||
#### 5.14.2. MeshCore for Home Assistant
|
||||
A custom Home Assistant integration for MeshCore mesh radio nodes. It allows you to monitor and control MeshCore nodes via USB, BLE, or TCP connections.
|
||||
https://github.com/awolden/meshcore-ha
|
||||
|
||||
#### 5.14.3. Python MeshCore
|
||||
Bindings to access your MeshCore companion radio nodes in python.
|
||||
https://github.com/fdlamotte/meshcore_py
|
||||
|
||||
#### 5.14.4. meshcore-cli
|
||||
CLI interface to MeshCore companion radio over BLE, TCP, or serial. Uses Pyton MeshCore above.
|
||||
https://github.com/fdlamotte/meshcore-cli
|
||||
|
||||
#### 5.14.5. meshcore.js
|
||||
A JavaScript library for interacting with a MeshCore device running the companion radio firmware
|
||||
https://github.com/liamcottle/meshcore.js
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
## 6. Troubleshooting
|
||||
|
||||
### Q: My client says another client or a repeater or a room server was last seen many, many days ago.
|
||||
### Q: A repeater or a client or a room server I expect to see on my discover list (on T-Deck) or contact list (on a smart device client) are not listed.
|
||||
### 6.1. Q: My client says another client or a repeater or a room server was last seen many, many days ago.
|
||||
### 6.2. Q: A repeater or a client or a room server I expect to see on my discover list (on T-Deck) or contact list (on a smart device client) are not listed.
|
||||
**A:**
|
||||
- If your client is a T-Deck, it may not have its time set (no GPS installed, no GPS lock, or wrong GPS baud rate).
|
||||
- If you are using the Android or iOS client, the other client, repeater, or room server may have the wrong time.
|
||||
|
||||
You can get the epoch time on <https://www.epochconverter.com/> and use it to set your T-Deck clock. For a repeater and room server, the admin can use a T-Deck to remotely set their clock (clock sync), or use the `time` command in the USB serial console with the server device connected.
|
||||
|
||||
### Q: How to connect to a repeater via BLE (bluetooth)?
|
||||
**A:** You can't connect to a device running repeater firmware via bluetooth. Devices running the BLE companion firmware you can connect to it via bluetooth using the android app
|
||||
### 6.3. Q: How to connect to a repeater via BLE (Bluetooth)?
|
||||
**A:** You can't connect to a device running repeater firmware via Bluetooth. Devices running the BLE companion firmware you can connect to it via Bluetooth using the android app
|
||||
|
||||
### Q: I can't connect via bluetooth, what is the bluetooth pairing code?
|
||||
### 6.4. Q: I can't connect via Bluetooth, what is the Bluetooth pairing code?
|
||||
|
||||
**A:** the default bluetooth pairing code is `123456`
|
||||
**A:** the default Bluetooth pairing code is `123456`
|
||||
|
||||
### Q: My Heltec V3 keeps disconnecting from my smartphone. It can't hold a solid Bluetooth connection.
|
||||
### 6.5. Q: My Heltec V3 keeps disconnecting from my smartphone. It can't hold a solid Bluetooth connection.
|
||||
|
||||
**A:** Heltec V3 has a very small coil antenna on its PCB for WiFi and Bluetooth connectivty. It has a very short range, only a few feet. It is possible to remove the coil antenna and replace it with a 31mm wire. The BT range is much improved with the modification.
|
||||
**A:** Heltec V3 has a very small coil antenna on its PCB for Wi-Fi and Bluetooth connectivity. It has a very short range, only a few feet. It is possible to remove the coil antenna and replace it with a 31mm wire. The BT range is much improved with the modification.
|
||||
|
||||
---
|
||||
## Other Questions:
|
||||
### Q: How to Update repeater and room server firmware over the air?
|
||||
## 7. Other Questions:
|
||||
### 7.1. Q: How to Update repeater and room server firmware over the air?
|
||||
|
||||
**A:** Only nRF-based RAK4631 and Heltec T114 OTA firmware update are verified using nRF smartphone app. Lilygo T-Echo doesn't work currently.
|
||||
You can update repeater and room server firmware with a bluetooth connection between your smartphone and your LoRa radio using the nRF app.
|
||||
You can update repeater and room server firmware with a Bluetooth connection between your smartphone and your LoRa radio using the nRF app.
|
||||
|
||||
1. Download the ZIP file for the specific node from the web flasher to your smartphone
|
||||
2. On the phone client, log on to the repeater as administrator (default password is `password`) to issue the `start ota`command to the repeater or room server to get the device into OTA DFU mode
|
||||
|
||||

|
||||
1. `start ota` can be initiated from USB serial console on the web flasher page or a T-Deck
|
||||
|
||||
1. `start ota` can be initiated from USB serial console on the web flasher page or a T-Deck
|
||||
4. On the smartphone, download and run the nRF app and scan for Bluetooth devices
|
||||
5. Connect to the repeater/room server node you want to update
|
||||
1. nRF app is available on both Android and iOS
|
||||
@@ -322,7 +553,8 @@ You can update repeater and room server firmware with a bluetooth connection bet
|
||||
|
||||
**iOS continues here:**
|
||||
5. Once connected successfully, a `DFU` icon 
|
||||
appears in the top right corner of the app
|
||||
appears in the top right corner of the app
|
||||

|
||||
|
||||
6. Scroll down to change the `PRN(s)` number:
|
||||
|
||||
@@ -372,4 +604,4 @@ You can update repeater and room server firmware with a bluetooth connection bet
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ struct NodePrefs { // persisted to file
|
||||
uint8_t tx_power_dbm;
|
||||
uint8_t telemetry_mode_base;
|
||||
uint8_t telemetry_mode_loc;
|
||||
uint8_t telemetry_mode_env;
|
||||
float rx_delay_base;
|
||||
uint32_t ble_pin;
|
||||
};
|
||||
|
||||
@@ -53,6 +53,31 @@ void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs, const char* bu
|
||||
|
||||
// v1.2.3 (1 Jan 2025)
|
||||
sprintf(_version_info, "%s (%s)", version, build_date);
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
buzzer.begin();
|
||||
#endif
|
||||
}
|
||||
|
||||
void UITask::soundBuzzer(UIEventType bet) {
|
||||
#if defined(PIN_BUZZER)
|
||||
switch(bet){
|
||||
case UIEventType::contactMessage:
|
||||
// gemini's pick
|
||||
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
||||
break;
|
||||
case UIEventType::channelMessage:
|
||||
buzzer.play("kerplop:d=16,o=6,b=120:32g#,32c#");
|
||||
break;
|
||||
case UIEventType::roomMessage:
|
||||
case UIEventType::newContactMessage:
|
||||
case UIEventType::none:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
// Serial.print("DBG: Buzzzzzz -> ");
|
||||
// Serial.println((int) bet);
|
||||
}
|
||||
|
||||
void UITask::msgRead(int msgcount) {
|
||||
@@ -85,7 +110,7 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
||||
}
|
||||
}
|
||||
|
||||
void renderBatteryIndicator(DisplayDriver* _display, uint16_t batteryMilliVolts) {
|
||||
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
|
||||
// Convert millivolts to percentage
|
||||
const int minMilliVolts = 3000; // Minimum voltage (e.g., 3.0V)
|
||||
const int maxMilliVolts = 4200; // Maximum voltage (e.g., 4.2V)
|
||||
@@ -107,8 +132,8 @@ void renderBatteryIndicator(DisplayDriver* _display, uint16_t batteryMilliVolts)
|
||||
_display->fillRect(iconX + iconWidth, iconY + (iconHeight / 4), 3, iconHeight / 2);
|
||||
|
||||
// fill the battery based on the percentage
|
||||
int fillWidth = (batteryPercentage * (iconWidth - 2)) / 100;
|
||||
_display->fillRect(iconX + 1, iconY + 1, fillWidth, iconHeight - 2);
|
||||
int fillWidth = (batteryPercentage * (iconWidth - 4)) / 100;
|
||||
_display->fillRect(iconX + 2, iconY + 2, fillWidth, iconHeight - 4);
|
||||
}
|
||||
|
||||
void UITask::renderCurrScreen() {
|
||||
@@ -155,7 +180,7 @@ void UITask::renderCurrScreen() {
|
||||
_display->print(_node_prefs->node_name);
|
||||
|
||||
// battery voltage
|
||||
renderBatteryIndicator(_display, _board->getBattMilliVolts());
|
||||
renderBatteryIndicator(_board->getBattMilliVolts());
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
@@ -209,45 +234,58 @@ void UITask::userLedHandler() {
|
||||
}
|
||||
|
||||
void UITask::buttonHandler() {
|
||||
#ifdef PIN_USER_BTN
|
||||
static int prev_btn_state = !USER_BTN_PRESSED;
|
||||
static unsigned long btn_state_change_time = 0;
|
||||
static unsigned long next_read = 0;
|
||||
int cur_time = millis();
|
||||
if (cur_time >= next_read) {
|
||||
int btn_state = digitalRead(PIN_USER_BTN);
|
||||
if (btn_state != prev_btn_state) {
|
||||
if (btn_state == USER_BTN_PRESSED) { // pressed?
|
||||
if (_display != NULL) {
|
||||
if (_display->isOn()) {
|
||||
clearMsgPreview();
|
||||
} else {
|
||||
_display->turnOn();
|
||||
_need_refresh = true;
|
||||
#if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
|
||||
static int prev_btn_state = !USER_BTN_PRESSED;
|
||||
static int prev_btn_state_ana = !USER_BTN_PRESSED;
|
||||
static unsigned long btn_state_change_time = 0;
|
||||
static unsigned long next_read = 0;
|
||||
int cur_time = millis();
|
||||
if (cur_time >= next_read) {
|
||||
int btn_state = 0;
|
||||
int btn_state_ana = 0;
|
||||
#ifdef PIN_USER_BTN
|
||||
btn_state = digitalRead(PIN_USER_BTN);
|
||||
#endif
|
||||
#ifdef PIN_USER_BTN_ANA
|
||||
btn_state_ana = (analogRead(PIN_USER_BTN_ANA) < 20); // analogRead returns a value hopefully below 20 when button is pressed.
|
||||
#endif
|
||||
if (btn_state != prev_btn_state || btn_state_ana != prev_btn_state_ana) { // check for either digital or analogue button change of state
|
||||
if (btn_state == USER_BTN_PRESSED || btn_state_ana == USER_BTN_PRESSED) { // pressed?
|
||||
if (_display != NULL) {
|
||||
if (_display->isOn()) {
|
||||
clearMsgPreview();
|
||||
} else {
|
||||
_display->turnOn();
|
||||
_need_refresh = true;
|
||||
}
|
||||
_auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||
}
|
||||
} else { // unpressed ? check pressed time ...
|
||||
if ((cur_time - btn_state_change_time) > 5000) {
|
||||
#ifdef PIN_STATUS_LED
|
||||
digitalWrite(PIN_STATUS_LED, LOW);
|
||||
delay(10);
|
||||
#endif
|
||||
_board->powerOff();
|
||||
}
|
||||
_auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||
}
|
||||
} else { // unpressed ? check pressed time ...
|
||||
if ((cur_time - btn_state_change_time) > 5000) {
|
||||
#ifdef PIN_STATUS_LED
|
||||
digitalWrite(PIN_STATUS_LED, LOW);
|
||||
delay(10);
|
||||
#endif
|
||||
_board->powerOff();
|
||||
}
|
||||
btn_state_change_time = millis();
|
||||
prev_btn_state = btn_state;
|
||||
prev_btn_state_ana = btn_state_ana;
|
||||
}
|
||||
btn_state_change_time = millis();
|
||||
prev_btn_state = btn_state;
|
||||
next_read = millis() + 100; // 10 reads per second
|
||||
}
|
||||
next_read = millis() + 100; // 10 reads per second
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UITask::loop() {
|
||||
buttonHandler();
|
||||
userLedHandler();
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
if (buzzer.isPlaying()) buzzer.loop();
|
||||
#endif
|
||||
|
||||
if (_display != NULL && _display->isOn()) {
|
||||
static bool _firstBoot = true;
|
||||
if(_firstBoot && millis() >= BOOT_SCREEN_MILLIS) {
|
||||
|
||||
@@ -4,11 +4,27 @@
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
#include <helpers/ui/buzzer.h>
|
||||
#endif
|
||||
|
||||
#include "NodePrefs.h"
|
||||
|
||||
enum class UIEventType
|
||||
{
|
||||
none,
|
||||
contactMessage,
|
||||
channelMessage,
|
||||
roomMessage,
|
||||
newContactMessage
|
||||
};
|
||||
|
||||
class UITask {
|
||||
DisplayDriver* _display;
|
||||
mesh::MainBoard* _board;
|
||||
#ifdef PIN_BUZZER
|
||||
genericBuzzer buzzer;
|
||||
#endif
|
||||
unsigned long _next_refresh, _auto_off;
|
||||
bool _connected;
|
||||
uint32_t _pin_code;
|
||||
@@ -22,7 +38,9 @@ class UITask {
|
||||
void renderCurrScreen();
|
||||
void buttonHandler();
|
||||
void userLedHandler();
|
||||
void renderBatteryIndicator(uint16_t batteryMilliVolts);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UITask(mesh::MainBoard* board) : _board(board), _display(NULL) {
|
||||
@@ -36,5 +54,6 @@ public:
|
||||
void clearMsgPreview();
|
||||
void msgRead(int msgcount);
|
||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
||||
void soundBuzzer(UIEventType bet = UIEventType::none);
|
||||
void loop();
|
||||
};
|
||||
|
||||
@@ -60,28 +60,7 @@
|
||||
|
||||
#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="
|
||||
|
||||
#ifdef DISPLAY_CLASS // TODO: refactor this -- move to variants/*/target
|
||||
#include "UITask.h"
|
||||
#ifdef ST7735
|
||||
#include <helpers/ui/ST7735Display.h>
|
||||
#elif ST7789
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#elif defined(HAS_GxEPD)
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#else
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
#if defined(HELTEC_LORA_V3) && defined(ST7735)
|
||||
static DISPLAY_CLASS display(&board.periph_power); // peripheral power pin is shared
|
||||
#else
|
||||
static DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#define HAS_UI
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UI)
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "UITask.h"
|
||||
|
||||
static UITask ui_task(&board);
|
||||
@@ -102,11 +81,11 @@ static uint32_t _atoi(const char* sp) {
|
||||
#define FIRMWARE_VER_CODE 5
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "17 May 2025"
|
||||
#define FIRMWARE_BUILD_DATE "24 May 2025"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.6.1"
|
||||
#define FIRMWARE_VERSION "v1.6.2"
|
||||
#endif
|
||||
|
||||
#define CMD_APP_START 1
|
||||
@@ -292,8 +271,8 @@ class MyMesh : public BaseChatMesh {
|
||||
|
||||
void saveContacts() {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove("/contacts3");
|
||||
File file = _fs->open("/contacts3", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts3", "w");
|
||||
#else
|
||||
@@ -357,8 +336,8 @@ class MyMesh : public BaseChatMesh {
|
||||
|
||||
void saveChannels() {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove("/channels2");
|
||||
File file = _fs->open("/channels2", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/channels2", "w");
|
||||
#else
|
||||
@@ -414,8 +393,8 @@ class MyMesh : public BaseChatMesh {
|
||||
sprintf(path, "/bl/%s", fname);
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove(path);
|
||||
File f = _fs->open(path, FILE_O_WRITE);
|
||||
if (f) { f.seek(0); f.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File f = _fs->open(path, "w");
|
||||
#else
|
||||
@@ -504,10 +483,6 @@ class MyMesh : public BaseChatMesh {
|
||||
return 0; // queue is empty
|
||||
}
|
||||
|
||||
void soundBuzzer() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
protected:
|
||||
float getAirtimeBudgetFactor() const override {
|
||||
return _prefs.airtime_factor;
|
||||
@@ -544,7 +519,9 @@ protected:
|
||||
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
|
||||
}
|
||||
} else {
|
||||
soundBuzzer();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.soundBuzzer(UIEventType::newContactMessage);
|
||||
#endif
|
||||
}
|
||||
|
||||
saveContacts();
|
||||
@@ -605,9 +582,11 @@ protected:
|
||||
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
||||
_serial->writeFrame(frame, 1);
|
||||
} else {
|
||||
soundBuzzer();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.soundBuzzer(UIEventType::contactMessage);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.newMsg(path_len, from.name, text, offline_queue_len);
|
||||
#endif
|
||||
}
|
||||
@@ -656,9 +635,11 @@ protected:
|
||||
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
||||
_serial->writeFrame(frame, 1);
|
||||
} else {
|
||||
soundBuzzer();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.soundBuzzer(UIEventType::channelMessage);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.newMsg(path_len, "Public", text, offline_queue_len);
|
||||
#endif
|
||||
}
|
||||
@@ -680,6 +661,12 @@ protected:
|
||||
permissions |= cp & TELEM_PERM_LOCATION;
|
||||
}
|
||||
|
||||
if (_prefs.telemetry_mode_env == TELEM_MODE_ALLOW_ALL) {
|
||||
permissions |= TELEM_PERM_ENVIRONMENT;
|
||||
} else if (_prefs.telemetry_mode_env == TELEM_MODE_ALLOW_FLAGS) {
|
||||
permissions |= cp & TELEM_PERM_ENVIRONMENT;
|
||||
}
|
||||
|
||||
if (permissions & TELEM_PERM_BASE) { // only respond if base permission bit is set
|
||||
telemetry.reset();
|
||||
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
|
||||
@@ -843,7 +830,7 @@ public:
|
||||
file.read((uint8_t *) &_prefs.tx_power_dbm, sizeof(_prefs.tx_power_dbm)); // 68
|
||||
file.read((uint8_t *) &_prefs.telemetry_mode_base, sizeof(_prefs.telemetry_mode_base)); // 69
|
||||
file.read((uint8_t *) &_prefs.telemetry_mode_loc, sizeof(_prefs.telemetry_mode_loc)); // 70
|
||||
file.read(pad, 1); // 71
|
||||
file.read((uint8_t *) &_prefs.telemetry_mode_env, sizeof(_prefs.telemetry_mode_env)); // 71
|
||||
file.read((uint8_t *) &_prefs.rx_delay_base, sizeof(_prefs.rx_delay_base)); // 72
|
||||
file.read(pad, 4); // 76
|
||||
file.read((uint8_t *) &_prefs.ble_pin, sizeof(_prefs.ble_pin)); // 80
|
||||
@@ -882,6 +869,11 @@ public:
|
||||
mesh::Utils::toHex(pub_key_hex, self_id.pub_key, 4);
|
||||
strcpy(_prefs.node_name, pub_key_hex);
|
||||
|
||||
// if name is provided as a build flag, use that as default node name instead
|
||||
#ifdef ADVERT_NAME
|
||||
strcpy(_prefs.node_name, ADVERT_NAME);
|
||||
#endif
|
||||
|
||||
// load persisted prefs
|
||||
if (_fs->exists("/new_prefs")) {
|
||||
loadPrefsInt("/new_prefs"); // new filename
|
||||
@@ -893,7 +885,7 @@ public:
|
||||
|
||||
#ifdef BLE_PIN_CODE
|
||||
if (_prefs.ble_pin == 0) {
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (has_display) {
|
||||
StdRNG rng;
|
||||
_active_ble_pin = rng.nextInt(100000, 999999); // random pin each session
|
||||
@@ -934,8 +926,8 @@ public:
|
||||
|
||||
void savePrefs() {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove("/new_prefs");
|
||||
File file = _fs->open("/new_prefs", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/new_prefs", "w");
|
||||
#else
|
||||
@@ -959,7 +951,7 @@ public:
|
||||
file.write((uint8_t *) &_prefs.tx_power_dbm, sizeof(_prefs.tx_power_dbm)); // 68
|
||||
file.write((uint8_t *) &_prefs.telemetry_mode_base, sizeof(_prefs.telemetry_mode_base)); // 69
|
||||
file.write((uint8_t *) &_prefs.telemetry_mode_loc, sizeof(_prefs.telemetry_mode_loc)); // 70
|
||||
file.write(pad, 1); // 71
|
||||
file.write((uint8_t *) &_prefs.telemetry_mode_env, sizeof(_prefs.telemetry_mode_env)); // 71
|
||||
file.write((uint8_t *) &_prefs.rx_delay_base, sizeof(_prefs.rx_delay_base)); // 72
|
||||
file.write(pad, 4); // 76
|
||||
file.write((uint8_t *) &_prefs.ble_pin, sizeof(_prefs.ble_pin)); // 80
|
||||
@@ -1004,7 +996,7 @@ public:
|
||||
memcpy(&out_frame[i], &lon, 4); i += 4;
|
||||
out_frame[i++] = 0; // reserved
|
||||
out_frame[i++] = 0; // reserved
|
||||
out_frame[i++] = (_prefs.telemetry_mode_loc << 2) | (_prefs.telemetry_mode_base); // v5+
|
||||
out_frame[i++] = (_prefs.telemetry_mode_env << 4) | (_prefs.telemetry_mode_loc << 2) | (_prefs.telemetry_mode_base); // v5+
|
||||
out_frame[i++] = _prefs.manual_add_contacts;
|
||||
|
||||
uint32_t freq = _prefs.freq * 1000;
|
||||
@@ -1242,7 +1234,7 @@ public:
|
||||
int out_len;
|
||||
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
||||
_serial->writeFrame(out_frame, out_len);
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.msgRead(offline_queue_len);
|
||||
#endif
|
||||
} else {
|
||||
@@ -1296,6 +1288,7 @@ public:
|
||||
if (len >= 3) {
|
||||
_prefs.telemetry_mode_base = cmd_frame[2] & 0x03; // v5+
|
||||
_prefs.telemetry_mode_loc = (cmd_frame[2] >> 2) & 0x03;
|
||||
_prefs.telemetry_mode_env = (cmd_frame[2] >> 4) & 0x03;
|
||||
}
|
||||
savePrefs();
|
||||
writeOKFrame();
|
||||
@@ -1570,7 +1563,7 @@ public:
|
||||
checkConnections();
|
||||
}
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.setHasConnection(_serial->isConnected());
|
||||
ui_task.loop();
|
||||
#endif
|
||||
@@ -1641,16 +1634,14 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
DisplayDriver* disp = NULL;
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
disp = &display;
|
||||
disp->startFrame();
|
||||
disp->print("Please wait...");
|
||||
disp->endFrame();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
@@ -1660,7 +1651,7 @@ void setup() {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
InternalFS.begin();
|
||||
the_mesh.begin(InternalFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
@@ -1678,7 +1669,7 @@ void setup() {
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
the_mesh.begin(LittleFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
@@ -1703,7 +1694,7 @@ void setup() {
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
@@ -1731,7 +1722,7 @@ void setup() {
|
||||
|
||||
sensors.begin();
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(disp, the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, the_mesh.getBLEPin());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
/* ------------------------------ Config -------------------------------- */
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "17 May 2025"
|
||||
#define FIRMWARE_BUILD_DATE "24 May 2025"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.6.1"
|
||||
#define FIRMWARE_VERSION "v1.6.2"
|
||||
#endif
|
||||
|
||||
#ifndef LORA_FREQ
|
||||
@@ -60,10 +60,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
|
||||
static DISPLAY_CLASS display;
|
||||
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(display);
|
||||
#endif
|
||||
@@ -735,7 +731,7 @@ void setup() {
|
||||
board.begin();
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if(display.begin()){
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
display.print("Please wait...");
|
||||
display.endFrame();
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
/* ------------------------------ Config -------------------------------- */
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE "17 May 2025"
|
||||
#define FIRMWARE_BUILD_DATE "24 May 2025"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.6.1"
|
||||
#define FIRMWARE_VERSION "v1.6.2"
|
||||
#endif
|
||||
|
||||
#ifndef LORA_FREQ
|
||||
@@ -68,10 +68,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
|
||||
static DISPLAY_CLASS display;
|
||||
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(display);
|
||||
#endif
|
||||
@@ -909,7 +905,7 @@ void setup() {
|
||||
board.begin();
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if(display.begin()){
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
display.print("Please wait...");
|
||||
display.endFrame();
|
||||
|
||||
@@ -127,8 +127,8 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
|
||||
|
||||
void saveContacts() {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
_fs->remove("/contacts");
|
||||
File file = _fs->open("/contacts", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts", "w");
|
||||
#else
|
||||
@@ -341,8 +341,8 @@ public:
|
||||
|
||||
void savePrefs() {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
_fs->remove("/node_prefs");
|
||||
File file = _fs->open("/node_prefs", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/node_prefs", "w");
|
||||
#else
|
||||
|
||||
@@ -71,7 +71,15 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
|
||||
|
||||
// remove our hash from 'path', then re-broadcast
|
||||
pkt->path_len -= PATH_HASH_SIZE;
|
||||
#if 0
|
||||
memcpy(pkt->path, &pkt->path[PATH_HASH_SIZE], pkt->path_len);
|
||||
#elif PATH_HASH_SIZE == 1
|
||||
for (int k = 0; k < pkt->path_len; k++) { // shuffle bytes by 1
|
||||
pkt->path[k] = pkt->path[k + 1];
|
||||
}
|
||||
#else
|
||||
#error "need path remove impl"
|
||||
#endif
|
||||
|
||||
uint32_t d = getDirectRetransmitDelay(pkt);
|
||||
return ACTION_RETRANSMIT_DELAYED(0, d); // Routed traffic is HIGHEST priority
|
||||
|
||||
@@ -8,8 +8,14 @@
|
||||
memcpy(&app_data[i], &_lat, 4); i += 4;
|
||||
memcpy(&app_data[i], &_lon, 4); i += 4;
|
||||
}
|
||||
// TODO: BATTERY encoding
|
||||
// TODO: TEMPERATURE encoding
|
||||
if (_extra1) {
|
||||
app_data[0] |= ADV_FEAT1_MASK;
|
||||
memcpy(&app_data[i], &_extra1, 2); i += 2;
|
||||
}
|
||||
if (_extra2) {
|
||||
app_data[0] |= ADV_FEAT2_MASK;
|
||||
memcpy(&app_data[i], &_extra2, 2); i += 2;
|
||||
}
|
||||
if (_name && *_name != 0) {
|
||||
app_data[0] |= ADV_NAME_MASK;
|
||||
const char* sp = _name;
|
||||
@@ -25,17 +31,18 @@
|
||||
_lat = _lon = 0;
|
||||
_flags = app_data[0];
|
||||
_valid = false;
|
||||
|
||||
_extra1 = _extra2 = 0;
|
||||
|
||||
int i = 1;
|
||||
if (_flags & ADV_LATLON_MASK) {
|
||||
memcpy(&_lat, &app_data[i], 4); i += 4;
|
||||
memcpy(&_lon, &app_data[i], 4); i += 4;
|
||||
}
|
||||
if (_flags & ADV_BATTERY_MASK) {
|
||||
/* TODO: somewhere to store battery volts? */ i += 2;
|
||||
if (_flags & ADV_FEAT1_MASK) {
|
||||
memcpy(&_extra1, &app_data[i], 2); i += 2;
|
||||
}
|
||||
if (_flags & ADV_TEMPERATURE_MASK) {
|
||||
/* TODO: somewhere to store temperature? */ i += 2;
|
||||
if (_flags & ADV_FEAT2_MASK) {
|
||||
memcpy(&_extra2, &app_data[i], 2); i += 2;
|
||||
}
|
||||
|
||||
if (app_data_len >= i) {
|
||||
|
||||
@@ -11,20 +11,25 @@
|
||||
//FUTURE: 4..15
|
||||
|
||||
#define ADV_LATLON_MASK 0x10
|
||||
#define ADV_BATTERY_MASK 0x20
|
||||
#define ADV_TEMPERATURE_MASK 0x40
|
||||
#define ADV_FEAT1_MASK 0x20 // FUTURE
|
||||
#define ADV_FEAT2_MASK 0x40 // FUTURE
|
||||
#define ADV_NAME_MASK 0x80
|
||||
|
||||
class AdvertDataBuilder {
|
||||
uint8_t _type;
|
||||
const char* _name;
|
||||
int32_t _lat, _lon;
|
||||
uint16_t _extra1 = 0;
|
||||
uint16_t _extra2 = 0;
|
||||
public:
|
||||
AdvertDataBuilder(uint8_t adv_type) : _type(adv_type), _name(NULL), _lat(0), _lon(0) { }
|
||||
AdvertDataBuilder(uint8_t adv_type, const char* name) : _type(adv_type), _name(name), _lat(0), _lon(0) { }
|
||||
AdvertDataBuilder(uint8_t adv_type, const char* name, double lat, double lon) :
|
||||
_type(adv_type), _name(name), _lat(lat * 1E6), _lon(lon * 1E6) { }
|
||||
|
||||
void setFeat1(uint16_t extra) { _extra1 = extra; }
|
||||
void setFeat2(uint16_t extra) { _extra2 = extra; }
|
||||
|
||||
/**
|
||||
* \brief encode the given advertisement data.
|
||||
* \param app_data dest array, must be MAX_ADVERT_DATA_SIZE
|
||||
@@ -38,11 +43,15 @@ class AdvertDataParser {
|
||||
bool _valid;
|
||||
char _name[MAX_ADVERT_DATA_SIZE];
|
||||
int32_t _lat, _lon;
|
||||
uint16_t _extra1;
|
||||
uint16_t _extra2;
|
||||
public:
|
||||
AdvertDataParser(const uint8_t app_data[], uint8_t app_data_len);
|
||||
|
||||
bool isValid() const { return _valid; }
|
||||
uint8_t getType() const { return _flags & 0x0F; }
|
||||
uint16_t getFeat1() const { return _extra1; }
|
||||
uint16_t getFeat2() const { return _extra2; }
|
||||
|
||||
bool hasName() const { return _name[0] != 0; }
|
||||
const char* getName() const { return _name; }
|
||||
|
||||
@@ -74,8 +74,8 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
||||
|
||||
void CommonCLI::savePrefs(FILESYSTEM* fs) {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
fs->remove("/com_prefs");
|
||||
File file = fs->open("/com_prefs", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = fs->open("/com_prefs", "w");
|
||||
#else
|
||||
@@ -358,6 +358,6 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||
_callbacks->dumpLogFile();
|
||||
strcpy(reply, " EOF");
|
||||
} else {
|
||||
sprintf(reply, "Unknown: %s", command);
|
||||
strcpy(reply, "Unknown command");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ bool IdentityStore::save(const char *name, const mesh::LocalIdentity& id) {
|
||||
sprintf(filename, "%s/%s.id", _dir, name);
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove(filename);
|
||||
File file = _fs->open(filename, FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open(filename, "w");
|
||||
#else
|
||||
@@ -69,8 +69,8 @@ bool IdentityStore::save(const char *name, const mesh::LocalIdentity& id, const
|
||||
sprintf(filename, "%s/%s.id", _dir, name);
|
||||
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
_fs->remove(filename);
|
||||
File file = _fs->open(filename, FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open(filename, "w");
|
||||
#else
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
class SensorManager {
|
||||
public:
|
||||
double node_lat, node_lon; // modify these, if you want to affect Advert location
|
||||
double node_altitude; // altitude in meters
|
||||
|
||||
SensorManager() { node_lat = 0; node_lon = 0; }
|
||||
SensorManager() { node_lat = 0; node_lon = 0; node_altitude = 0; }
|
||||
virtual bool begin() { return false; }
|
||||
virtual bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { return false; }
|
||||
virtual void loop() { }
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#define P_LORA_MISO 13 //SX1262 MISO pin
|
||||
#define P_LORA_MOSI 11 //SX1262 MOSI pin
|
||||
|
||||
#define PIN_BOARD_SDA 17 //SDA for OLED, BME280, and QMC6310U (0x1C)
|
||||
#define PIN_BOARD_SCL 18 //SCL for OLED, BME280, and QMC6310U (0x1C)
|
||||
//#define PIN_BOARD_SDA 17 //SDA for OLED, BME280, and QMC6310U (0x1C)
|
||||
//#define PIN_BOARD_SCL 18 //SCL for OLED, BME280, and QMC6310U (0x1C)
|
||||
|
||||
#define PIN_BOARD_SDA1 42 //SDA for PMU and PFC8563 (RTC)
|
||||
#define PIN_BOARD_SCL1 41 //SCL for PMU and PFC8563 (RTC)
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void printPMU();
|
||||
#endif
|
||||
bool power_init();
|
||||
|
||||
void begin() {
|
||||
|
||||
power_init();
|
||||
|
||||
@@ -26,6 +26,10 @@ void RAK4631Board::begin() {
|
||||
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_USER_BTN_ANA
|
||||
pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
||||
#endif
|
||||
|
||||
231
src/helpers/sensors/EnvironmentSensorManager.cpp
Normal file
231
src/helpers/sensors/EnvironmentSensorManager.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
#include "EnvironmentSensorManager.h"
|
||||
|
||||
#if ENV_INCLUDE_AHTX0
|
||||
#define TELEM_AHTX_ADDRESS 0x38 // AHT10, AHT20 temperature and humidity sensor I2C address
|
||||
#include <Adafruit_AHTX0.h>
|
||||
static Adafruit_AHTX0 AHTX0;
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_BME280
|
||||
#define TELEM_BME280_ADDRESS 0x76 // BME280 environmental sensor I2C address
|
||||
#define TELEM_BME280_SEALEVELPRESSURE_HPA (1013.25) // Athmospheric pressure at sea level
|
||||
#include <Adafruit_BME280.h>
|
||||
static Adafruit_BME280 BME280;
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA3221
|
||||
#define TELEM_INA3221_ADDRESS 0x42 // INA3221 3 channel current sensor I2C address
|
||||
#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
|
||||
#define TELEM_INA3221_NUM_CHANNELS 3
|
||||
#include <Adafruit_INA3221.h>
|
||||
static Adafruit_INA3221 INA3221;
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA219
|
||||
#define TELEM_INA219_ADDRESS 0x40 // INA219 single channel current sensor I2C address
|
||||
#include <Adafruit_INA219.h>
|
||||
static Adafruit_INA219 INA219(TELEM_INA219_ADDRESS);
|
||||
#endif
|
||||
|
||||
bool EnvironmentSensorManager::begin() {
|
||||
#if ENV_INCLUDE_GPS
|
||||
initBasicGPS();
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_AHTX0
|
||||
if (AHTX0.begin(&Wire, 0, TELEM_AHTX_ADDRESS)) {
|
||||
MESH_DEBUG_PRINTLN("Found AHT10/AHT20 at address: %02X", TELEM_AHTX_ADDRESS);
|
||||
AHTX0_initialized = true;
|
||||
} else {
|
||||
AHTX0_initialized = false;
|
||||
MESH_DEBUG_PRINTLN("AHT10/AHT20 was not found at I2C address %02X", TELEM_AHTX_ADDRESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_BME280
|
||||
if (BME280.begin(TELEM_BME280_ADDRESS, &Wire)) {
|
||||
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", TELEM_BME280_ADDRESS);
|
||||
MESH_DEBUG_PRINTLN("BME sensor ID: %02X", BME280.sensorID());
|
||||
BME280_initialized = true;
|
||||
} else {
|
||||
BME280_initialized = false;
|
||||
MESH_DEBUG_PRINTLN("BME280 was not found at I2C address %02X", TELEM_BME280_ADDRESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA3221
|
||||
if (INA3221.begin(TELEM_INA3221_ADDRESS, &Wire)) {
|
||||
MESH_DEBUG_PRINTLN("Found INA3221 at address: %02X", TELEM_INA3221_ADDRESS);
|
||||
MESH_DEBUG_PRINTLN("%04X %04X", INA3221.getDieID(), INA3221.getManufacturerID());
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
INA3221.setShuntResistance(i, TELEM_INA3221_SHUNT_VALUE);
|
||||
}
|
||||
INA3221_initialized = true;
|
||||
} else {
|
||||
INA3221_initialized = false;
|
||||
MESH_DEBUG_PRINTLN("INA3221 was not found at I2C address %02X", TELEM_INA3221_ADDRESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA219
|
||||
if (INA219.begin(&Wire)) {
|
||||
MESH_DEBUG_PRINTLN("Found INA219 at address: %02X", TELEM_INA219_ADDRESS);
|
||||
INA219_initialized = true;
|
||||
} else {
|
||||
INA219_initialized = false;
|
||||
MESH_DEBUG_PRINTLN("INA219 was not found at I2C address %02X", TELEM_INA219_ADDRESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
next_available_channel = TELEM_CHANNEL_SELF + 1;
|
||||
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) {
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); // allow lat/lon via telemetry even if no GPS is detected
|
||||
}
|
||||
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
|
||||
|
||||
#if ENV_INCLUDE_AHTX0
|
||||
if (AHTX0_initialized) {
|
||||
sensors_event_t humidity, temp;
|
||||
AHTX0.getEvent(&humidity, &temp);
|
||||
telemetry.addTemperature(TELEM_CHANNEL_SELF, temp.temperature);
|
||||
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, humidity.relative_humidity);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_BME280
|
||||
if (BME280_initialized) {
|
||||
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME280.readTemperature());
|
||||
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, BME280.readHumidity());
|
||||
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, BME280.readPressure());
|
||||
telemetry.addAltitude(TELEM_CHANNEL_SELF, BME280.readAltitude(TELEM_BME280_SEALEVELPRESSURE_HPA));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA3221
|
||||
if (INA3221_initialized) {
|
||||
for(int i = 0; i < TELEM_INA3221_NUM_CHANNELS; i++) {
|
||||
// add only enabled INA3221 channels to telemetry
|
||||
if (INA3221.isChannelEnabled(i)) {
|
||||
float voltage = INA3221.getBusVoltage(i);
|
||||
float current = INA3221.getCurrentAmps(i);
|
||||
telemetry.addVoltage(next_available_channel, voltage);
|
||||
telemetry.addCurrent(next_available_channel, current);
|
||||
telemetry.addPower(next_available_channel, voltage * current);
|
||||
next_available_channel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENV_INCLUDE_INA219
|
||||
if (INA219_initialized) {
|
||||
telemetry.addVoltage(next_available_channel, INA219.getBusVoltage_V());
|
||||
telemetry.addCurrent(next_available_channel, INA219.getCurrent_mA() / 1000);
|
||||
telemetry.addPower(next_available_channel, INA219.getPower_mW() / 1000);
|
||||
next_available_channel++;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int EnvironmentSensorManager::getNumSettings() const {
|
||||
#if ENV_INCLUDE_GPS
|
||||
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* EnvironmentSensorManager::getSettingName(int i) const {
|
||||
#if ENV_INCLUDE_GPS
|
||||
return (gps_detected && i == 0) ? "gps" : NULL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
||||
#if ENV_INCLUDE_GPS
|
||||
if (gps_detected && i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool EnvironmentSensorManager::setSettingValue(const char* name, const char* value) {
|
||||
#if ENV_INCLUDE_GPS
|
||||
if (gps_detected && strcmp(name, "gps") == 0) {
|
||||
if (strcmp(value, "0") == 0) {
|
||||
stop_gps();
|
||||
} else {
|
||||
start_gps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
void EnvironmentSensorManager::initBasicGPS() {
|
||||
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX);
|
||||
Serial1.begin(9600);
|
||||
|
||||
// Try to detect if GPS is physically connected to determine if we should expose the setting
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, HIGH); // Power on GPS
|
||||
|
||||
// Give GPS a moment to power up and send data
|
||||
delay(1000);
|
||||
|
||||
// We'll consider GPS detected if we see any data on Serial1
|
||||
gps_detected = (Serial1.available() > 0);
|
||||
|
||||
if (gps_detected) {
|
||||
MESH_DEBUG_PRINTLN("GPS detected");
|
||||
digitalWrite(PIN_GPS_EN, LOW); // Power off GPS until the setting is changed
|
||||
} else {
|
||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
||||
digitalWrite(PIN_GPS_EN, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void EnvironmentSensorManager::start_gps() {
|
||||
gps_active = true;
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, HIGH);
|
||||
}
|
||||
|
||||
void EnvironmentSensorManager::stop_gps() {
|
||||
gps_active = false;
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, LOW);
|
||||
}
|
||||
|
||||
void EnvironmentSensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
_location->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
42
src/helpers/sensors/EnvironmentSensorManager.h
Normal file
42
src/helpers/sensors/EnvironmentSensorManager.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <Mesh.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
class EnvironmentSensorManager : public SensorManager {
|
||||
protected:
|
||||
int next_available_channel = TELEM_CHANNEL_SELF + 1;
|
||||
|
||||
bool AHTX0_initialized = false;
|
||||
bool BME280_initialized = false;
|
||||
bool INA3221_initialized = false;
|
||||
bool INA219_initialized = false;
|
||||
|
||||
bool gps_detected = false;
|
||||
bool gps_active = false;
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
LocationProvider* _location;
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
void initBasicGPS();
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
#if ENV_INCLUDE_GPS
|
||||
EnvironmentSensorManager(LocationProvider &location): _location(&location){};
|
||||
#else
|
||||
EnvironmentSensorManager(){};
|
||||
#endif
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||
#if ENV_INCLUDE_GPS
|
||||
void loop() override;
|
||||
#endif
|
||||
int getNumSettings() const override;
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
};
|
||||
@@ -8,6 +8,7 @@ class LocationProvider {
|
||||
public:
|
||||
virtual long getLatitude() = 0;
|
||||
virtual long getLongitude() = 0;
|
||||
virtual long getAltitude() = 0;
|
||||
virtual bool isValid() = 0;
|
||||
virtual long getTimestamp() = 0;
|
||||
virtual void reset();
|
||||
|
||||
@@ -61,6 +61,11 @@ public :
|
||||
|
||||
long getLatitude() override { return nmea.getLatitude(); }
|
||||
long getLongitude() override { return nmea.getLongitude(); }
|
||||
long getAltitude() override {
|
||||
long alt = 0;
|
||||
nmea.getAltitude(alt);
|
||||
return alt;
|
||||
}
|
||||
bool isValid() override { return nmea.isValid(); }
|
||||
|
||||
long getTimestamp() override {
|
||||
|
||||
@@ -126,6 +126,9 @@ InternalFileSystem::InternalFileSystem(void)
|
||||
|
||||
bool InternalFileSystem::begin(void)
|
||||
{
|
||||
#ifdef FORMAT_FS
|
||||
this->format();
|
||||
#endif
|
||||
// failed to mount, erase all sector then format and mount again
|
||||
if ( !Adafruit_LittleFS::begin() )
|
||||
{
|
||||
|
||||
91
src/helpers/ui/SH1106Display.cpp
Normal file
91
src/helpers/ui/SH1106Display.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include "SH1106Display.h"
|
||||
#include <Adafruit_GrayOLED.h>
|
||||
#include "Adafruit_SH110X.h"
|
||||
|
||||
bool SH1106Display::i2c_probe(TwoWire &wire, uint8_t addr)
|
||||
{
|
||||
wire.beginTransmission(addr);
|
||||
uint8_t error = wire.endTransmission();
|
||||
return (error == 0);
|
||||
}
|
||||
|
||||
bool SH1106Display::begin()
|
||||
{
|
||||
return display.begin(DISPLAY_ADDRESS, true) && i2c_probe(Wire, DISPLAY_ADDRESS);
|
||||
}
|
||||
|
||||
void SH1106Display::turnOn()
|
||||
{
|
||||
display.oled_command(SH110X_DISPLAYON);
|
||||
_isOn = true;
|
||||
}
|
||||
|
||||
void SH1106Display::turnOff()
|
||||
{
|
||||
display.oled_command(SH110X_DISPLAYOFF);
|
||||
_isOn = false;
|
||||
}
|
||||
|
||||
void SH1106Display::clear()
|
||||
{
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
}
|
||||
|
||||
void SH1106Display::startFrame(Color bkg)
|
||||
{
|
||||
display.clearDisplay(); // TODO: apply 'bkg'
|
||||
_color = SH110X_WHITE;
|
||||
display.setTextColor(_color);
|
||||
display.setTextSize(1);
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
}
|
||||
|
||||
void SH1106Display::setTextSize(int sz)
|
||||
{
|
||||
display.setTextSize(sz);
|
||||
}
|
||||
|
||||
void SH1106Display::setColor(Color c)
|
||||
{
|
||||
_color = (c != 0) ? SH110X_WHITE : SH110X_BLACK;
|
||||
display.setTextColor(_color);
|
||||
}
|
||||
|
||||
void SH1106Display::setCursor(int x, int y)
|
||||
{
|
||||
display.setCursor(x, y);
|
||||
}
|
||||
|
||||
void SH1106Display::print(const char *str)
|
||||
{
|
||||
display.print(str);
|
||||
}
|
||||
|
||||
void SH1106Display::fillRect(int x, int y, int w, int h)
|
||||
{
|
||||
display.fillRect(x, y, w, h, _color);
|
||||
}
|
||||
|
||||
void SH1106Display::drawRect(int x, int y, int w, int h)
|
||||
{
|
||||
display.drawRect(x, y, w, h, _color);
|
||||
}
|
||||
|
||||
void SH1106Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h)
|
||||
{
|
||||
display.drawBitmap(x, y, bits, w, h, SH110X_WHITE);
|
||||
}
|
||||
|
||||
uint16_t SH1106Display::getTextWidth(const char *str)
|
||||
{
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
void SH1106Display::endFrame()
|
||||
{
|
||||
display.display();
|
||||
}
|
||||
43
src/helpers/ui/SH1106Display.h
Normal file
43
src/helpers/ui/SH1106Display.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "DisplayDriver.h"
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#define SH110X_NO_SPLASH
|
||||
#include <Adafruit_SH110X.h>
|
||||
|
||||
#ifndef PIN_OLED_RESET
|
||||
#define PIN_OLED_RESET -1
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_ADDRESS
|
||||
#define DISPLAY_ADDRESS 0x3C
|
||||
#endif
|
||||
|
||||
class SH1106Display : public DisplayDriver
|
||||
{
|
||||
Adafruit_SH1106G display;
|
||||
bool _isOn;
|
||||
uint8_t _color;
|
||||
|
||||
bool i2c_probe(TwoWire &wire, uint8_t addr);
|
||||
|
||||
public:
|
||||
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
|
||||
bool begin();
|
||||
|
||||
bool isOn() override { return _isOn; }
|
||||
void turnOn() override;
|
||||
void turnOff() override;
|
||||
void clear() override;
|
||||
void startFrame(Color bkg = DARK) override;
|
||||
void setTextSize(int sz) override;
|
||||
void setColor(Color c) override;
|
||||
void setCursor(int x, int y) override;
|
||||
void print(const char *str) override;
|
||||
void fillRect(int x, int y, int w, int h) override;
|
||||
void drawRect(int x, int y, int w, int h) override;
|
||||
void drawXbm(int x, int y, const uint8_t *bits, int w, int h) override;
|
||||
uint16_t getTextWidth(const char *str) override;
|
||||
void endFrame() override;
|
||||
};
|
||||
@@ -1,5 +1,3 @@
|
||||
#ifdef ST7735
|
||||
|
||||
#include "ST7735Display.h"
|
||||
|
||||
#ifndef DISPLAY_ROTATION
|
||||
@@ -130,5 +128,3 @@ uint16_t ST7735Display::getTextWidth(const char* str) {
|
||||
void ST7735Display::endFrame() {
|
||||
// display.display();
|
||||
}
|
||||
|
||||
#endif
|
||||
54
src/helpers/ui/buzzer.cpp
Normal file
54
src/helpers/ui/buzzer.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifdef PIN_BUZZER
|
||||
#include "buzzer.h"
|
||||
|
||||
void genericBuzzer::begin() {
|
||||
// Serial.print("DBG: Setting up buzzer on pin ");
|
||||
// Serial.println(PIN_BUZZER);
|
||||
#ifdef PIN_BUZZER_EN
|
||||
pinMode(PIN_BUZZER_EN, OUTPUT);
|
||||
digitalWrite(PIN_BUZZER_EN, HIGH);
|
||||
#endif
|
||||
|
||||
quiet(false);
|
||||
pinMode(PIN_BUZZER, OUTPUT);
|
||||
startup();
|
||||
}
|
||||
|
||||
void genericBuzzer::play(const char *melody) {
|
||||
if (isPlaying()) // interrupt existing
|
||||
{
|
||||
rtttl::stop();
|
||||
}
|
||||
|
||||
if (_is_quiet) return;
|
||||
|
||||
rtttl::begin(PIN_BUZZER,melody);
|
||||
// Serial.print("DBG: Playing melody - isQuiet: ");
|
||||
// Serial.println(isQuiet());
|
||||
}
|
||||
|
||||
bool genericBuzzer::isPlaying() {
|
||||
return rtttl::isPlaying();
|
||||
}
|
||||
|
||||
void genericBuzzer::loop() {
|
||||
if (!rtttl::done()) rtttl::play();
|
||||
}
|
||||
|
||||
void genericBuzzer::startup() {
|
||||
play(startup_song);
|
||||
}
|
||||
|
||||
void genericBuzzer::shutdown() {
|
||||
play(shutdown_song);
|
||||
}
|
||||
|
||||
void genericBuzzer::quiet(bool buzzer_state) {
|
||||
_is_quiet = buzzer_state;
|
||||
}
|
||||
|
||||
bool genericBuzzer::isQuiet() {
|
||||
return _is_quiet;
|
||||
}
|
||||
|
||||
#endif // ifdef PIN_BUZZER
|
||||
37
src/helpers/ui/buzzer.h
Normal file
37
src/helpers/ui/buzzer.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <NonBlockingRtttl.h>
|
||||
|
||||
/* class abstracts underlying RTTTL library
|
||||
|
||||
Just a simple imlementation to start. At the moment use same
|
||||
melody for message and discovery
|
||||
Suggest enum type for different sounds
|
||||
- on message
|
||||
- on discovery
|
||||
|
||||
TODO
|
||||
- make message ring tone configurable
|
||||
|
||||
*/
|
||||
|
||||
class genericBuzzer
|
||||
{
|
||||
public:
|
||||
void begin(); // set up buzzer port
|
||||
void play(const char *melody); // Generic play function
|
||||
void loop(); // loop driven-nonblocking
|
||||
void startup(); // play startup sound
|
||||
void shutdown(); // play shutdown sound
|
||||
bool isPlaying(); // returns true if a sound is still playing else false
|
||||
void quiet(bool buzzer_state); // enables or disables the buzzer
|
||||
bool isQuiet(); // get buzzer state on/off
|
||||
|
||||
private:
|
||||
// gemini's picks:
|
||||
const char *startup_song = "Startup:d=4,o=5,b=160:16c6,16e6,8g6";
|
||||
const char *shutdown_song = "Shutdown:d=4,o=5,b=100:8g5,16e5,16c5";
|
||||
|
||||
bool _is_quiet = true;
|
||||
};
|
||||
@@ -31,6 +31,8 @@ build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/heltec_tracker>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
|
||||
|
||||
[env:Heltec_Wireless_Tracker_companion_radio_ble]
|
||||
extends = Heltec_tracker_base
|
||||
@@ -38,7 +40,6 @@ build_flags =
|
||||
${Heltec_tracker_base.build_flags}
|
||||
-I src/helpers/ui
|
||||
; -D ARDUINO_USB_CDC_ON_BOOT=1 ; need for debugging
|
||||
-D ST7735
|
||||
-D DISPLAY_ROTATION=1
|
||||
-D DISPLAY_CLASS=ST7735Display
|
||||
-D MAX_CONTACTS=100
|
||||
@@ -57,5 +58,43 @@ build_src_filter = ${Heltec_tracker_base.build_src_filter}
|
||||
lib_deps =
|
||||
${Heltec_tracker_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
|
||||
|
||||
[env:Heltec_Wireless_Tracker_repeater]
|
||||
extends = Heltec_tracker_base
|
||||
build_flags =
|
||||
${Heltec_tracker_base.build_flags}
|
||||
-D DISPLAY_ROTATION=1
|
||||
-D DISPLAY_CLASS=ST7735Display
|
||||
-D ADVERT_NAME='"Heltec Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_tracker_base.build_src_filter}
|
||||
+<helpers/ui/ST7735Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${Heltec_tracker_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Heltec_Wireless_Tracker_room_server]
|
||||
extends = Heltec_tracker_base
|
||||
build_flags =
|
||||
${Heltec_tracker_base.build_flags}
|
||||
-D DISPLAY_ROTATION=1
|
||||
-D DISPLAY_CLASS=ST7735Display
|
||||
-D ADVERT_NAME='"Heltec Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_tracker_base.build_src_filter}
|
||||
+<helpers/ui/ST7735Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${Heltec_tracker_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
@@ -19,6 +19,10 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
HWTSensorManager sensors = HWTSensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display(&board.periph_power); // peripheral power pin is shared
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -103,7 +107,7 @@ bool HWTSensorManager::begin() {
|
||||
|
||||
bool HWTSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f);
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -117,6 +121,7 @@ void HWTSensorManager::loop() {
|
||||
if (gps_active && _location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7735Display.h>
|
||||
#endif
|
||||
|
||||
class HWTSensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
@@ -31,6 +34,10 @@ extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern HWTSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern HeltecV2Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern HeltecV3Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern ESP32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -7,6 +7,7 @@ build_flags =
|
||||
-D LILYGO_TBEAM
|
||||
-D RADIO_CLASS=CustomSX1276
|
||||
-D WRAPPER_CLASS=CustomSX1276Wrapper
|
||||
-D SX127X_CURRENT_LIMIT=120
|
||||
-D LORA_TX_POWER=20
|
||||
-D P_LORA_TX_LED=4
|
||||
-D PIN_BOARD_SDA=21
|
||||
@@ -31,8 +32,6 @@ build_flags =
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
; -D RADIOLIB_DEBUG_BASIC=1
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
; -D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern TBeamBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern TBeamBoardSX1262 board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -6,10 +6,13 @@ build_flags =
|
||||
-I variants/lilygo_tbeam_supreme_SX1262
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=6
|
||||
-D PIN_BOARD_SDA=17
|
||||
-D PIN_BOARD_SCL=18
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
;-D DISPLAY_CLASS=SSD1306Display ;Needs to be modified for SH1106
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/lilygo_tbeam_supreme_SX1262>
|
||||
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
|
||||
|
||||
@@ -27,7 +27,68 @@ TbeamSupSensorManager sensors = TbeamSupSensorManager(nmea);
|
||||
static void setPMUIntFlag(){
|
||||
pmuIntFlag = true;
|
||||
}
|
||||
|
||||
#ifdef MESH_DEBUG
|
||||
uint32_t deviceOnline = 0x00;
|
||||
void scanDevices(TwoWire *w)
|
||||
{
|
||||
uint8_t err, addr;
|
||||
int nDevices = 0;
|
||||
uint32_t start = 0;
|
||||
|
||||
Serial.println("Scanning I2C for Devices");
|
||||
for (addr = 1; addr < 127; addr++) {
|
||||
start = millis();
|
||||
w->beginTransmission(addr); delay(2);
|
||||
err = w->endTransmission();
|
||||
if (err == 0) {
|
||||
nDevices++;
|
||||
switch (addr) {
|
||||
case 0x77:
|
||||
case 0x76:
|
||||
Serial.println("\tFound BMX280 Sensor");
|
||||
deviceOnline |= BME280_ONLINE;
|
||||
break;
|
||||
case 0x34:
|
||||
Serial.println("\tFound AXP192/AXP2101 PMU");
|
||||
deviceOnline |= POWERMANAGE_ONLINE;
|
||||
break;
|
||||
case 0x3C:
|
||||
Serial.println("\tFound SSD1306/SH1106 dispaly");
|
||||
deviceOnline |= DISPLAY_ONLINE;
|
||||
break;
|
||||
case 0x51:
|
||||
Serial.println("\tFound PCF8563 RTC");
|
||||
deviceOnline |= PCF8563_ONLINE;
|
||||
break;
|
||||
case 0x1C:
|
||||
Serial.println("\tFound QMC6310 MAG Sensor");
|
||||
deviceOnline |= QMC6310_ONLINE;
|
||||
break;
|
||||
default:
|
||||
Serial.print("\tI2C device found at address 0x");
|
||||
if (addr < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(addr, HEX);
|
||||
Serial.println(" !");
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (err == 4) {
|
||||
Serial.print("Unknow error at address 0x");
|
||||
if (addr < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.println(addr, HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
|
||||
Serial.println("Scan for devices is complete.");
|
||||
Serial.println("\n");
|
||||
}
|
||||
void TBeamS3SupremeBoard::printPMU()
|
||||
{
|
||||
Serial.print("isCharging:"); Serial.println(PMU.isCharging() ? "YES" : "NO");
|
||||
@@ -58,9 +119,9 @@ bool TBeamS3SupremeBoard::power_init()
|
||||
PMU.setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
|
||||
|
||||
// Set up PMU interrupts
|
||||
MESH_DEBUG_PRINTLN("Setting up PMU interrupts");
|
||||
pinMode(PIN_PMU_IRQ, INPUT_PULLUP);
|
||||
attachInterrupt(PIN_PMU_IRQ, setPMUIntFlag, FALLING);
|
||||
// MESH_DEBUG_PRINTLN("Setting up PMU interrupts");
|
||||
// pinMode(PIN_PMU_IRQ, INPUT_PULLUP);
|
||||
// attachInterrupt(PIN_PMU_IRQ, setPMUIntFlag, FALLING);
|
||||
|
||||
// GPS
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling a-ldo4 for GPS");
|
||||
@@ -73,74 +134,83 @@ bool TBeamS3SupremeBoard::power_init()
|
||||
PMU.enableALDO3();
|
||||
|
||||
// To avoid SPI bus issues during power up, reset OLED, sensor, and SD card supplies
|
||||
MESH_DEBUG_PRINTLN("Reset a-ldo1&2 and b-ldo1");
|
||||
if (ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause())
|
||||
{
|
||||
PMU.disableALDO1();
|
||||
PMU.disableALDO2();
|
||||
PMU.disableBLDO1();
|
||||
delay(250);
|
||||
}
|
||||
// MESH_DEBUG_PRINTLN("Reset a-ldo1&2 and b-ldo1");
|
||||
// if (ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause())
|
||||
// {
|
||||
// PMU.disableALDO1();
|
||||
// PMU.disableALDO2();
|
||||
// PMU.disableBLDO1();
|
||||
// delay(250);
|
||||
// }
|
||||
|
||||
// BME280 and OLED
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling a-ldo1 for oled");
|
||||
PMU.setALDO1Voltage(3300);
|
||||
PMU.enableALDO1();
|
||||
// m.2 interface
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling dcdc3 for m.2 interface");
|
||||
PMU.setDC3Voltage(3300); // doesn't go anywhere in the schematic??
|
||||
PMU.enableDC3();
|
||||
|
||||
// QMC6310U
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling a-ldo2 for QMC");
|
||||
PMU.setALDO2Voltage(3300);
|
||||
PMU.enableALDO2(); // disable to save power
|
||||
|
||||
// BME280 and OLED
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling a-ldo1 for oled");
|
||||
PMU.setALDO1Voltage(3300);
|
||||
PMU.enableALDO1();
|
||||
|
||||
// SD card
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling b-ldo2 for SD card");
|
||||
PMU.setBLDO1Voltage(3300);
|
||||
PMU.enableBLDO1();
|
||||
|
||||
// Out to header pins
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling b-ldo2 for output to header");
|
||||
PMU.setBLDO2Voltage(3300);
|
||||
PMU.enableBLDO2();
|
||||
// MESH_DEBUG_PRINTLN("Setting and enabling b-ldo2 for output to header");
|
||||
// PMU.setBLDO2Voltage(3300);
|
||||
// PMU.enableBLDO2();
|
||||
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling dcdc4 for output to header");
|
||||
PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); // 1.8V
|
||||
PMU.enableDC4();
|
||||
// MESH_DEBUG_PRINTLN("Setting and enabling dcdc4 for output to header");
|
||||
// PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); // 1.8V
|
||||
// PMU.enableDC4();
|
||||
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling dcdc5 for output to header");
|
||||
PMU.setDC5Voltage(3300);
|
||||
PMU.enableDC5();
|
||||
|
||||
// Other power rails
|
||||
MESH_DEBUG_PRINTLN("Setting and enabling dcdc3 for ?");
|
||||
PMU.setDC3Voltage(3300); // doesn't go anywhere in the schematic??
|
||||
PMU.enableDC3();
|
||||
// MESH_DEBUG_PRINTLN("Setting and enabling dcdc5 for output to header");
|
||||
// PMU.setDC5Voltage(3300);
|
||||
// PMU.enableDC5();
|
||||
|
||||
// Unused power rails
|
||||
MESH_DEBUG_PRINTLN("Disabling unused supplies dcdc2, dldo1 and dldo2");
|
||||
PMU.disableDC2();
|
||||
PMU.disableDC5();
|
||||
PMU.disableDLDO1();
|
||||
PMU.disableDLDO2();
|
||||
|
||||
// Set charge current to 300mA
|
||||
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
|
||||
// Set charge current to 500mA
|
||||
MESH_DEBUG_PRINTLN("Setting battery charge current limit and voltage");
|
||||
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_500MA);
|
||||
PMU.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
|
||||
PMU.clearIrqStatus();
|
||||
PMU.disableTSPinMeasure();
|
||||
|
||||
// enable battery voltage measurement
|
||||
MESH_DEBUG_PRINTLN("Enabling battery measurement");
|
||||
PMU.enableBattVoltageMeasure();
|
||||
PMU.enableVbusVoltageMeasure();
|
||||
|
||||
// Reset and re-enable PMU interrupts
|
||||
MESH_DEBUG_PRINTLN("Re-enable interrupts");
|
||||
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
PMU.clearIrqStatus();
|
||||
PMU.enableIRQ(
|
||||
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | // Battery interrupts
|
||||
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | // VBUS interrupts
|
||||
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | // Power Key interrupts
|
||||
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ // Charging interrupts
|
||||
);
|
||||
// MESH_DEBUG_PRINTLN("Re-enable interrupts");
|
||||
// PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
// PMU.clearIrqStatus();
|
||||
// PMU.enableIRQ(
|
||||
// XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | // Battery interrupts
|
||||
// XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | // VBUS interrupts
|
||||
// XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | // Power Key interrupts
|
||||
// XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ // Charging interrupts
|
||||
// );
|
||||
#ifdef MESH_DEBUG
|
||||
// scanDevices(&Wire);
|
||||
// scanDevices(&Wire1);
|
||||
printPMU();
|
||||
#endif
|
||||
|
||||
@@ -217,7 +287,7 @@ static bool l76kProbe()
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
Wire1.begin(PIN_BOARD_SDA1,PIN_BOARD_SCL1);
|
||||
|
||||
rtc_clock.begin(Wire1);
|
||||
|
||||
#ifdef SX126X_DIO3_TCXO_VOLTAGE
|
||||
@@ -287,7 +357,7 @@ bool TbeamSupSensorManager::begin() {
|
||||
|
||||
bool TbeamSupSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f);
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -301,6 +371,7 @@ void TbeamSupSensorManager::loop() {
|
||||
if (_nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
|
||||
@@ -12,6 +12,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern LilyGoTLoraBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
102
variants/nano_g2_ultra/nano-g2.cpp
Normal file
102
variants/nano_g2_ultra/nano-g2.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
#include <Arduino.h>
|
||||
#include "nano-g2.h"
|
||||
|
||||
#ifdef NANO_G2_ULTRA
|
||||
|
||||
#include <bluefruit.h>
|
||||
#include <Wire.h>
|
||||
|
||||
static BLEDfu bledfu;
|
||||
|
||||
static void connect_callback(uint16_t conn_handle)
|
||||
{
|
||||
(void)conn_handle;
|
||||
MESH_DEBUG_PRINTLN("BLE client connected");
|
||||
}
|
||||
|
||||
static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
{
|
||||
(void)conn_handle;
|
||||
(void)reason;
|
||||
|
||||
MESH_DEBUG_PRINTLN("BLE client disconnected");
|
||||
}
|
||||
|
||||
void NanoG2Ultra::begin()
|
||||
{
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
// set user button
|
||||
pinMode(PIN_BUTTON1, INPUT);
|
||||
|
||||
// the external notification circuit is shared for both buzzer and led
|
||||
pinMode(EXT_NOTIFY_OUT, OUTPUT);
|
||||
digitalWrite(EXT_NOTIFY_OUT, LOW);
|
||||
|
||||
Wire.begin();
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
uint16_t NanoG2Ultra::getBattMilliVolts()
|
||||
{
|
||||
int adcvalue = 0;
|
||||
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
|
||||
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
// Convert the raw value to compensated mv, taking the resistor-
|
||||
// divider into account (providing the actual LIPO voltage)
|
||||
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
|
||||
}
|
||||
|
||||
bool NanoG2Ultra::startOTAUpdate(const char *id, char reply[])
|
||||
{
|
||||
// Config the peripheral connection with maximum bandwidth
|
||||
// more SRAM required by SoftDevice
|
||||
// Note: All config***() function must be called before begin()
|
||||
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
|
||||
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
|
||||
|
||||
Bluefruit.begin(1, 0);
|
||||
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
|
||||
Bluefruit.setTxPower(4);
|
||||
// Set the BLE device name
|
||||
Bluefruit.setName("TECHO_OTA");
|
||||
|
||||
Bluefruit.Periph.setConnectCallback(connect_callback);
|
||||
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
|
||||
|
||||
// To be consistent OTA DFU should be added first if it exists
|
||||
bledfu.begin();
|
||||
|
||||
// Set up and start advertising
|
||||
// Advertising packet
|
||||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
||||
Bluefruit.Advertising.addTxPower();
|
||||
Bluefruit.Advertising.addName();
|
||||
|
||||
/* Start Advertising
|
||||
- Enable auto advertising if disconnected
|
||||
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
|
||||
- Timeout for fast mode is 30 seconds
|
||||
- Start(timeout) with timeout = 0 will advertise forever (until connected)
|
||||
|
||||
For recommended advertising interval
|
||||
https://developer.apple.com/library/content/qa/qa1931/_index.html
|
||||
*/
|
||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||
|
||||
strcpy(reply, "OK - started");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
57
variants/nano_g2_ultra/nano-g2.h
Normal file
57
variants/nano_g2_ultra/nano-g2.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// LoRa radio module pins
|
||||
#define P_LORA_DIO_1 (32 + 10)
|
||||
#define P_LORA_NSS (32 + 13)
|
||||
#define P_LORA_RESET (32 + 15)
|
||||
#define P_LORA_BUSY (32 + 11)
|
||||
#define P_LORA_SCLK (0 + 12)
|
||||
#define P_LORA_MISO (32 + 9)
|
||||
#define P_LORA_MOSI (0 + 11)
|
||||
|
||||
#define SX126X_DIO2_AS_RF_SWITCH true
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
#define SX126X_POWER_EN 37
|
||||
|
||||
// buttons
|
||||
#define PIN_BUTTON1 (32 + 6)
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
#define PIN_USER_BTN BUTTON_PIN
|
||||
|
||||
// built-ins
|
||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||
|
||||
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT, actually 100K + 100K
|
||||
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
|
||||
|
||||
#define PIN_VBAT_READ (0 + 2)
|
||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||
|
||||
class NanoG2Ultra : public mesh::MainBoard
|
||||
{
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
uint16_t getBattMilliVolts() override;
|
||||
bool startOTAUpdate(const char *id, char reply[]) override;
|
||||
|
||||
uint8_t getStartupReason() const override
|
||||
{
|
||||
return startup_reason;
|
||||
}
|
||||
|
||||
const char *getManufacturerName() const override
|
||||
{
|
||||
return "Nano G2 Ultra";
|
||||
}
|
||||
|
||||
void reboot() override
|
||||
{
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
};
|
||||
59
variants/nano_g2_ultra/platformio.ini
Normal file
59
variants/nano_g2_ultra/platformio.ini
Normal file
@@ -0,0 +1,59 @@
|
||||
[nrf52840_g2_ultra]
|
||||
extends = nrf52_base
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
lewisxhe/PCF8563_Library@^1.0.1
|
||||
|
||||
[Nano_G2_Ultra]
|
||||
extends = nrf52840_g2_ultra
|
||||
board = nano-g2-ultra
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52840_g2_ultra.build_flags}
|
||||
-I variants/nano_g2_ultra
|
||||
-D NANO_G2_ULTRA
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_USER_BTN=38
|
||||
build_src_filter = ${nrf52840_g2_ultra.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<../variants/nano_g2_ultra>
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:Nano_G2_Ultra_companion_radio_ble]
|
||||
extends = Nano_G2_Ultra
|
||||
build_flags =
|
||||
${Nano_G2_Ultra.build_flags}
|
||||
-I src/helpers/ui
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=0
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D PIN_BUZZER=4
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
; -D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Nano_G2_Ultra.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/SH1106Display.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<../examples/companion_radio>
|
||||
lib_deps =
|
||||
${Nano_G2_Ultra.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
adafruit/Adafruit SH110X @ ~2.1.13
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
183
variants/nano_g2_ultra/target.cpp
Normal file
183
variants/nano_g2_ultra/target.cpp
Normal file
@@ -0,0 +1,183 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
NanoG2Ultra board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init()
|
||||
{
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#ifdef SX126X_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
|
||||
SPI.begin();
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
|
||||
if (status != RADIOLIB_ERR_NONE)
|
||||
{
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
#ifdef SX126X_CURRENT_LIMIT
|
||||
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
|
||||
#endif
|
||||
#ifdef SX126X_DIO2_AS_RF_SWITCH
|
||||
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
|
||||
#endif
|
||||
#ifdef SX126X_RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed()
|
||||
{
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr)
|
||||
{
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm)
|
||||
{
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
void NanoG2UltraSensorManager::start_gps()
|
||||
{
|
||||
if (!gps_active)
|
||||
{
|
||||
MESH_DEBUG_PRINTLN("starting GPS");
|
||||
digitalWrite(PIN_GPS_STANDBY, HIGH);
|
||||
gps_active = true;
|
||||
}
|
||||
}
|
||||
|
||||
void NanoG2UltraSensorManager::stop_gps()
|
||||
{
|
||||
if (gps_active)
|
||||
{
|
||||
MESH_DEBUG_PRINTLN("stopping GPS");
|
||||
digitalWrite(PIN_GPS_STANDBY, LOW);
|
||||
gps_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool NanoG2UltraSensorManager::begin()
|
||||
{
|
||||
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX); // be sure to tx into rx and rx into tx
|
||||
Serial1.begin(115200);
|
||||
|
||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
||||
digitalWrite(PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
|
||||
delay(500);
|
||||
|
||||
// We'll consider GPS detected if we see any data on Serial1
|
||||
if (Serial1.available() > 0)
|
||||
{
|
||||
MESH_DEBUG_PRINTLN("GPS detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
||||
}
|
||||
digitalWrite(GPS_EN, LOW); // Put GPS back into standby mode
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NanoG2UltraSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP &telemetry)
|
||||
{
|
||||
if (requester_permissions & TELEM_PERM_LOCATION)
|
||||
{ // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NanoG2UltraSensorManager::loop()
|
||||
{
|
||||
static long next_gps_update = 0;
|
||||
_location->loop();
|
||||
if (millis() > next_gps_update && gps_active) // don't bother if gps position is not enabled
|
||||
{
|
||||
if (_location->isValid())
|
||||
{
|
||||
node_lat = ((double)_location->getLatitude()) / 1000000.;
|
||||
node_lon = ((double)_location->getLongitude()) / 1000000.;
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
}
|
||||
next_gps_update = millis() + (1000 * 60); // after initial update, only check every minute TODO: should be configurable
|
||||
}
|
||||
}
|
||||
|
||||
int NanoG2UltraSensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
|
||||
|
||||
const char *NanoG2UltraSensorManager::getSettingName(int i) const
|
||||
{
|
||||
return i == 0 ? "gps" : NULL;
|
||||
}
|
||||
|
||||
const char *NanoG2UltraSensorManager::getSettingValue(int i) const
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool NanoG2UltraSensorManager::setSettingValue(const char *name, const char *value)
|
||||
{
|
||||
if (strcmp(name, "gps") == 0)
|
||||
{
|
||||
if (strcmp(value, "0") == 0)
|
||||
{
|
||||
stop_gps();
|
||||
}
|
||||
else
|
||||
{
|
||||
start_gps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity()
|
||||
{
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
47
variants/nano_g2_ultra/target.h
Normal file
47
variants/nano_g2_ultra/target.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include "nano-g2.h"
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SH1106Display.h>
|
||||
#endif
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
class NanoG2UltraSensorManager : public SensorManager
|
||||
{
|
||||
bool gps_active = false;
|
||||
LocationProvider *_location;
|
||||
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
|
||||
public:
|
||||
NanoG2UltraSensorManager(LocationProvider &location) : _location(&location) {}
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP &telemetry) override;
|
||||
void loop() override;
|
||||
int getNumSettings() const override;
|
||||
const char *getSettingName(int i) const override;
|
||||
const char *getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char *name, const char *value) override;
|
||||
};
|
||||
|
||||
extern NanoG2Ultra board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern NanoG2UltraSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
36
variants/nano_g2_ultra/variant.cpp
Normal file
36
variants/nano_g2_ultra/variant.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
// P0 - pins 0 and 1 are hardwired for xtal and should never be enabled
|
||||
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
|
||||
// P1
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
// Nothing need to be inited for now
|
||||
}
|
||||
193
variants/nano_g2_ultra/variant.h
Normal file
193
variants/nano_g2_ultra/variant.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_Nano_G2_
|
||||
#define _VARIANT_Nano_G2_
|
||||
|
||||
/** Master clock frequency */
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||
// #define USE_LFRC // Board uses 32khz RC for LF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
// Number of pins defined in PinDescription array
|
||||
#define PINS_COUNT (48)
|
||||
#define NUM_DIGITAL_PINS (48)
|
||||
#define NUM_ANALOG_INPUTS (1)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED1 (-1)
|
||||
#define PIN_LED2 (-1)
|
||||
#define PIN_LED3 (-1)
|
||||
|
||||
#define LED_RED PIN_LED3
|
||||
#define LED_BLUE PIN_LED1
|
||||
#define LED_GREEN PIN_LED2
|
||||
|
||||
#define LED_BUILTIN LED_BLUE
|
||||
#define LED_CONN PIN_GREEN
|
||||
|
||||
#define LED_STATE_ON 0 // State when LED is lit
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
#define PIN_BUTTON1 (32 + 6)
|
||||
|
||||
#define EXT_NOTIFY_OUT (0 + 4) // Default pin to use for Ext Notify Module.
|
||||
|
||||
/*
|
||||
* Analog pins
|
||||
*/
|
||||
#define PIN_A4 (0 + 2) // Battery ADC
|
||||
|
||||
#define BATTERY_PIN PIN_A4
|
||||
|
||||
static const uint8_t A4 = PIN_A4;
|
||||
|
||||
#define ADC_RESOLUTION 14
|
||||
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
#define PIN_SERIAL2_RX (0 + 22)
|
||||
#define PIN_SERIAL2_TX (0 + 20)
|
||||
|
||||
/**
|
||||
Wire Interfaces
|
||||
*/
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_WIRE_SDA (0 + 17)
|
||||
#define PIN_WIRE_SCL (0 + 15)
|
||||
|
||||
#define PIN_RTC_INT (0 + 14) // Interrupt from the PCF8563 RTC
|
||||
|
||||
/*
|
||||
External serial flash W25Q16JV_IQ
|
||||
*/
|
||||
|
||||
// QSPI Pins
|
||||
#define PIN_QSPI_SCK (0 + 8)
|
||||
#define PIN_QSPI_CS (32 + 7)
|
||||
#define PIN_QSPI_IO0 (0 + 6) // MOSI if using two bit interface
|
||||
#define PIN_QSPI_IO1 (0 + 26) // MISO if using two bit interface
|
||||
#define PIN_QSPI_IO2 (32 + 4) // WP if using two bit interface (i.e. not used)
|
||||
#define PIN_QSPI_IO3 (32 + 2) // HOLD if using two bit interface (i.e. not used)
|
||||
|
||||
// On-board QSPI Flash
|
||||
#define EXTERNAL_FLASH_DEVICES W25Q16JV_IQ
|
||||
#define EXTERNAL_FLASH_USE_QSPI
|
||||
|
||||
/*
|
||||
* Lora radio
|
||||
*/
|
||||
|
||||
#define USE_SX1262
|
||||
#define SX126X_CS (32 + 13) // FIXME - we really should define LORA_CS instead
|
||||
#define SX126X_DIO1 (32 + 10)
|
||||
// Note DIO2 is attached internally to the module to an analog switch for TX/RX switching
|
||||
// #define SX1262_DIO3 (0 + 21)
|
||||
// This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the main CPU?
|
||||
#define SX126X_BUSY (32 + 11)
|
||||
#define SX126X_RESET (32 + 15)
|
||||
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
||||
#define SX126X_DIO2_AS_RF_SWITCH
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
// #define LORA_DISABLE_SENDING // Define this to disable transmission for testing (power testing etc...)
|
||||
|
||||
// #undef SX126X_CS
|
||||
|
||||
/*
|
||||
* GPS pins
|
||||
*/
|
||||
|
||||
#define HAS_GPS 1
|
||||
#define GPS_L76K
|
||||
|
||||
#define PIN_GPS_STANDBY (0 + 13) // An output to wake GPS, low means allow sleep, high means force wake STANDBY
|
||||
#define PIN_GPS_TX (0 + 9) // This is for bits going TOWARDS the CPU
|
||||
#define PIN_GPS_RX (0 + 10) // This is for bits going TOWARDS the GPS
|
||||
#define GPS_RX_PIN PIN_GPS_RX
|
||||
#define GPS_TX_PIN PIN_GPS_TX
|
||||
|
||||
|
||||
// #define GPS_THREAD_INTERVAL 50
|
||||
|
||||
#define PIN_SERIAL1_RX PIN_GPS_TX
|
||||
#define PIN_SERIAL1_TX PIN_GPS_RX
|
||||
|
||||
// PCF8563 RTC Module
|
||||
#define PCF8563_RTC 0x51
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
*/
|
||||
#define SPI_INTERFACES_COUNT 1
|
||||
|
||||
// For LORA, spi 0
|
||||
#define PIN_SPI_MISO (32 + 9)
|
||||
#define PIN_SPI_MOSI (0 + 11)
|
||||
#define PIN_SPI_SCK (0 + 12)
|
||||
|
||||
// #define PIN_PWR_EN (0 + 6)
|
||||
|
||||
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
||||
// #define USE_SEGGER
|
||||
|
||||
// Battery
|
||||
// The battery sense is hooked to pin A0 (2)
|
||||
// it is defined in the anlaolgue pin section of this file
|
||||
// and has 12 bit resolution
|
||||
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
||||
#define BATTERY_SENSE_RESOLUTION 4096.0
|
||||
#undef AREF_VOLTAGE
|
||||
#define AREF_VOLTAGE 3.0
|
||||
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define HAS_RTC 1
|
||||
|
||||
/**
|
||||
OLED Screen Model
|
||||
*/
|
||||
#define ARDUINO_ARCH_AVR
|
||||
#define USE_SH1107_128_64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
@@ -9,17 +9,30 @@ build_flags = ${nrf52840_base.build_flags}
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D PIN_BOARD_SCL=7
|
||||
-D PIN_BOARD_SDA=8
|
||||
-D PIN_OLED_RESET=-1
|
||||
-D PIN_USER_BTN=6
|
||||
-D PIN_GPS_RX=3
|
||||
-D PIN_GPS_TX=4
|
||||
-D PIN_GPS_EN=5
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_INCLUDE_AHTX0=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D ENV_INCLUDE_INA3221=1
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
build_src_filter = ${nrf52840_base.build_src_filter}
|
||||
+<helpers/nrf52/PromicroBoard.cpp>
|
||||
+<helpers/sensors>
|
||||
+<../variants/promicro>
|
||||
lib_deps= ${nrf52840_base.lib_deps}
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
|
||||
[env:Faketec_Repeater]
|
||||
extends = Faketec
|
||||
build_src_filter = ${Faketec.build_src_filter}
|
||||
@@ -32,12 +45,11 @@ build_flags =
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps = ${Faketec.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:Faketec_room_server]
|
||||
extends = Faketec
|
||||
@@ -50,12 +62,11 @@ build_flags = ${Faketec.build_flags}
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps = ${Faketec.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:Faketec_terminal_chat]
|
||||
extends = Faketec
|
||||
@@ -69,14 +80,13 @@ build_src_filter = ${Faketec.build_src_filter}
|
||||
lib_deps = ${Faketec.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:Faketec_companion_radio_usb]
|
||||
extends = Faketec
|
||||
build_flags = ${Faketec.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${Faketec.build_src_filter}
|
||||
@@ -85,8 +95,6 @@ build_src_filter = ${Faketec.build_src_filter}
|
||||
lib_deps = ${Faketec.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:Faketec_companion_radio_ble]
|
||||
extends = Faketec
|
||||
@@ -98,8 +106,9 @@ build_flags = ${Faketec.build_flags}
|
||||
-D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
-D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D MESH_DEBUG=1
|
||||
build_src_filter = ${Faketec.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio>
|
||||
@@ -107,8 +116,6 @@ build_src_filter = ${Faketec.build_src_filter}
|
||||
lib_deps = ${Faketec.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[ProMicroLLCC68]
|
||||
extends = nrf52840_base
|
||||
@@ -124,7 +131,13 @@ build_flags = ${nrf52840_base.build_flags}
|
||||
build_src_filter =
|
||||
${nrf52840_base.build_src_filter}
|
||||
+<helpers/nrf52/PromicroBoard.cpp>
|
||||
+<helpers/sensors>
|
||||
+<../variants/promicro>
|
||||
lib_deps= ${nrf52840_base.lib_deps}
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
|
||||
[env:ProMicroLLCC68_Repeater]
|
||||
extends = ProMicroLLCC68
|
||||
@@ -138,8 +151,6 @@ build_flags = ${ProMicroLLCC68.build_flags}
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps = ${ProMicroLLCC68.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:ProMicroLLCC68_room_server]
|
||||
extends = ProMicroLLCC68
|
||||
@@ -153,8 +164,6 @@ build_flags = ${ProMicroLLCC68.build_flags}
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps = ${ProMicroLLCC68.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:ProMicroLLCC68_terminal_chat]
|
||||
extends = ProMicroLLCC68
|
||||
@@ -168,8 +177,6 @@ build_src_filter = ${ProMicroLLCC68.build_src_filter}
|
||||
lib_deps = ${ProMicroLLCC68.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:ProMicroLLCC68_companion_radio_usb]
|
||||
extends = ProMicroLLCC68
|
||||
@@ -183,8 +190,6 @@ build_src_filter = ${ProMicroLLCC68.build_src_filter}
|
||||
lib_deps = ${ProMicroLLCC68.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
|
||||
[env:ProMicroLLCC68_companion_radio_ble]
|
||||
extends = ProMicroLLCC68
|
||||
@@ -204,5 +209,3 @@ build_src_filter = ${ProMicroLLCC68.build_src_filter}
|
||||
lib_deps = ${ProMicroLLCC68.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
robtillaart/INA3221 @ ^0.4.1
|
||||
robtillaart/INA219 @ ^0.4.1
|
||||
@@ -2,6 +2,9 @@
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
#endif
|
||||
|
||||
PromicroBoard board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
@@ -10,7 +13,17 @@ WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
PromicroSensorManager sensors;
|
||||
#if ENV_INCLUDE_GPS
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors;
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
@@ -75,91 +88,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
static INA3221 INA_3221(TELEM_INA3221_ADDRESS, &Wire);
|
||||
static INA219 INA_219(TELEM_INA219_ADDRESS, &Wire);
|
||||
|
||||
bool PromicroSensorManager::begin() {
|
||||
if (INA_3221.begin()) {
|
||||
MESH_DEBUG_PRINTLN("Found INA3221 at address: %02X", INA_3221.getAddress());
|
||||
MESH_DEBUG_PRINTLN("%04X %04X %04X", INA_3221.getDieID(), INA_3221.getManufacturerID(), INA_3221.getConfiguration());
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
INA_3221.setShuntR(i, TELEM_INA3221_SHUNT_VALUE);
|
||||
}
|
||||
INA3221initialized = true;
|
||||
} else {
|
||||
INA3221initialized = false;
|
||||
MESH_DEBUG_PRINTLN("INA3221 was not found at I2C address %02X", TELEM_INA3221_ADDRESS);
|
||||
}
|
||||
if (INA_219.begin()) {
|
||||
MESH_DEBUG_PRINTLN("Found INA219 at address: %02X", INA_219.getAddress());
|
||||
INA219_CHANNEL = INA3221initialized ? TELEM_CHANNEL_SELF + 4 : TELEM_CHANNEL_SELF + 1;
|
||||
INA_219.setMaxCurrentShunt(TELEM_INA219_MAX_CURRENT, TELEM_INA219_SHUNT_VALUE);
|
||||
INA219initialized = true;
|
||||
} else {
|
||||
INA219initialized = false;
|
||||
MESH_DEBUG_PRINTLN("INA219 was not found at I2C address %02X", TELEM_INA219_ADDRESS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PromicroSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
|
||||
if (INA3221initialized) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
// add only enabled INA3221 channels to telemetry
|
||||
if (INA3221_CHANNEL_ENABLED[i]) {
|
||||
telemetry.addVoltage(INA3221_CHANNELS[i], INA_3221.getBusVoltage(i));
|
||||
telemetry.addCurrent(INA3221_CHANNELS[i], INA_3221.getCurrent(i));
|
||||
telemetry.addPower(INA3221_CHANNELS[i], INA_3221.getPower(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(INA219initialized) {
|
||||
telemetry.addVoltage(INA219_CHANNEL, INA_219.getBusVoltage());
|
||||
telemetry.addCurrent(INA219_CHANNEL, INA_219.getCurrent());
|
||||
telemetry.addPower(INA219_CHANNEL, INA_219.getPower());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int PromicroSensorManager::getNumSettings() const {
|
||||
return NUM_SENSOR_SETTINGS;
|
||||
}
|
||||
|
||||
const char* PromicroSensorManager::getSettingName(int i) const {
|
||||
if (i >= 0 && i < NUM_SENSOR_SETTINGS) {
|
||||
return INA3221_CHANNEL_NAMES[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* PromicroSensorManager::getSettingValue(int i) const {
|
||||
if (i >= 0 && i < NUM_SENSOR_SETTINGS) {
|
||||
return INA3221_CHANNEL_ENABLED[i] ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool PromicroSensorManager::setSettingValue(const char* name, const char* value) {
|
||||
for (int i = 0; i < NUM_SENSOR_SETTINGS; i++) {
|
||||
if (strcmp(name, INA3221_CHANNEL_NAMES[i]) == 0) {
|
||||
int channelEnabled = INA_3221.getEnableChannel(i);
|
||||
if (strcmp(value, "1") == 0) {
|
||||
INA3221_CHANNEL_ENABLED[i] = true;
|
||||
if (!channelEnabled) {
|
||||
INA_3221.enableChannel(i);
|
||||
}
|
||||
} else {
|
||||
INA3221_CHANNEL_ENABLED[i] = false;
|
||||
if (channelEnabled) {
|
||||
INA_3221.disableChannel(i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -7,16 +7,20 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/CustomLLCC68Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <INA3221.h>
|
||||
#include <INA219.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
#define NUM_SENSOR_SETTINGS 3
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
|
||||
extern PromicroBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
@@ -24,36 +28,3 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
#define TELEM_INA3221_ADDRESS 0x42 // INA3221 3 channel current sensor I2C address
|
||||
#define TELEM_INA219_ADDRESS 0x40 // INA219 single channel current sensor I2C address
|
||||
|
||||
#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
|
||||
#define TELEM_INA3221_SETTING_CH1 "INA3221-1"
|
||||
#define TELEM_INA3221_SETTING_CH2 "INA3221-2"
|
||||
#define TELEM_INA3221_SETTING_CH3 "INA3221-3"
|
||||
|
||||
#define TELEM_INA219_SHUNT_VALUE 0.100 // shunt value in ohms (may differ between manufacturers)
|
||||
#define TELEM_INA219_MAX_CURRENT 5
|
||||
|
||||
class PromicroSensorManager: public SensorManager {
|
||||
bool INA3221initialized = false;
|
||||
bool INA219initialized = false;
|
||||
|
||||
// INA3221 channels in telemetry
|
||||
int INA3221_CHANNELS[NUM_SENSOR_SETTINGS] = {TELEM_CHANNEL_SELF + 1, TELEM_CHANNEL_SELF + 2, TELEM_CHANNEL_SELF+ 3};
|
||||
const char * INA3221_CHANNEL_NAMES[NUM_SENSOR_SETTINGS] = { TELEM_INA3221_SETTING_CH1, TELEM_INA3221_SETTING_CH2, TELEM_INA3221_SETTING_CH3};
|
||||
bool INA3221_CHANNEL_ENABLED[NUM_SENSOR_SETTINGS] = {true, true, true};
|
||||
|
||||
int INA219_CHANNEL;
|
||||
public:
|
||||
PromicroSensorManager(){};
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||
int getNumSettings() const override;
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
};
|
||||
|
||||
|
||||
extern PromicroSensorManager sensors;
|
||||
33
variants/rak3x72/platformio.ini
Normal file
33
variants/rak3x72/platformio.ini
Normal file
@@ -0,0 +1,33 @@
|
||||
[rak3x72]
|
||||
extends = stm32_base
|
||||
board = rak3172
|
||||
board_upload.maximum_size = 229376 ; 32kb for FS
|
||||
build_flags = ${stm32_base.build_flags}
|
||||
-D RADIO_CLASS=CustomSTM32WLx
|
||||
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
|
||||
-D SPI_INTERFACES_COUNT=0
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-I variants/rak3x72
|
||||
build_src_filter = ${stm32_base.build_src_filter}
|
||||
+<../variants/rak3x72>
|
||||
|
||||
[env:rak3x72-repeater]
|
||||
extends = rak3x72
|
||||
build_flags = ${rak3x72.build_flags}
|
||||
-D LORA_TX_POWER=22
|
||||
-D ADVERT_NAME='"RAK3x72 Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${rak3x72.build_src_filter}
|
||||
+<../examples/simple_repeater/main.cpp>
|
||||
|
||||
[env:rak3x72_companion_radio_usb]
|
||||
extends = rak3x72
|
||||
build_flags = ${rak3x72.build_flags}
|
||||
; -D FORMAT_FS=true
|
||||
-D LORA_TX_POWER=22
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
build_src_filter = ${rak3x72.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${rak3x72.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
67
variants/rak3x72/target.cpp
Normal file
67
variants/rak3x72/target.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
RAK3x72Board board;
|
||||
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
static const uint32_t rfswitch_pins[] = {LORAWAN_RFSWITCH_PINS, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
{STM32WLx::MODE_IDLE, {LOW, LOW}},
|
||||
{STM32WLx::MODE_RX, {HIGH, LOW}},
|
||||
{STM32WLx::MODE_TX_LP, {LOW, HIGH}},
|
||||
{STM32WLx::MODE_TX_HP, {LOW, HIGH}},
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
|
||||
VolatileRTCClock rtc_clock;
|
||||
SensorManager sensors;
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
// rtc_clock.begin(Wire);
|
||||
|
||||
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, 0, 0); // TCXO set to 0 for RAK3172
|
||||
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
35
variants/rak3x72/target.h
Normal file
35
variants/rak3x72/target.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/stm32/STM32Board.h>
|
||||
#include <helpers/CustomSTM32WLxWrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
|
||||
#define PIN_VBAT_READ A0
|
||||
#define ADC_MULTIPLIER (5 * 1.73 * 1000)
|
||||
|
||||
class RAK3x72Board : public STM32Board {
|
||||
public:
|
||||
const char* getManufacturerName() const override {
|
||||
return "RAK 3x72";
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
uint32_t raw = analogRead(PIN_VBAT_READ);
|
||||
return (ADC_MULTIPLIER * raw) / 1024;
|
||||
}
|
||||
};
|
||||
|
||||
extern RAK3x72Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
5
variants/rak3x72/variant.h
Normal file
5
variants/rak3x72/variant.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <variant_RAK3172_MODULE.h>
|
||||
|
||||
#undef RNG
|
||||
@@ -7,6 +7,7 @@ build_flags = ${nrf52840_base.build_flags}
|
||||
-I variants/rak4631
|
||||
-D RAK_4631
|
||||
-D PIN_USER_BTN=9
|
||||
-D PIN_USER_BTN_ANA=31
|
||||
-D PIN_BOARD_SCL=14
|
||||
-D PIN_BOARD_SDA=13
|
||||
-D PIN_OLED_RESET=-1
|
||||
|
||||
@@ -12,6 +12,10 @@ VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern RAK4631Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
24
variants/t1000-e/NullDisplayDriver.h
Normal file
24
variants/t1000-e/NullDisplayDriver.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
|
||||
class NullDisplayDriver : public DisplayDriver {
|
||||
public:
|
||||
NullDisplayDriver() : DisplayDriver(128, 64) { }
|
||||
bool begin() { return false; } // not present
|
||||
|
||||
bool isOn() override { return false; }
|
||||
void turnOn() override { }
|
||||
void turnOff() override { }
|
||||
void clear() override { }
|
||||
void startFrame(Color bkg = DARK) override { }
|
||||
void setTextSize(int sz) override { }
|
||||
void setColor(Color c) override { }
|
||||
void setCursor(int x, int y) override { }
|
||||
void print(const char* str) override { }
|
||||
void fillRect(int x, int y, int w, int h) override { }
|
||||
void drawRect(int x, int y, int w, int h) override { }
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { }
|
||||
uint16_t getTextWidth(const char* str) override { return 0; }
|
||||
void endFrame() { }
|
||||
};
|
||||
@@ -46,10 +46,14 @@ build_flags = ${t1000-e.build_flags}
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D HAS_UI
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D PIN_BUZZER=25
|
||||
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
|
||||
build_src_filter = ${t1000-e.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${t1000-e.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
@@ -12,6 +12,10 @@ VolatileRTCClock rtc_clock;
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
T1000SensorManager sensors = T1000SensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -154,7 +158,7 @@ bool T1000SensorManager::begin() {
|
||||
|
||||
bool T1000SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f);
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -168,6 +172,7 @@ void T1000SensorManager::loop() {
|
||||
if (_nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
class T1000SensorManager: public SensorManager {
|
||||
bool gps_active = false;
|
||||
@@ -27,6 +30,10 @@ public:
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
};
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
extern T1000eBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
|
||||
@@ -14,6 +14,10 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
T114SensorManager sensors = T114SensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -93,7 +97,7 @@ bool T114SensorManager::begin() {
|
||||
digitalWrite(GPS_EN, HIGH); // Power on GPS
|
||||
|
||||
// Give GPS a moment to power up and send data
|
||||
delay(500);
|
||||
delay(1500);
|
||||
|
||||
// We'll consider GPS detected if we see any data on Serial1
|
||||
gps_detected = (Serial1.available() > 0);
|
||||
@@ -111,7 +115,7 @@ bool T114SensorManager::begin() {
|
||||
|
||||
bool T114SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f);
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -125,6 +129,7 @@ void T114SensorManager::loop() {
|
||||
if (_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#endif
|
||||
|
||||
class T114SensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
@@ -32,6 +35,10 @@ extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern T114SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
#define LED_BLUE (-1) // No blue led, prevents Bluefruit flashing the green LED during advertising
|
||||
#define LED_PIN LED_BUILTIN
|
||||
|
||||
#define LED_STATE_ON HIGH
|
||||
#define LED_STATE_ON LOW
|
||||
|
||||
#define PIN_NEOPIXEL (14)
|
||||
#define NEOPIXEL_NUM (2)
|
||||
@@ -109,7 +109,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Buzzer
|
||||
|
||||
#define PIN_BUZZER (46)
|
||||
// #define PIN_BUZZER (46)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -64,7 +64,6 @@ build_flags =
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D HAS_GxEPD
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
; -D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
|
||||
@@ -12,6 +12,10 @@ VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,20 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern TechoBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -70,7 +70,6 @@ build_flags =
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D DISPLAY_ROTATION=4
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D HAS_GxEPD
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
; -D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
|
||||
@@ -12,6 +12,10 @@ VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#endif
|
||||
|
||||
extern ThinkNodeM1Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
@@ -6,6 +6,7 @@ build_flags = ${stm32_base.build_flags}
|
||||
-D RADIO_CLASS=CustomSTM32WLx
|
||||
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
|
||||
-D SPI_INTERFACES_COUNT=0
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-I variants/wio-e5
|
||||
build_src_filter = ${stm32_base.build_src_filter}
|
||||
+<../variants/wio-e5>
|
||||
@@ -13,7 +14,7 @@ build_src_filter = ${stm32_base.build_src_filter}
|
||||
[env:wio-e5-repeater]
|
||||
extends = lora_e5
|
||||
build_flags = ${lora_e5.build_flags}
|
||||
-D LORA_TX_POWER=20
|
||||
-D LORA_TX_POWER=22
|
||||
-D ADVERT_NAME='"WIO-E5 Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${lora_e5.build_src_filter}
|
||||
@@ -22,7 +23,7 @@ build_src_filter = ${lora_e5.build_src_filter}
|
||||
[env:wio-e5_companion_radio_usb]
|
||||
extends = lora_e5
|
||||
build_flags = ${lora_e5.build_flags}
|
||||
-D LORA_TX_POWER=20
|
||||
-D LORA_TX_POWER=22
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
build_src_filter = ${lora_e5.build_src_filter}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
STM32Board board;
|
||||
WIOE5Board board;
|
||||
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
|
||||
@@ -42,7 +42,11 @@ bool radio_init() {
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
return true; // success
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
|
||||
extern STM32Board board;
|
||||
class WIOE5Board : public STM32Board {
|
||||
public:
|
||||
const char* getManufacturerName() const override {
|
||||
return "Seeed Wio E5";
|
||||
}
|
||||
};
|
||||
|
||||
extern WIOE5Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
@@ -16,6 +16,11 @@ lib_ignore =
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
|
||||
|
||||
[Xiao_nrf52]
|
||||
extends = nrf52840_xiao
|
||||
@@ -35,8 +40,15 @@ build_flags = ${nrf52840_xiao.build_flags}
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_WIRE_SCL=6
|
||||
-D PIN_WIRE_SDA=7
|
||||
-D ENV_INCLUDE_AHTX0=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D ENV_INCLUDE_INA3221=1
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
build_src_filter = ${nrf52840_xiao.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors>
|
||||
+<helpers/nrf52/XiaoNrf52Board.cpp>
|
||||
+<../variants/xiao_nrf52>
|
||||
debug_tool = jlink
|
||||
|
||||
@@ -9,7 +9,7 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
VolatileRTCClock rtc_clock;
|
||||
SensorManager sensors;
|
||||
EnvironmentSensorManager sensors;
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include <helpers/nrf52/XiaoNrf52Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
|
||||
extern XiaoNrf52Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
|
||||
@@ -110,8 +110,8 @@ static const uint8_t A5 = PIN_A5;
|
||||
// Wire Interfaces
|
||||
#define WIRE_INTERFACES_COUNT (1)
|
||||
|
||||
#define PIN_WIRE_SDA (17) // 4 and 5 are used for the sx1262 !
|
||||
#define PIN_WIRE_SCL (16) // use WIRE1_SDA
|
||||
// #define PIN_WIRE_SDA (17) // 4 and 5 are used for the sx1262 !
|
||||
// #define PIN_WIRE_SCL (16) // use WIRE1_SDA
|
||||
|
||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
|
||||
@@ -16,6 +16,10 @@ ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,19 @@
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
extern ESP32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
|
||||
Reference in New Issue
Block a user