Comments (3)
supposed fix:
diff --git a/mqtt/queue.c b/mqtt/queue.c
index 7fa50aa..4a7e146 100644
--- a/mqtt/queue.c
+++ b/mqtt/queue.c
@@ -34,6 +34,11 @@
#include "os_type.h"
#include "mem.h"
#include "proto.h"
+
+uint8_t *last_rb_p_r;
+uint8_t *last_rb_p_w;
+uint32_t last_fill_cnt;
+
void ICACHE_FLASH_ATTR QUEUE_Init(QUEUE *queue, int bufferSize)
{
queue->buf = (uint8_t*)os_zalloc(bufferSize);
@@ -41,7 +46,20 @@ void ICACHE_FLASH_ATTR QUEUE_Init(QUEUE *queue, int bufferSize)
}
int32_t ICACHE_FLASH_ATTR QUEUE_Puts(QUEUE *queue, uint8_t* buffer, uint16_t len)
{
- return PROTO_AddRb(&queue->rb, buffer, len);
+ uint32_t ret;
+
+ last_rb_p_r = queue->rb.p_r;
+ last_rb_p_w = queue->rb.p_w;
+ last_fill_cnt = queue->rb.fill_cnt;
+
+ ret = PROTO_AddRb(&queue->rb, buffer, len);
+ if (ret == -1) {
+ // rolling ring buffer back
+ queue->rb.p_r = last_rb_p_r;
+ queue->rb.p_w = last_rb_p_w;
+ queue->rb.fill_cnt = last_fill_cnt;
+ }
+ return ret;
}
int32_t ICACHE_FLASH_ATTR QUEUE_Gets(QUEUE *queue, uint8_t* buffer, uint16_t* len, uint16_t maxLen)
{
from esp-mqtt.
On 18 Nov 2016, at 04.46, Tuan PM [email protected] wrote:
@st0ff3r can you send a pull-request for this
done, and thanx for the nice work :)
from esp-mqtt.
@st0ff3r can you send a pull-request for this
Thanks
from esp-mqtt.
Related Issues (20)
- Make `MQTT_POLL_READ_TIMEOUT_MS` configurable through `menuconfig/sdkconfig` (IDFGH-9196) HOT 2
- printf nano formatting and using "%zu" in debug log messages (IDFGH-9208) HOT 1
- Publish data leaking to topic (IDFGH-9290) HOT 5
- Not compatible with CPP, IDF 5.0 (IDFGH-9334) HOT 5
- How can I detect Expired certificates (IDFGH-9420) HOT 3
- ESP-IDF won't connect to MQTT broker local gateway IP (IDFGH-9465) HOT 4
- Init multiple network components in separate network interfaces (IDFGH-9466) HOT 2
- MQTT 5 Bug - Checks packet header but there is none (IDFGH-9603) HOT 1
- esp_mqtt_client_publish() does not return -1 for QOS0 when disconnect (IDFGH-10129) HOT 1
- Possible bug on mqtt5 client when QoS>0 (IDFGH-10436) HOT 3
- MQTT QOS2 not resend PUBREC ACKNOWLEDGED message (IDFGH-10609)
- Qos 2 wrong implementation (IDFGH-10613) HOT 5
- Last Will Message pushed when I reconnect (IDFGH-10970) HOT 1
- esp_mqtt_set_config ignores buffer_size (IDFGH-11058) HOT 2
- AUTH command not supported (IDFGH-11745)
- MQTT data persistence (QOS 1 and 2) (IDFGH-12616) HOT 3
- Retransmission of QOS0 (IDFGH-12829) HOT 1
- Connection aborts when mqtt_resend_queued fails (IDFGH-12830) HOT 9
- Expired messages only delete when connected (IDFGH-12831)
- Memory Leak when using esp_mqtt_client_publish (IDFGH-12840) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-mqtt.