10000 Fix WiFiStation buffer management · Networking-for-Arduino/ESPHost@603b7c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 603b7c3

Browse files
committed
Fix WiFiStation buffer management
1 parent 8122f54 commit 603b7c3

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/CEspCommunication.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ bool CEspCom::getMsgForStation(CMsg &msg) {
137137
return false;
138138
}
139139

140+
/* -------------------------------------------------------------------------- */
141+
int CEspCom::peekMsgSizeForStation() {
142+
/* -------------------------------------------------------------------------- */
143+
if(CEspCom::rxStationQueue.size() > 0) {
144+
return CEspCom::rxStationQueue.front().get_size();
145+
}
146+
return 0;
147+
}
148+
140149
/* -------------------------------------------------------------------------- */
141150
bool CEspCom::getMsgForSoftAp(CMsg &msg) {
142151
/* -------------------------------------------------------------------------- */

src/CEspCommunication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class CEspCom {
6060
static bool storeStationMsg(CMsg &msg);
6161
static bool storeSoftApMsg(CMsg &msg);
6262
static bool getMsgForStation(CMsg &msg);
63+
static int peekMsgSizeForStation();
6364
static bool getMsgForSoftAp(CMsg &msg);
6465

6566
static void clearStationRx();

src/CEspControl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ int CEspControl::process_test_messages(CCtrlMsgWrapper* response) {
6868
return 0;
6969
}
7070

71-
7271
/* -------------------------------------------------------------------------- */
7372
uint8_t *CEspControl::getStationRx(uint8_t &if_num, uint16_t &dim) {
7473
/* -------------------------------------------------------------------------- */
7574
uint8_t *rv = nullptr;
76-
CMsg msg;
75+
CMsg msg;
7776
__disable_irq();
7877
bool res = CEspCom::getMsgForStation(msg);
7978
if(!res) {
@@ -91,6 +90,16 @@ uint8_t *CEspControl::getStationRx(uint8_t &if_num, uint16_t &dim) {
9190
return rv;
9291
}
9392

93+
/* -------------------------------------------------------------------------- */
94+
uint16_t CEspControl::peekStationRxMsgSize() {
95+
/* -------------------------------------------------------------------------- */
96+
uint16_t res;
97+
__disable_irq();
98+
res = CEspCom::peekMsgSizeForStation();
99+
__enable_irq();
100+
return res;
101+
}
102+
94103
/* -------------------------------------------------------------------------- */
95104
uint8_t *CEspControl::getSoftApRx(uint8_t &if_num, uint16_t &dim) {
96105
/* -------------------------------------------------------------------------- */

src/CEspControl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class CEspControl {
137137
int sendBuffer(ESP_INTERFACE_TYPE type, uint8_t num, uint8_t *buf, uint16_t dim);
138138

139139
uint8_t *getStationRx(uint8_t &if_num, uint16_t &dim);
140+
uint16_t peekStationRxMsgSize();
140141
uint8_t *getSoftApRx(uint8_t &if_num, uint16_t &dim);
141142

142143

0 commit comments

Comments
 (0)
0