mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 04:36:38 +00:00
allow p0b1 and p[0].b[1] notiations
This commit is contained in:
parent
99fe6641d1
commit
17c5266ae5
@ -78,30 +78,36 @@ bool dispatch_factory_reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// p[x].b[y].attr=value
|
// p[x].b[y].attr=value
|
||||||
inline void dispatch_process_button_attribute(String strTopic, const char * payload)
|
inline bool dispatch_process_button_attribute(const char * topic_p, const char * payload)
|
||||||
{
|
{
|
||||||
// Log.verbose(TAG_MSGR,F("BTN ATTR: %s = %s"), strTopic.c_str(), payload);
|
// Log.verbose(TAG_MSGR,F("BTN ATTR: %s = %s"), strTopic.c_str(), payload);
|
||||||
|
|
||||||
unsigned int pageid, objid;
|
unsigned int pageid, objid;
|
||||||
const char * topic_p = strTopic.c_str();
|
// const char * topic_p = strTopic.c_str();
|
||||||
|
|
||||||
if(sscanf(topic_p, "p%ub%u.", &pageid, &objid) == 2) { // Literal String
|
if(sscanf(topic_p, HASP_OBJECT_NOTATION ".", &pageid, &objid) == 2) { // Literal String
|
||||||
|
|
||||||
// OK, continue below
|
// OK, continue below
|
||||||
|
|
||||||
} else if(sscanf(topic_p, "p[%u]b[%u].", &pageid, &objid) == 2) { // Literal String
|
} else if(sscanf(topic_p, "p[%u].b[%u].", &pageid, &objid) == 2) { // Literal String
|
||||||
|
|
||||||
// TODO: obsolete old syntax p[x].b[]y
|
// TODO: obsolete old syntax p[x].b[y].
|
||||||
// OK, continue below
|
// OK, continue below
|
||||||
|
while(*topic_p++ != '.') {
|
||||||
|
// strip to '.' character
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(*topic_p++ != '.') {
|
while(*topic_p != '.') {
|
||||||
// strip to '.' character
|
if(*topic_p == 0) return false; // strip to '.' character
|
||||||
|
topic_p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasp_process_attribute((uint8_t)pageid, (uint8_t)objid, topic_p, payload);
|
hasp_process_attribute((uint8_t)pageid, (uint8_t)objid, topic_p, payload);
|
||||||
|
return true;
|
||||||
|
|
||||||
// String strPageId((char *)0);
|
// String strPageId((char *)0);
|
||||||
// String strTemp((char *)0);
|
// String strTemp((char *)0);
|
||||||
@ -149,8 +155,8 @@ void dispatch_command(const char * topic, const char * payload)
|
|||||||
// } else if(strcasecmp_P(topic, PSTR("screenshot")) == 0) {
|
// } else if(strcasecmp_P(topic, PSTR("screenshot")) == 0) {
|
||||||
// guiTakeScreenshot("/screenshot.bmp"); // Literal String
|
// guiTakeScreenshot("/screenshot.bmp"); // Literal String
|
||||||
|
|
||||||
} else if(topic[0] == 'p') {
|
} else if(topic[0] == 'p' && dispatch_process_button_attribute(topic, payload)) {
|
||||||
dispatch_process_button_attribute(topic, payload);
|
return; // matched pxby.attr
|
||||||
|
|
||||||
#if HASP_USE_CONFIG > 0
|
#if HASP_USE_CONFIG > 0
|
||||||
|
|
||||||
@ -597,7 +603,7 @@ void dispatch_parse_jsonl(std::istringstream & stream)
|
|||||||
{
|
{
|
||||||
uint8_t savedPage = haspGetPage();
|
uint8_t savedPage = haspGetPage();
|
||||||
size_t line = 1;
|
size_t line = 1;
|
||||||
DynamicJsonDocument jsonl(MQTT_MAX_PACKET_SIZE / 2); // max ~256 characters per line
|
DynamicJsonDocument jsonl(MQTT_MAX_PACKET_SIZE / 2 + 128); // max ~256 characters per line
|
||||||
DeserializationError err = deserializeJson(jsonl, stream);
|
DeserializationError err = deserializeJson(jsonl, stream);
|
||||||
stream.setTimeout(25);
|
stream.setTimeout(25);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user