and change name to queue
This commit is contained in:
parent
cafe4ec84f
commit
a1151db62a
@ -13,30 +13,30 @@ namespace Mqtt {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char* topic = "esp_clock/sensor/ir/value";
|
const char* topic = "esp_clock/sensor/ir/value";
|
||||||
std::queue<uint8_t> list;
|
std::queue<uint8_t> queue;
|
||||||
uint8_t getCurrent() {
|
uint8_t getCurrent() {
|
||||||
return list.empty() ? 0 : list.front();
|
return queue.empty() ? 0 : queue.front();
|
||||||
}
|
}
|
||||||
void push(uint8_t el) {
|
void push(uint8_t el) {
|
||||||
list.push(el);
|
queue.push(el);
|
||||||
}
|
}
|
||||||
void pop() {
|
void pop() {
|
||||||
list.pop();
|
queue.pop();
|
||||||
}
|
}
|
||||||
uint8_t front() {
|
uint8_t front() {
|
||||||
return list.front();
|
return queue.front();
|
||||||
}
|
}
|
||||||
} commands;
|
} commands;
|
||||||
|
|
||||||
void publishCommand() {
|
void publishCommand() {
|
||||||
if (!commands.list.empty() && client.connected()) {
|
if (!commands.queue.empty() && client.connected()) {
|
||||||
char message[32];
|
char message[32];
|
||||||
uint8_t cmd = commands.front();
|
uint8_t cmd = commands.queue.front();
|
||||||
sprintf(message, "%X", cmd);
|
sprintf(message, "%X", cmd);
|
||||||
if (client.publish(commands.topic, 0, true, message) != 0) {
|
if (client.publish(commands.topic, 0, true, message) != 0) {
|
||||||
Serial.print(cmd, HEX);
|
Serial.print(cmd, HEX);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
commands.pop();
|
commands.queue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user