Skip to content

Commit 911469a

Browse files
authored
Merge pull request #68 from hpsaturn/devel
Devel
2 parents c139f3d + 85f7f31 commit 911469a

File tree

22 files changed

+1012
-82
lines changed

22 files changed

+1012
-82
lines changed

.github/workflows/devel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
pio pkg update
3434
- name: PlatformIO Build Test
3535
run: |
36-
pio run -e freenove-tank -e makerfabs-multi-receiver -e xiao-camera3
36+
pio run -e freenove-tank -e makerfabs-multi-receiver -e xiao-camera3 -e wifiraw-80211tx-sender

.github/workflows/platformio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
pio pkg update
3434
- name: PlatformIO Build Test
3535
run: |
36-
pio run -e freenove-tank -e m5stickCplus-joystick-tank -e custom-camera-sender -e m5cores3-espnow-receiver -e makerfabs-multi-receiver -e xiao-camera3
36+
pio run -e freenove-tank -e m5stickCplus-joystick-tank -e custom-camera-sender -e m5cores3-espnow-receiver -e makerfabs-multi-receiver -e xiao-camera3 -e wifiraw-80211tx-sender -e wifiraw-80211tx-receiver

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ releases
4545
releases/binaries/
4646
releases/installer/
4747
examples/lib/espcamlib
48+
.history
49+
.local
50+
.cache
51+
.platformio

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The latest version brings numerous enhancements and is currently highly stable.
2222
- One transmitter to multiple receivers using the internal ESPNow broadcasting feature (1:N mode).
2323
- Peer-to-peer (P2P) connections utilizing MAC address targeting (1:1 mode).
2424
- Multi-sender mode with one receiver (N:1 mode).
25+
- **NEW:** [80211tx()](#wifi-raw-80211tx-mode-experimental) WiFi raw ESPNow alternative (Beta).
2526

2627
[![ESPNowCam broadcast camera mode](https://raw.githubusercontent.com/hpsaturn/ESPNowCam/master/pictures/broadcast-camera-mode.gif)](https://youtu.be/zXIzP1TGlpA) [![ESPNowCam P2P mode](https://raw.githubusercontent.com/hpsaturn/ESPNowCam/master/pictures/p2p-camera-mode.gif)](https://youtu.be/XDIiJ25AKr8) [![ESPNowCam multi camera mode](https://raw.githubusercontent.com/hpsaturn/ESPNowCam/master/pictures/multi-camera-mode.gif)](https://youtu.be/ip6RohVEg2s)
2728
[[1:N mode video]](https://youtu.be/zXIzP1TGlpA) [[1:1 mode video]](https://youtu.be/XDIiJ25AKr8) [[N:1 mode video]](https://youtu.be/ip6RohVEg2s)
@@ -35,6 +36,7 @@ The current version was tested with the next cameras:
3536

3637
| Sender | Frame | PSRAM | JPGQ | FPS | Status |
3738
|:---------|:-----:|:-----:|:------:|:-------:|:------:|
39+
| Freenove [80211tx()](#wifi-raw-80211tx-mode-experimental) | QVGA | Yes | 12 | ~13 FPS | TESTING |
3840
| TTGO TJournal | QVGA | No | 12 | ~11 FPS | STABLE |
3941
| XIAO Sense S3 | QVGA | Yes | 12 | ~11 FPS | STABLE |
4042
| Freenove S3 | QVGA | Yes | 12 | ~10 FPS | STABLE |
@@ -51,21 +53,21 @@ The current version was tested with the next cameras:
5153
Add the following line to the lib_deps option of your [env:] section:
5254

5355
```python
54-
hpsaturn/EspNowCam@^0.1.17
56+
hpsaturn/EspNowCam@^0.2.0
5557
```
5658

5759
Or via command line:
5860

5961
```python
60-
pio pkg install --library "hpsaturn/ESPNowCam@^0.1.17"
62+
pio pkg install --library "hpsaturn/ESPNowCam@^0.2.0"
6163
```
6264

6365
**Arduino IDE**:
6466

6567
>[!IMPORTANT]
6668
>For `Arduino IDE` is a little bit more complicated because the Arduino IDE dependencies resolver is very bad, but you only need:
6769
>
68-
>1. Download and install the [Nanopb library](https://github.com/nanopb/nanopb/releases/tag/nanopb-0.4.8) using the `Include Library` section via zip file
70+
>1. Download and install the [Nanopb library](https://github.com/nanopb/nanopb/releases/tag/nanopb-0.4.9.1) using the `Include Library` section via zip file
6971
>2. and then with the **Library Manager** find **ESPNowCam** and install it.
7072
7173
>[!TIP]
@@ -83,6 +85,7 @@ ESPNowCam radio;
8385
radio.init();
8486
radio.sendData(data, data_len);
8587
```
88+
8689
[full sender implementation example](https://github.com/hpsaturn/ESPNowCam/blob/master/examples/xiao-espnow-sender/xiao-espnow-sender.cpp)
8790

8891
**To receive** the data, you only need to define a buffer and callback:
@@ -98,6 +101,7 @@ void onDataReady(uint32_t lenght) {
98101
tft.drawJpg(fb, lenght , 0, 0, dw, dh);
99102
}
100103
```
104+
101105
[full receiver implementation example](https://github.com/hpsaturn/ESPNowCam/blob/master/examples/m5core2-basic-receiver/m5core2-basic-receiver.ino)
102106
103107
>[!NOTE]
@@ -128,6 +132,42 @@ radio.setRecvFilter(fb_cam3, mac_cam3, onCam3DataReady);
128132

129133
and each camera should have configured the receiver MAC like a target. Fore more details, please follow the [multi-camera-one-receiver](https://github.com/hpsaturn/ESPNowCam/tree/master/examples/multi-camera-one-receiver/) directory example.
130134

135+
### WiFi Raw 802.11tx mode (experimental)
136+
137+
Now is possible use 80211tx() primitive or WiFi RAW mode without ESPNow internals. Using this raw mode it could be better performance. For that, only do that:
138+
139+
**sender**:
140+
141+
```cpp
142+
WiFiRawComm wifiRaw;
143+
ESPNowCam radio(&wifiRaw);
144+
145+
radio.setTarget(macRecv); // receiver mac address to improve quality
146+
radio.setChannel(6); // improve quality (recommended)
147+
radio.init(512); // you are able to change the chunk size
148+
149+
radio.sendData(out_data, out_data_len);
150+
```
151+
152+
[full wifiraw-80211tx-sender example](https://github.com/hpsaturn/ESPNowCam/tree/master/examples/wifiraw-80211tx-sender)
153+
154+
**receiver**:
155+
156+
```cpp
157+
WiFiRawComm wifiRaw;
158+
ESPNowCam radio(&wifiRaw);
159+
160+
radio.setRecvBuffer(fb); // fixed buffer
161+
radio.setRecvCallback(onDataReady); // similar callback to other modes
162+
radio.setChannel(6); // improve quality
163+
radio.init(512); // the same sender chunk size
164+
```
165+
166+
[full wifiraw-80211tx-receiver example](https://github.com/hpsaturn/ESPNowCam/tree/master/examples/wifiraw-80211tx-receiver)
167+
168+
>[!TIP]
169+
>Note: The N:1 mode is not full implemented on WiFi raw. It is recommended use channel and mac address target on the sender for improve quality. Please sse the examples for details.
170+
131171
### Predefined drivers
132172

133173
The library includes some pre-defined camera configs to have an easy implementation, for example:
@@ -214,7 +254,7 @@ Also I'm working in a complete Camera configurator and test suite for this libra
214254
- [x] Add sender callback to improve speed
215255
- [x] Added internal drivers for some popular Cameras
216256
- [x] Added multi-camera support with one only target
217-
- [ ] Migration to esp_wifi_80211_tx() to improve Payload and Quality
257+
- [x] Migration to esp_wifi_80211_tx() to improve Payload and Quality
218258

219259
## Credits
220260

examples/freenove-p2p-sender/freenove-p2p-sender.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,24 @@ void setup() {
4040
}
4141

4242
// M5Core2 receiver
43-
const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
44-
radio.setTarget(macRecv);
45-
radio.init();
43+
// const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
44+
// radio.setTarget(macRecv);
45+
46+
if (radio.init()) {
47+
Serial.println("ESPNowCam Init Success");
48+
}
49+
50+
delay(500);
4651

4752
// You are able to change the Camera config E.g:
4853
// Camera.config.fb_count = 2;
4954
// Camera.config.frame_size = FRAMESIZE_QQVGA;
5055

51-
if (!Camera.begin()) {
56+
if (Camera.begin()) {
57+
Serial.println("Camera Init Success");
58+
} else
5259
Serial.println("Camera Init Fail");
53-
}
60+
5461
delay(500);
5562
}
5663

examples/m5core2-espnow-receiver/m5core2-espnow-receiver.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212

1313
ESPNowCam radio;
1414

15-
// frame buffer
16-
uint8_t *fb;
17-
// display globals
18-
int32_t dw, dh;
15+
uint8_t *fb; // frame buffer
16+
int32_t dw, dh; // display width and height
1917

2018
void onDataReady(uint32_t lenght) {
2119
M5.Display.drawJpg(fb, lenght , 0, 0, dw, dh);
@@ -42,8 +40,8 @@ void setup() {
4240
radio.setRecvCallback(onDataReady);
4341

4442
if (radio.init()) {
45-
M5.Display.drawString("ESPNow Init Success", dw / 2, dh / 2);
46-
Serial.println("ESPNow Init Success");
43+
M5.Display.drawString("ESPNowCam Init Success", dw / 2, dh / 2);
44+
Serial.println("ESPNowCam Init Success");
4745
}
4846
delay(500);
4947
}

examples/m5cores3-espnow-receiver/m5cores3-espnow-receiver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ void setup() {
5353
}
5454

5555
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
56-
fb = static_cast<uint8_t *>(ps_malloc(5000 * sizeof(uint8_t)));
56+
fb = static_cast<uint8_t *>(ps_malloc(15000 * sizeof(uint8_t)));
5757

5858
radio.setRecvBuffer(fb);
5959
radio.setRecvCallback(onDataReady);
6060

6161
if (radio.init()) {
62-
M5.Display.drawString("ESPNow Init Success", dw / 2, dh / 2);
62+
M5.Display.drawString("ESPNowCam Init Success", dw / 2, dh / 2);
6363
}
6464
delay(1000);
6565
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**************************************************
2+
* ESPNowCam receiver using WiFi Raw frames (802.11 Tx)
3+
* by @hpsaturn Copyright (C) 2024-2026
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
6+
**************************************************/
7+
8+
// N O T E:
9+
// -------
10+
// Don't forget first install NanoPb library!
11+
// and also review the README.md file.
12+
13+
#include <Arduino.h>
14+
#include <M5Unified.h>
15+
#include "ESPNowCam.h"
16+
#include "Utils.h"
17+
18+
WiFiRawComm wifiRaw;
19+
ESPNowCam radio(&wifiRaw);
20+
21+
uint8_t *fb; // frame buffer
22+
int32_t dw, dh; // display width and height
23+
24+
void onDataReady(uint32_t lenght) {
25+
M5.Display.drawJpg(fb, lenght , 0, 0, dw, dh);
26+
printFPS("M5Core2:");
27+
}
28+
29+
void setup() {
30+
Serial.begin(115200);
31+
Serial.setDebugOutput(true);
32+
Serial.println();
33+
delay(100);
34+
35+
auto cfg = M5.config();
36+
M5.begin(cfg);
37+
M5.Display.setBrightness(100);
38+
dw=M5.Display.width();
39+
dh=M5.Display.height();
40+
41+
if(psramFound()){
42+
size_t psram_size = esp_spiram_get_size() / 1048576;
43+
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
44+
}
45+
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
46+
fb = static_cast<uint8_t*>(ps_malloc(15000 * sizeof(uint8_t)));
47+
48+
radio.setRecvBuffer(fb);
49+
radio.setRecvCallback(onDataReady);
50+
radio.setChannel(6);
51+
52+
if (radio.init(512)) { // chunk size in bytes (beta feature)
53+
M5.Display.drawString("ESPNowCam Init Success", dw / 2, dh / 2);
54+
Serial.println("ESPNowCam Init Success");
55+
}
56+
delay(100);
57+
}
58+
59+
void loop() {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**************************************************
2+
* ESPNowCam transmitter using WiFi Raw frames (802.11 Tx)
3+
* by @hpsaturn Copyright (C) 2024-2026
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
6+
**************************************************/
7+
8+
// N O T E:
9+
// -------
10+
// Don't forget first install NanoPb library!
11+
// and also review the README.md file.
12+
13+
#include <Arduino.h>
14+
#include <ESPNowCam.h>
15+
#include <drivers/CamFreenove.h>
16+
17+
CamFreenove Camera;
18+
WiFiRawComm wifiRaw;
19+
ESPNowCam radio(&wifiRaw);
20+
21+
void processFrame() {
22+
if (Camera.get()) {
23+
uint8_t *out_jpg = NULL;
24+
size_t out_jpg_len = 0;
25+
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len);
26+
radio.sendData(out_jpg, out_jpg_len);
27+
free(out_jpg);
28+
Camera.free();
29+
}
30+
}
31+
32+
void setup() {
33+
Serial.begin(115200);
34+
Serial.setDebugOutput(true);
35+
Serial.println();
36+
delay(100);
37+
38+
if(psramFound()){
39+
size_t psram_size = esp_spiram_get_size() / 1048576;
40+
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
41+
}
42+
43+
// M5Core2 receiver
44+
const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
45+
radio.setTarget(macRecv);
46+
radio.setChannel(6);
47+
48+
if (radio.init(512)) { // chunk size in bytes (beta feature)
49+
Serial.println("ESPNowCam Init Success");
50+
}
51+
52+
// You are able to change the Camera config E.g:
53+
Camera.config.fb_count = 2;
54+
Camera.config.frame_size = FRAMESIZE_QVGA;
55+
56+
if (!Camera.begin()) {
57+
Serial.println("Camera Init Fail");
58+
}
59+
delay(100);
60+
}
61+
62+
void loop() {
63+
processFrame();
64+
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EspNowCam",
3-
"version": "0.1.17",
3+
"version": "0.2.0",
44
"homepage":"https://github.com/hpsaturn/esp32s3-cam",
55
"keywords":
66
[

0 commit comments

Comments
 (0)