Simplified IPC code to use less different IPC messages. Share more code. More qork on MQTT code.
This commit is contained in:
@@ -41,6 +41,38 @@ GWEN_MSG *GWEN_SubAckMqttMsg_new(uint8_t flags, uint16_t packetId, uint8_t resul
|
||||
|
||||
|
||||
|
||||
int AQH_SubAckMqttMsg_GetResultCode(const GWEN_MSG *msg)
|
||||
{
|
||||
const uint8_t *msgPtr;
|
||||
uint32_t msgLen;
|
||||
|
||||
msgPtr=GWEN_Msg_GetConstBuffer(msg);
|
||||
msgLen=GWEN_Msg_GetBytesInBuffer(msg);
|
||||
|
||||
if (msgLen>1) {
|
||||
uint32_t flags;
|
||||
uint32_t payloadLen;
|
||||
const uint8_t *payloadPtr;
|
||||
|
||||
flags=AQH_MqttMsg_GetMsgTypeAndFlags(msg);
|
||||
payloadLen=GWEN_Msg_GetParsedPayloadSize(msg);
|
||||
payloadPtr=msgPtr+GWEN_Msg_GetParsedPayloadOffset(msg);
|
||||
|
||||
if (payloadLen>0) {
|
||||
if (flags & (AQH_MQTTMSG_FLAGS_QOS2 | AQH_MQTTMSG_FLAGS_QOS1)) {
|
||||
payloadLen--;
|
||||
payloadPtr++;
|
||||
}
|
||||
if (payloadLen>1)
|
||||
return (int) (payloadPtr[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_SubAckMqttMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
const uint8_t *msgPtr;
|
||||
|
||||
Reference in New Issue
Block a user