Repository navigation
example: add ESP-NOW capture example #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
40034ee
feat: add ESP-NOW capture callback API
88f0cbe
feat: parse ESP-NOW action frames
4dbeece
example: add ESP-NOW capture example
b0f27c8
Merge branch 'develop' into feat/esp-now-capture
0ldev 4ffa929
fix: address review feedback on esp-now capture and add to ci matrix
0ldev 9b834a2
Merge branch 'develop' into feat/esp-now-capture
0ldev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [platformio] | ||
| default_envs = esp32 | ||
|
|
||
| [env:esp32] | ||
| platform = espressif32 @ ~6.13.0 | ||
| board = esp32dev | ||
| framework = arduino | ||
| monitor_speed = 115200 | ||
| lib_deps = | ||
| symlink://../.. | ||
| build_flags = | ||
| -D CORE_DEBUG_LEVEL=5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #include <Arduino.h> | ||
| #include <Politician.h> | ||
|
|
||
| using namespace politician; | ||
|
|
||
| Politician engine; | ||
|
|
||
| void setup() { | ||
| Serial.begin(115200); | ||
| delay(2000); | ||
| Serial.println("\n\n--- Politician ESP-NOW Capture Example ---"); | ||
|
|
||
| Config cfg; | ||
| // We don't necessarily need to capture beacons for ESP-NOW, but it helps populate the AP cache | ||
| cfg.capture_filter = LOG_FILTER_BEACONS | LOG_FILTER_PROBES; | ||
|
|
||
| // Initialize the engine | ||
| if (engine.begin(cfg) != politician::OK) { | ||
| Serial.println("Failed to start Politician engine"); | ||
| while (1) delay(100); | ||
| } | ||
|
|
||
| // Set the callback to process ESP-NOW payloads | ||
| engine.setEspNowCallback([](const EspNowRecord &rec) { | ||
| Serial.printf("[ESP-NOW] ch=%d rssi=%d src=%02x:%02x:%02x:%02x:%02x:%02x dst=%02x:%02x:%02x:%02x:%02x:%02x len=%d payload=[", | ||
| rec.channel, rec.rssi, | ||
| rec.src[0], rec.src[1], rec.src[2], rec.src[3], rec.src[4], rec.src[5], | ||
| rec.dst[0], rec.dst[1], rec.dst[2], rec.dst[3], rec.dst[4], rec.dst[5], | ||
| rec.length); | ||
|
|
||
| // Print the first few bytes of the payload in hex | ||
| int printLen = rec.length > 16 ? 16 : rec.length; | ||
| for (int i = 0; i < printLen; i++) { | ||
| Serial.printf("%02x ", rec.payload[i]); | ||
| } | ||
| if (rec.length > 16) Serial.print("..."); | ||
| Serial.println("]"); | ||
| }); | ||
|
|
||
| // Start hopping to discover ESP-NOW devices on any channel, | ||
| // or use engine.lockChannel(1) if you know their specific channel. | ||
| engine.startHopping(); | ||
| Serial.println("Hopping started. Waiting for ESP-NOW traffic..."); | ||
| } | ||
|
|
||
| void loop() { | ||
| engine.tick(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.