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