91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5.01MB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發布日期: 2023-09-26
  • 語言: 其他
  • 標簽: MT2503??FreeRT??STM32??MQTT??

資源簡介

我已經成功把MQTT移植到MT2503上。同樣的在其他MCU上是可以移植的 資源包含了MQTT源碼,移植及測試的詳細步驟

資源截圖

代碼片段和文件信息

/*******************************************************************************
?*?Copyright?(c)?2014?IBM?Corp.
?*
?*?All?rights?reserved.?This?program?and?the?accompanying?materials
?*?are?made?available?under?the?terms?of?the?Eclipse?Public?License?v1.0
?*?and?Eclipse?Distribution?License?v1.0?which?accompany?this?distribution.
?*
?*?The?Eclipse?Public?License?is?available?at
?*????http://www.eclipse.org/legal/epl-v10.html
?*?and?the?Eclipse?Distribution?License?is?available?at
?*???http://www.eclipse.org/org/documents/edl-v10.php.
?*
?*?Contributors:
?*????Ian?Craggs?-?initial?API?and?implementation?and/or?initial?documentation
?*******************************************************************************/

#include?“MQTTPacket.h“
#include?“StackTrace.h“

#include?

/**
??*?Determines?the?length?of?the?MQTT?connect?packet?that?would?be?produced?using?the?supplied?connect?options.
??*?@param?options?the?options?to?be?used?to?build?the?connect?packet
??*?@return?the?length?of?buffer?needed?to?contain?the?serialized?version?of?the?packet
??*/
int?MQTTSerialize_connectLength(MQTTPacket_connectData*?options)
{
int?len?=?0;

FUNC_ENTRY;

if?(options->MQTTVersion?==?3)
len?=?12;?/*?variable?depending?on?MQTT?or?MQIsdp?*/
else?if?(options->MQTTVersion?==?4)
len?=?10;

len?+=?MQTTstrlen(options->clientID)+2;
if?(options->willFlag)
len?+=?MQTTstrlen(options->will.topicName)+2?+?MQTTstrlen(options->will.message)+2;
if?(options->username.cstring?||?options->username.lenstring.data)
len?+=?MQTTstrlen(options->username)+2;
if?(options->password.cstring?||?options->password.lenstring.data)
len?+=?MQTTstrlen(options->password)+2;

FUNC_EXIT_RC(len);
return?len;
}


/**
??*?Serializes?the?connect?options?into?the?buffer.
??*?@param?buf?the?buffer?into?which?the?packet?will?be?serialized
??*?@param?len?the?length?in?bytes?of?the?supplied?buffer
??*?@param?options?the?options?to?be?used?to?build?the?connect?packet
??*?@return?serialized?length?or?error?if?0
??*/
int?MQTTSerialize_connect(unsigned?char*?buf?int?buflen?MQTTPacket_connectData*?options)
{
unsigned?char?*ptr?=?buf;
MQTTHeader?header?=?{0};
MQTTConnectFlags?flags?=?{0};
int?len?=?0;
int?rc?=?-1;

FUNC_ENTRY;
if?(MQTTPacket_len(len?=?MQTTSerialize_connectLength(options))?>?buflen)
{
rc?=?MQTTPACKET_BUFFER_TOO_SHORT;
goto?exit;
}

header.byte?=?0;
header.bits.type?=?CONNECT;
writeChar(&ptr?header.byte);?/*?write?header?*/

ptr?+=?MQTTPacket_encode(ptr?len);?/*?write?remaining?length?*/

if?(options->MQTTVersion?==?4)
{
writeCString(&ptr?“MQTT“);
writeChar(&ptr?(char)?4);
}
else
{
writeCString(&ptr?“MQIsdp“);
writeChar(&ptr?(char)?3);
}

flags.all?=?0;
flags.bits.cleansession?=?options->cleansession;
flags.bits.will?=?(options->willFlag)???1?:?0;
if?(flags.bits.will)
{
flags.bits.willQoS?=?options->will.qos;
flags.bits.willRetain?=?options->will.retained;
}

if?(options->username.cstring?||?options->username.lenstring.dat

評論

共有 條評論