mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 15:36:51 +01:00
Refacter the MQTT-SN Packet printf()
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -262,7 +262,7 @@ void ClientRecvTask::log(Client* client, MQTTSNPacket* packet, MQTTSNString* id)
|
||||
|
||||
void ClientRecvTask::log(const char* clientId, MQTTSNPacket* packet)
|
||||
{
|
||||
char pbuf[ (SIZE_OF_LOG_PACKET + 3) * 3];
|
||||
char pbuf[ SIZE_OF_LOG_PACKET * 3 + 1];
|
||||
char msgId[6];
|
||||
|
||||
switch (packet->getType())
|
||||
|
||||
@@ -84,7 +84,7 @@ void ClientSendTask::run()
|
||||
|
||||
void ClientSendTask::log(Client* client, MQTTSNPacket* packet)
|
||||
{
|
||||
char pbuf[(SIZE_OF_LOG_PACKET + 3) * 3];
|
||||
char pbuf[SIZE_OF_LOG_PACKET * 3 + 1];
|
||||
char msgId[6];
|
||||
const char* clientId = client ? (const char*)client->getClientId() : UNKNOWNCL ;
|
||||
|
||||
|
||||
@@ -423,12 +423,9 @@ char* MQTTSNPacket::print(char* pbuf)
|
||||
{
|
||||
char* ptr = pbuf;
|
||||
char** pptr = &pbuf;
|
||||
int value = 0;
|
||||
|
||||
int i = MQTTSNPacket_decode(_buf, _bufLen, &value);
|
||||
int size = _bufLen > SIZE_OF_LOG_PACKET ? SIZE_OF_LOG_PACKET : _bufLen;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
sprintf(*pptr, " %02X", *(_buf + i));
|
||||
*pptr += 3;
|
||||
|
||||
Reference in New Issue
Block a user