aqhomed, aqhome: added MQTT endpoint, publish value changes via MQTT.
This commit is contained in:
@@ -35,7 +35,7 @@ GWEN_MSG *GWEN_PubResponseMqttMsg_new(uint8_t typeAndFlags, uint16_t pkgId)
|
||||
|
||||
|
||||
|
||||
void AQH_PubResponseMqttMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
uint16_t AQH_PubResponseMqttMsg_GetPacketId(const GWEN_MSG *msg)
|
||||
{
|
||||
const uint8_t *msgPtr;
|
||||
uint32_t msgLen;
|
||||
@@ -47,12 +47,24 @@ void AQH_PubResponseMqttMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf,
|
||||
const uint8_t *payloadPtr;
|
||||
uint32_t payloadLen;
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf, "%s %s", AQH_MqttMsg_MsgTypeToString(msgPtr[0] & 0xf0), sText);
|
||||
payloadLen=GWEN_Msg_GetParsedPayloadSize(msg);
|
||||
payloadPtr=msgPtr+GWEN_Msg_GetParsedPayloadOffset(msg);
|
||||
if (payloadLen>=2)
|
||||
GWEN_Buffer_AppendArgs(dbuf, "(packet id=%04x)", (payloadPtr[0]<<8)+payloadPtr[1]);
|
||||
if (payloadPtr && payloadLen>=2)
|
||||
return (payloadPtr[0]<<8)+payloadPtr[1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_PubResponseMqttMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
uint8_t msgType;
|
||||
uint16_t packetId;
|
||||
|
||||
msgType=AQH_MqttMsg_GetMsgTypeAndFlags(msg);
|
||||
packetId=AQH_PubResponseMqttMsg_GetPacketId(msg);
|
||||
GWEN_Buffer_AppendArgs(dbuf, "%s %s (packet id: %04x)", AQH_MqttMsg_MsgTypeToString(msgType & 0xf0), sText, packetId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user