TallyArbiter icon indicating copy to clipboard operation
TallyArbiter copied to clipboard

New PlatformIO listener client

Open MatteoGheza opened this issue 3 years ago • 19 comments

I wrote this new listener client to migrate every ESP32/ESP8266-based listener client to the same codebase, and for using PlatformIO. It's compatible with the Arduino IDE (currently, renaming a file is needed, fixing this soon), and it support build configuration.

Every feature/piece of code is configurable (WiP), so you can enable or disable certain features on a custom build, for example, enabling tally light status output on the M5Atom (turning on a GPIO pin on bus status).

Why did I do this?

There are 4 different firmwares for M5Atom and similar devices, and maintaining them is becoming a nightmare. There are a lot of PR, and when a listener is uupdated we should apply the same patch (or similar) to the other 3. Using PlatformIO, configuring build flags and running tests, or even emulations, is easier. PlatformIO has a build cache, and it uses them when you re-compile the code after a change. With this cache, compiling requires only a few seconds.

TODOs:

  • [x] Connect to server and handle device status change
  • [x] Save preferences and display settings into the WiFi selection page
  • [x] Implement tally status GPIO output
  • [x] Add settings reset support
  • [x] Add settings and info page (and button navigation)
  • [x] Replace old logo with the new logo (and update the TTGO platform code)
  • [x] Display errors with icons and message on devices with a screen (for example when the WiFi connection fails, when the device needs to be configured, etc)
  • [x] Support ESP8266 data saving
  • [x] "Porting" PRs-added features here
  • [x] Add documentation
  • [x] Static code analysis and firmware compiling on Github Actions Workflow

Implement M5Stick and similar platforms looking at the old listeners:

  • [x] Adafruit NeoPixel
  • [x] M5AtomMatrix
  • [x] TTGO_T
  • [x] m5stickc

MatteoGheza avatar Jan 25 '22 00:01 MatteoGheza

Cool! Look forward to trying it out.

wrldtvlr avatar Jan 25 '22 01:01 wrldtvlr

Amazing as always, @MatteoGheza !

josephdadams avatar Jan 25 '22 01:01 josephdadams

Looks awesome! Hit me up when you need testing on the clients.

mg-1999 avatar Jan 25 '22 09:01 mg-1999

How do you plan on adding all the features of the different clients without the 'main' file getting complicated to work in?

mg-1999 avatar Jan 27 '22 08:01 mg-1999

How do you plan on adding all the features of the different clients without the 'main' file getting complicated to work in?

IDK. I tried to split the code into different files. Functions in main.cpp currently:

  • setAdafruitNeoPixelColor if Adafruit NeoPixel is enabled (since you should be able to use NeoPixel on a TTGO or an M5Stack, for example)
  • event_* for every WebSocket event
  • socketIOEvent for parsing Socket.IO events and socketIOConnEvent for Websocket connection
  • saveParamCallback since it's used only in main.cpp
  • setup and loop

I think that I should add more comments in the code.

MatteoGheza avatar Jan 28 '22 17:01 MatteoGheza

Looks like a good start.

I see that you are putting listener specific code in a separate file. And then calling listener specific 'initialise' and 'process tally data' from the main file if they are enabled?

Smart! Good to also document how to add listener clients with maybe an example client?

mg-1999 avatar Jan 28 '22 22:01 mg-1999

I flashed the listener to one of my M5 Stick c Pluses and it get stuck in booting because WiFi manager still has stored settings from the other version of the software.

I think that it needs to have a way of having its WiFi credentials and other settings reset to keep it from getting stuck in a boot loop.

I implemented a reset menu, but it works only when the device is configured (no WiFi configuration). I tested it a lot on the TTGO. Currently, if you click the button (M5 button) once, it opens the info page. If you click it twice, it opens a page with the IP Address of the device and you can go to the settings web page (for configuring WiFi, TA server and updating the device OTA). If you long-press it, then you long-press it again, the device will reset.

What do you think about enabling this menu when the device is not configured (eg. reset the device if button pressed while turning on the device, like opening BIOS page on a computer).

What do you think about changing the M5StickC configuration to use the Action button instead of the M5 button for this (and using the M5 button for enabling sleep mode like on the TTGO)?

MatteoGheza avatar Feb 08 '22 08:02 MatteoGheza

Both option sound like a solid idea.

mg-1999 avatar Feb 08 '22 08:02 mg-1999

I flashed the listener to one of my M5 Stick c Pluses and it get stuck in booting because WiFi manager still has stored settings from the other version of the software.

I think that it needs to have a way of having its WiFi credentials and other settings reset to keep it from getting stuck in a boot loop.

Done. Now, for resetting the device if it isn't configured, you should press (without releasing) the menu button (M5 button in this case) while turning on the device.

MatteoGheza avatar Feb 08 '22 15:02 MatteoGheza

I love this, thank you for taking this on @MatteoGheza! I'll bring in my initial discussion #269 here for context. Let me take a look at this and see if I can yield any suggestions.

mattv8 avatar Mar 02 '22 19:03 mattv8

Sorry it took a month to get this review in. Life got super busy and I'm just getting back to TA

JTF4 avatar Mar 14 '22 21:03 JTF4

Sorry it took a month to get this review in. Life got super busy and I'm just getting back to TA

@JTF4 I know the feeling! 😅

mattv8 avatar Mar 15 '22 18:03 mattv8

Sorry it took a month to get this review in. Life got super busy and I'm just getting back to TA

It's the same for me...

MatteoGheza avatar Mar 16 '22 16:03 MatteoGheza

Can someone help me testing this and writing documentation (I only documented the build flags)? This should be prod-ready.

MatteoGheza avatar May 13 '22 13:05 MatteoGheza

@MatteoGheza I may have some time to look into testing/documentation. I'm still currently working on my custom tally PCB (working on v2), so I'm hoping to adapt this to it and test this PR in the process.

mattv8 avatar May 18 '22 19:05 mattv8

@MatteoGheza I may have some time to look into testing/documentation. I'm still currently working on my custom tally PCB (working on v2), so I'm hoping to adapt this to it and test this PR in the process.

Thanks. When everythings works well, we should implement an update system.

MatteoGheza avatar May 19 '22 15:05 MatteoGheza

Hey, I just discovered this program today and I am a big fan of PlatformIO. I decided to clone the repo and try and build code and got some errors. After doing some digging I found the issue is due to a breaking change in ArduinoJSON

https://arduinojson.org/news/2022/12/26/arduinojson-6-20-0/#removed-support-for-char-and-char

I am still learning my way around the source so I am not sure of where all this effects but the fix I used in the short term to get the code to build is to modify platformio.ini to force version 6.18.5 bblanchon/ArduinoJson@=6.18.5

MrFobwatch avatar Nov 10 '23 02:11 MrFobwatch

I think it should be a relatively easy fix. I'll have to see if I've got time to look into it.

JTF4 avatar Dec 14 '23 08:12 JTF4

What is the status of this PR? Trying to understand if there is something that I can help with.

Jocke4f avatar Dec 29 '23 19:12 Jocke4f