Skip to content

Commit

Permalink
esp-now mode, untested
Browse files Browse the repository at this point in the history
  • Loading branch information
nonik0 committed Feb 29, 2024
1 parent d103117 commit 3ee5709
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 160 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install PlatformIO Core
run: pip install --upgrade platformio

- name: Build PlatformIO Project
run: pio run

- name: Rename bin file
- name: Rename Bin File
run: mv .pio/build/m5cardputer/firmware.bin LoRaChat.bin

- name: Upload a Build Artifact
- name: Upload Build Artifact
uses: actions/upload-artifact@v4.3.1
with:
name: CardputerLoRaChat
Expand All @@ -40,9 +43,8 @@ jobs:
if: github.ref_type == 'tag'

steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Download Build Artifact
uses: actions/download-artifact@v4

- name: Release ${{ github.ref_name }}
uses: softprops/action-gh-release@v1
Expand Down
52 changes: 52 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <Arduino.h>

enum RedrawFlags
{
MainWindow = 0b001,
SystemBar = 0b010,
TabBar = 0b100,
None = 0b000
};

// TODO: refine message format
struct Message
{
uint8_t nonce : 6;
uint8_t channel : 2; // 4 channels, 0b01,0b10,0b11 channels, 0b11 reserved for pings
String username; // use MAC or something tied to device?
int rssi;
String text;
};

// track presence of other users
struct Presence
{
String username;
int rssi;
unsigned long lastSeenMillis;
};
std::vector<Presence> presence;

struct ChatTab
{
unsigned char channel;
// TODO: access in thread-safe way
std::vector<Message> messages;
String messageBuffer;
int viewIndex;
};

enum Settings
{
Username = 0,
Brightness = 1,
PingMode = 2,
RepeatMode = 3,
EspNowMode = 4,
WriteConfig = 5,
LoRaSettings = 6
};

const int SettingsCount = 7;
const String SettingsNames[SettingsCount] = {"Username", "Brightness", "Ping Mode", "Repeat Mode", "ESP-NOW Mode", "App Config", "LoRa Config"};
const String SettingsFilename = "/LoRaChat.conf";
Loading

0 comments on commit 3ee5709

Please sign in to comment.