Skip to content

Conversation

@hank
Copy link
Contributor

@hank hank commented Jun 1, 2025

This branch does a few things:

  • Pulls the companion MyMesh class into a header and CPP file and makes the right externed globals for the Button, MyMesh, main and UITask files to actually integrate with each other
  • Adds a double press action to button behavior on all devices that sends an advert
  • Fixes all the companion ini files to include all files in the companion directory so there shouldn't be linker errors
  • Ports a self advert func from repeater since that was missing in the MyMesh for companion

FIRMWARE_VERSION ends up in MyMesh.h, which can be moved if desired. main.cpp just isn't a great place for it. This brings up a potential future task of cleaning up the MyMesh classes in the different example codebases to make a proper class structure that would support Repeater, Room Server and Companion (and other) implementations.

I just tested the doublepress advert on a tbeam sx1276 and it works great, shows up immediately on another node's discover list.

DEBUG: UITask: any press triggered
DEBUG: UITask: any press triggered
DEBUG: UITask: double press triggered, sending advert
DEBUG: Advert sent!

Pulled the class out of main.cpp, made a header to go along with it, externed globals in headers to make them accessible to button code. Added button code to send an advert on double press. Refactored ini files to prevent linker errors.
@446564
Copy link
Contributor

446564 commented Jun 1, 2025

I'll test this on the g2 nano tonight

@ripplebiz
Copy link
Collaborator

The project doesn't have a linter or code format def yet, but it's customary to use the predominant brace/indenting style of the repo.

@@ -1,4 +1,5 @@
#pragma once
#ifndef UI_TASK_H
#define UI_TASK_H
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'#pragma once' does this, and is very widely supported now.

; -D ENABLE_PRIVATE_KEY_EXPORT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D MESH_DEBUG=1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to leave these uncommented/enabled when committing


#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="

#define CMD_APP_START 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CMD_ and RESP_ codes don't need to be known by other modules, so can be moved to the .cpp file

@hank
Copy link
Contributor Author

hank commented Jun 1, 2025

  • pragma onced
  • Moved CMD/RESP macros as requested
  • Added clang-format to the repo which vscode will use to format code, and set it up to match what I saw in the repo with the braces and spacing. Tweak to your heart's content!
  • Reformatted all my changes
  • Removed debug macro from ini
  • Merged in current dev, which required porting a change from main.cpp into MyMesh.cpp because of refactor.

Please review! Thanks!

@ripplebiz
Copy link
Collaborator

Thanks for the changes.
There's a lot at stake with changes like this. It's very hard to tell if you've made a mistake somewhere with this refactor, and it has the potential to break ALL companion firmwares. Still, the MyMesh class could really do with being moved out of main, so I'm trying to really weigh this one up properly.

Still, I'd like as many unnecessary changes as possible to be reverted. Like the simple_secure_chat/main.cpp. Doesn't look like there are any actual changes there. Same with the Button.* files. If you could revert these files please. (I know, the author of Button didn't follow code formatting, but I'd rather leave as-is, and stick to the 'no unnecessary diffs pls' principle.

Also, with the clang formatter, there are still some differences, like else and else if being on same line. And function opening brace on same line.

@hank
Copy link
Contributor Author

hank commented Jun 2, 2025

  • Reverted changes to Button files as requested
  • Reverted changes to simple_secure_chat
  • Switched AllowShortIfStatementsOnASingleLine to true to clang format rules
  • Switched BreakBeforeBraces to Attach to make all opening braces occur on the same line
  • Reformatted MyMesh.cpp as an example of clang-format changes. Can update more if needed.
  • Did my best to minimize changes to the repo
  • Built many companion firmwares and tested one to ensure things aren't completely broken, more testing recommended.

@ripplebiz ripplebiz merged commit accbe3b into meshcore-dev:dev Jun 2, 2025
agessaman pushed a commit to agessaman/MeshCore that referenced this pull request Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants