Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

web page publish and main loop share the MQTT send queue

オープン
#616 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

@Yukti007 がすでに取り組んでいます。

2026年10月13日 から。

評価

この issue はまだ評価されていません。

説明

High Priority regression test type: bug

Describe the bug
Messages going to the MQTT broker first go into a small queue of 8 slots. The main program adds messages to it (alarm Acknowledge/Dismiss/Shelve replies and the "online" message). The Broker Console web page also adds messages when someone presses Publish. The web page runs in a separate task that can interrupt the main program at any moment, and there is no lock. Both can pick the same empty slot. Then one message is lost, or a message goes out with one sender's topic and the other sender's text.

Short Summary of the expected behavior:
Every message added to the MQTT queue is sent once, on the right topic, with the right text, no matter which part of the program added it.

Short Summary of the buggy behavior:
If the web page and the main program add a message at the same moment, one message can be lost, or the topic and the text can come from different messages. The web page can still say "published".

To Reproduce
Found by reading the code. Not yet tested on a real Krake board. The two writes must overlap within microseconds, so this is hard to make happen on purpose. Suggested steps to try:

  1. Connect the Krake to Wi-Fi and an MQTT broker. Subscribe to its ACK topic and to a Broker Console publish topic with an MQTT client.
  2. Open the Broker Console web page on the Krake.
  3. Use a script to send many POST requests to /broker-console/publish very quickly.
  4. At the same time, send alarms to the Krake and acknowledge them on the knob, or just let the "online" message go out every 10 seconds.
  5. See error: some messages are missing on the broker, or an ACK-topic message arrives on the Broker Console topic (or the other way round).

Expected behavior
All messages arrive at the broker, each on its own topic with its own text. An operator's Acknowledge is never lost.

Screenshots
None. Not yet tested on hardware.

Hardware description
Model: Krake (GPAD_API firmware), checked against main at commit b6ea4b3 (2026-09-20)
Serial Number: N/A (found by reading the code)
Other: Affects any Krake with Wi-Fi/MQTT and the web page in use.

Test Equipment
Model: N/A (not yet tested)
Serial Number: N/A

Additional context
Where in the code:

Why it happens: queueMqtt() finds an empty slot, copies in the topic, then the text, and only then marks the slot as used. The web task can interrupt in the middle of that, see the same slot as empty, and write into it too. There is no mutex, critical section or FreeRTOS queue: a search of the firmware for mutex, Semaphore, portENTER_CRITICAL and xQueue finds nothing.

How likely: low. The two writes must overlap within microseconds. But it happens at random, cannot be reproduced on demand, and a lost Acknowledge matters on an alarm device.

Possible fix: protect queueMqtt() and serviceMqttQueue() (and the matching SPI mirror functions) with a FreeRTOS mutex or a short critical section. Or have the web handler pass the message to the main loop through a FreeRTOS queue, so only loop() touches the MQTT queue. The same handler also changes saved publish topics and settings from the web task (lines 2204–2221), so the fix should cover those too.

Not checked: the async web server library is not listed in platformio.ini, so its exact task priority and core setting could not be confirmed from this repo.

Related: #370 (MQTT messages published), #283 (shared global variables).

主要言語
C++
スター
9
フォーク
6
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PubInv/krake のほかの issue

PubInv/krake の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。