delete some unused code
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,912 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
|
||||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
|
||||||
|
|
||||||
<SchemaVersion>2.1</SchemaVersion>
|
|
||||||
|
|
||||||
<Header>### uVision Project, (C) Keil Software</Header>
|
|
||||||
|
|
||||||
<Targets>
|
|
||||||
<Target>
|
|
||||||
<TargetName>TencentOS_tiny</TargetName>
|
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
|
||||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
|
||||||
<uAC6>0</uAC6>
|
|
||||||
<TargetOption>
|
|
||||||
<TargetCommonOption>
|
|
||||||
<Device>STM32L431RCTx</Device>
|
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
|
||||||
<PackID>Keil.STM32L4xx_DFP.2.0.0</PackID>
|
|
||||||
<PackURL>http://www.keil.com/pack</PackURL>
|
|
||||||
<Cpu>IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
|
||||||
<StartupFile></StartupFile>
|
|
||||||
<FlashDriverDll></FlashDriverDll>
|
|
||||||
<DeviceId></DeviceId>
|
|
||||||
<RegisterFile></RegisterFile>
|
|
||||||
<MemoryEnv></MemoryEnv>
|
|
||||||
<Cmp></Cmp>
|
|
||||||
<Asm></Asm>
|
|
||||||
<Linker></Linker>
|
|
||||||
<OHString></OHString>
|
|
||||||
<InfinionOptionDll></InfinionOptionDll>
|
|
||||||
<SLE66CMisc></SLE66CMisc>
|
|
||||||
<SLE66AMisc></SLE66AMisc>
|
|
||||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
|
||||||
<SFDFile>$$Device:STM32L431RCTx$CMSIS\SVD\STM32L4x1.svd</SFDFile>
|
|
||||||
<bCustSvd>0</bCustSvd>
|
|
||||||
<UseEnv>0</UseEnv>
|
|
||||||
<BinPath></BinPath>
|
|
||||||
<IncludePath></IncludePath>
|
|
||||||
<LibPath></LibPath>
|
|
||||||
<RegisterFilePath></RegisterFilePath>
|
|
||||||
<DBRegisterFilePath></DBRegisterFilePath>
|
|
||||||
<TargetStatus>
|
|
||||||
<Error>0</Error>
|
|
||||||
<ExitCodeStop>0</ExitCodeStop>
|
|
||||||
<ButtonStop>0</ButtonStop>
|
|
||||||
<NotGenerated>0</NotGenerated>
|
|
||||||
<InvalidFlash>1</InvalidFlash>
|
|
||||||
</TargetStatus>
|
|
||||||
<OutputDirectory>.\obj\</OutputDirectory>
|
|
||||||
<OutputName>TencentOS_tiny</OutputName>
|
|
||||||
<CreateExecutable>1</CreateExecutable>
|
|
||||||
<CreateLib>0</CreateLib>
|
|
||||||
<CreateHexFile>1</CreateHexFile>
|
|
||||||
<DebugInformation>1</DebugInformation>
|
|
||||||
<BrowseInformation>0</BrowseInformation>
|
|
||||||
<ListingPath>.\list\</ListingPath>
|
|
||||||
<HexFormatSelection>1</HexFormatSelection>
|
|
||||||
<Merge32K>0</Merge32K>
|
|
||||||
<CreateBatchFile>0</CreateBatchFile>
|
|
||||||
<BeforeCompile>
|
|
||||||
<RunUserProg1>0</RunUserProg1>
|
|
||||||
<RunUserProg2>0</RunUserProg2>
|
|
||||||
<UserProg1Name></UserProg1Name>
|
|
||||||
<UserProg2Name></UserProg2Name>
|
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
|
||||||
<nStopU1X>0</nStopU1X>
|
|
||||||
<nStopU2X>0</nStopU2X>
|
|
||||||
</BeforeCompile>
|
|
||||||
<BeforeMake>
|
|
||||||
<RunUserProg1>0</RunUserProg1>
|
|
||||||
<RunUserProg2>0</RunUserProg2>
|
|
||||||
<UserProg1Name></UserProg1Name>
|
|
||||||
<UserProg2Name></UserProg2Name>
|
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
|
||||||
<nStopB1X>0</nStopB1X>
|
|
||||||
<nStopB2X>0</nStopB2X>
|
|
||||||
</BeforeMake>
|
|
||||||
<AfterMake>
|
|
||||||
<RunUserProg1>0</RunUserProg1>
|
|
||||||
<RunUserProg2>0</RunUserProg2>
|
|
||||||
<UserProg1Name></UserProg1Name>
|
|
||||||
<UserProg2Name></UserProg2Name>
|
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
|
||||||
<nStopA1X>0</nStopA1X>
|
|
||||||
<nStopA2X>0</nStopA2X>
|
|
||||||
</AfterMake>
|
|
||||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
|
||||||
<SVCSIdString></SVCSIdString>
|
|
||||||
</TargetCommonOption>
|
|
||||||
<CommonProperty>
|
|
||||||
<UseCPPCompiler>0</UseCPPCompiler>
|
|
||||||
<RVCTCodeConst>0</RVCTCodeConst>
|
|
||||||
<RVCTZI>0</RVCTZI>
|
|
||||||
<RVCTOtherData>0</RVCTOtherData>
|
|
||||||
<ModuleSelection>0</ModuleSelection>
|
|
||||||
<IncludeInBuild>1</IncludeInBuild>
|
|
||||||
<AlwaysBuild>0</AlwaysBuild>
|
|
||||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
|
||||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
|
||||||
<PublicsOnly>0</PublicsOnly>
|
|
||||||
<StopOnExitCode>3</StopOnExitCode>
|
|
||||||
<CustomArgument></CustomArgument>
|
|
||||||
<IncludeLibraryModules></IncludeLibraryModules>
|
|
||||||
<ComprImg>0</ComprImg>
|
|
||||||
</CommonProperty>
|
|
||||||
<DllOption>
|
|
||||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
|
||||||
<SimDllArguments>-REMAP -MPU</SimDllArguments>
|
|
||||||
<SimDlgDll>DCM.DLL</SimDlgDll>
|
|
||||||
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
|
|
||||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
|
||||||
<TargetDllArguments>-MPU</TargetDllArguments>
|
|
||||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
|
||||||
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
|
|
||||||
</DllOption>
|
|
||||||
<DebugOption>
|
|
||||||
<OPTHX>
|
|
||||||
<HexSelection>1</HexSelection>
|
|
||||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
|
||||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
|
||||||
<HexOffset>0</HexOffset>
|
|
||||||
<Oh166RecLen>16</Oh166RecLen>
|
|
||||||
</OPTHX>
|
|
||||||
</DebugOption>
|
|
||||||
<Utilities>
|
|
||||||
<Flash1>
|
|
||||||
<UseTargetDll>1</UseTargetDll>
|
|
||||||
<UseExternalTool>0</UseExternalTool>
|
|
||||||
<RunIndependent>0</RunIndependent>
|
|
||||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
|
||||||
<Capability>1</Capability>
|
|
||||||
<DriverSelection>4107</DriverSelection>
|
|
||||||
</Flash1>
|
|
||||||
<bUseTDR>1</bUseTDR>
|
|
||||||
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
|
|
||||||
<Flash3></Flash3>
|
|
||||||
<Flash4></Flash4>
|
|
||||||
<pFcarmOut></pFcarmOut>
|
|
||||||
<pFcarmGrp></pFcarmGrp>
|
|
||||||
<pFcArmRoot></pFcArmRoot>
|
|
||||||
<FcArmLst>0</FcArmLst>
|
|
||||||
</Utilities>
|
|
||||||
<TargetArmAds>
|
|
||||||
<ArmAdsMisc>
|
|
||||||
<GenerateListings>0</GenerateListings>
|
|
||||||
<asHll>1</asHll>
|
|
||||||
<asAsm>1</asAsm>
|
|
||||||
<asMacX>1</asMacX>
|
|
||||||
<asSyms>1</asSyms>
|
|
||||||
<asFals>1</asFals>
|
|
||||||
<asDbgD>1</asDbgD>
|
|
||||||
<asForm>1</asForm>
|
|
||||||
<ldLst>0</ldLst>
|
|
||||||
<ldmm>1</ldmm>
|
|
||||||
<ldXref>1</ldXref>
|
|
||||||
<BigEnd>0</BigEnd>
|
|
||||||
<AdsALst>1</AdsALst>
|
|
||||||
<AdsACrf>1</AdsACrf>
|
|
||||||
<AdsANop>0</AdsANop>
|
|
||||||
<AdsANot>0</AdsANot>
|
|
||||||
<AdsLLst>1</AdsLLst>
|
|
||||||
<AdsLmap>1</AdsLmap>
|
|
||||||
<AdsLcgr>1</AdsLcgr>
|
|
||||||
<AdsLsym>1</AdsLsym>
|
|
||||||
<AdsLszi>1</AdsLszi>
|
|
||||||
<AdsLtoi>1</AdsLtoi>
|
|
||||||
<AdsLsun>1</AdsLsun>
|
|
||||||
<AdsLven>1</AdsLven>
|
|
||||||
<AdsLsxf>1</AdsLsxf>
|
|
||||||
<RvctClst>0</RvctClst>
|
|
||||||
<GenPPlst>0</GenPPlst>
|
|
||||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
|
||||||
<RvctDeviceName></RvctDeviceName>
|
|
||||||
<mOS>0</mOS>
|
|
||||||
<uocRom>0</uocRom>
|
|
||||||
<uocRam>0</uocRam>
|
|
||||||
<hadIROM>1</hadIROM>
|
|
||||||
<hadIRAM>1</hadIRAM>
|
|
||||||
<hadXRAM>0</hadXRAM>
|
|
||||||
<uocXRam>0</uocXRam>
|
|
||||||
<RvdsVP>2</RvdsVP>
|
|
||||||
<RvdsMve>0</RvdsMve>
|
|
||||||
<hadIRAM2>0</hadIRAM2>
|
|
||||||
<hadIROM2>0</hadIROM2>
|
|
||||||
<StupSel>8</StupSel>
|
|
||||||
<useUlib>1</useUlib>
|
|
||||||
<EndSel>0</EndSel>
|
|
||||||
<uLtcg>0</uLtcg>
|
|
||||||
<nSecure>0</nSecure>
|
|
||||||
<RoSelD>3</RoSelD>
|
|
||||||
<RwSelD>3</RwSelD>
|
|
||||||
<CodeSel>0</CodeSel>
|
|
||||||
<OptFeed>0</OptFeed>
|
|
||||||
<NoZi1>0</NoZi1>
|
|
||||||
<NoZi2>0</NoZi2>
|
|
||||||
<NoZi3>0</NoZi3>
|
|
||||||
<NoZi4>0</NoZi4>
|
|
||||||
<NoZi5>0</NoZi5>
|
|
||||||
<Ro1Chk>0</Ro1Chk>
|
|
||||||
<Ro2Chk>0</Ro2Chk>
|
|
||||||
<Ro3Chk>0</Ro3Chk>
|
|
||||||
<Ir1Chk>1</Ir1Chk>
|
|
||||||
<Ir2Chk>0</Ir2Chk>
|
|
||||||
<Ra1Chk>0</Ra1Chk>
|
|
||||||
<Ra2Chk>0</Ra2Chk>
|
|
||||||
<Ra3Chk>0</Ra3Chk>
|
|
||||||
<Im1Chk>1</Im1Chk>
|
|
||||||
<Im2Chk>0</Im2Chk>
|
|
||||||
<OnChipMemories>
|
|
||||||
<Ocm1>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm1>
|
|
||||||
<Ocm2>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm2>
|
|
||||||
<Ocm3>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm3>
|
|
||||||
<Ocm4>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm4>
|
|
||||||
<Ocm5>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm5>
|
|
||||||
<Ocm6>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</Ocm6>
|
|
||||||
<IRAM>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x20000000</StartAddress>
|
|
||||||
<Size>0x10000</Size>
|
|
||||||
</IRAM>
|
|
||||||
<IROM>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x8000000</StartAddress>
|
|
||||||
<Size>0x40000</Size>
|
|
||||||
</IROM>
|
|
||||||
<XRAM>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</XRAM>
|
|
||||||
<OCR_RVCT1>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT1>
|
|
||||||
<OCR_RVCT2>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT2>
|
|
||||||
<OCR_RVCT3>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT3>
|
|
||||||
<OCR_RVCT4>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x8000000</StartAddress>
|
|
||||||
<Size>0x40000</Size>
|
|
||||||
</OCR_RVCT4>
|
|
||||||
<OCR_RVCT5>
|
|
||||||
<Type>1</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT5>
|
|
||||||
<OCR_RVCT6>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT6>
|
|
||||||
<OCR_RVCT7>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT7>
|
|
||||||
<OCR_RVCT8>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT8>
|
|
||||||
<OCR_RVCT9>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x20000000</StartAddress>
|
|
||||||
<Size>0x10000</Size>
|
|
||||||
</OCR_RVCT9>
|
|
||||||
<OCR_RVCT10>
|
|
||||||
<Type>0</Type>
|
|
||||||
<StartAddress>0x0</StartAddress>
|
|
||||||
<Size>0x0</Size>
|
|
||||||
</OCR_RVCT10>
|
|
||||||
</OnChipMemories>
|
|
||||||
<RvctStartVector></RvctStartVector>
|
|
||||||
</ArmAdsMisc>
|
|
||||||
<Cads>
|
|
||||||
<interw>1</interw>
|
|
||||||
<Optim>1</Optim>
|
|
||||||
<oTime>0</oTime>
|
|
||||||
<SplitLS>0</SplitLS>
|
|
||||||
<OneElfS>1</OneElfS>
|
|
||||||
<Strict>0</Strict>
|
|
||||||
<EnumInt>0</EnumInt>
|
|
||||||
<PlainCh>0</PlainCh>
|
|
||||||
<Ropi>0</Ropi>
|
|
||||||
<Rwpi>0</Rwpi>
|
|
||||||
<wLevel>2</wLevel>
|
|
||||||
<uThumb>0</uThumb>
|
|
||||||
<uSurpInc>0</uSurpInc>
|
|
||||||
<uC99>1</uC99>
|
|
||||||
<uGnu>0</uGnu>
|
|
||||||
<useXO>0</useXO>
|
|
||||||
<v6Lang>1</v6Lang>
|
|
||||||
<v6LangP>1</v6LangP>
|
|
||||||
<vShortEn>1</vShortEn>
|
|
||||||
<vShortWch>1</vShortWch>
|
|
||||||
<v6Lto>0</v6Lto>
|
|
||||||
<v6WtE>0</v6WtE>
|
|
||||||
<v6Rtti>0</v6Rtti>
|
|
||||||
<VariousControls>
|
|
||||||
<MiscControls></MiscControls>
|
|
||||||
<Define>USE_HAL_DRIVER,STM32L431xx</Define>
|
|
||||||
<Undefine></Undefine>
|
|
||||||
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\kernel\core\include;..\..\TOS-CONFIG;..\..\..\..\platform\arch\arm\cortex-m4\keil;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\BSP\Hardware\DHT11;..\..\BSP\Hardware\BH1750;..\..\BSP\Hardware\OLED;..\..\..\..\examples\helloworld;..\..\..\..\net\at\include;..\..\..\..\kernel\hal\include;..\..\..\..\net\sal_module_wrapper;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\wrapper\include;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\include;..\..\..\..\examples\mqtt;..\..\..\..\devices\bc35_28_95;..\..\..\..\devices\esp8266;..\..\..\..\devices\m26</IncludePath>
|
|
||||||
</VariousControls>
|
|
||||||
</Cads>
|
|
||||||
<Aads>
|
|
||||||
<interw>1</interw>
|
|
||||||
<Ropi>0</Ropi>
|
|
||||||
<Rwpi>0</Rwpi>
|
|
||||||
<thumb>0</thumb>
|
|
||||||
<SplitLS>0</SplitLS>
|
|
||||||
<SwStkChk>0</SwStkChk>
|
|
||||||
<NoWarn>0</NoWarn>
|
|
||||||
<uSurpInc>0</uSurpInc>
|
|
||||||
<useXO>0</useXO>
|
|
||||||
<uClangAs>0</uClangAs>
|
|
||||||
<VariousControls>
|
|
||||||
<MiscControls></MiscControls>
|
|
||||||
<Define></Define>
|
|
||||||
<Undefine></Undefine>
|
|
||||||
<IncludePath></IncludePath>
|
|
||||||
</VariousControls>
|
|
||||||
</Aads>
|
|
||||||
<LDads>
|
|
||||||
<umfTarg>1</umfTarg>
|
|
||||||
<Ropi>0</Ropi>
|
|
||||||
<Rwpi>0</Rwpi>
|
|
||||||
<noStLib>0</noStLib>
|
|
||||||
<RepFail>1</RepFail>
|
|
||||||
<useFile>0</useFile>
|
|
||||||
<TextAddressRange>0x08000000</TextAddressRange>
|
|
||||||
<DataAddressRange>0x20000000</DataAddressRange>
|
|
||||||
<pXoBase></pXoBase>
|
|
||||||
<ScatterFile></ScatterFile>
|
|
||||||
<IncludeLibs></IncludeLibs>
|
|
||||||
<IncludeLibsPath></IncludeLibsPath>
|
|
||||||
<Misc></Misc>
|
|
||||||
<LinkerInputFile></LinkerInputFile>
|
|
||||||
<DisabledWarnings></DisabledWarnings>
|
|
||||||
</LDads>
|
|
||||||
</TargetArmAds>
|
|
||||||
</TargetOption>
|
|
||||||
<Groups>
|
|
||||||
<Group>
|
|
||||||
<GroupName>Application/MDK-ARM</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>startup_stm32l431xx.s</FileName>
|
|
||||||
<FileType>2</FileType>
|
|
||||||
<FilePath>startup_stm32l431xx.s</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>Application/User</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>gpio.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\gpio.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>main.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\main.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>mcu_init.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\mcu_init.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_msp.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\stm32l4xx_hal_msp.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>usart.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\usart.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>adc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\adc.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>dac.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\dac.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>i2c.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\i2c.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>spi.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\spi.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_it_module.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\stm32l4xx_it_module.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tim.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\tim.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>examples</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>mqtt_example.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\examples\tencent_os_mqtt\mqtt_example.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>Drivers/STM32L4xx_HAL_Driver</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_tim.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_tim_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_uart.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_uart_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_i2c.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_i2c_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_rcc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_rcc_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_flash.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_flash_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_flash_ramfunc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_gpio.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_dma.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_dma_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_pwr.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_pwr_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_cortex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_adc_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_adc.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_dac.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_dac_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_spi.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>stm32l4xx_hal_spi_ex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>Drivers/CMSIS</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>system_stm32l4xx.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Src\system_stm32l4xx.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>Hardware</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>DHT11_BUS.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Hardware\DHT11\DHT11_BUS.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>oled.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Hardware\OLED\oled.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>BH1750.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\BSP\Hardware\BH1750\BH1750.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>kernel</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_binary_heap.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_binary_heap.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_char_fifo.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_char_fifo.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_completion.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_completion.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_countdownlatch.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_countdownlatch.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_event.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_event.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_global.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_global.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_mail_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_mail_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_message_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_message_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_mmblk.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_mmblk.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_mmheap.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_mmheap.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_mutex.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_mutex.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_pend.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_pend.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_priority_mail_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_priority_mail_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_priority_message_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_priority_message_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_priority_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_priority_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_ring_queue.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_ring_queue.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_robin.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_robin.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_sched.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_sched.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_sem.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_sem.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_sys.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_sys.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_task.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_task.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_tick.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_tick.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_time.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_time.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_timer.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_timer.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_stopwatch.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\kernel\core\tos_stopwatch.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>cpu</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>port_s.S</FileName>
|
|
||||||
<FileType>2</FileType>
|
|
||||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_cpu.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>port_c.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>cmsis</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>cmsis_os.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\osal\cmsis_os\cmsis_os.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>config</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_config.h</FileName>
|
|
||||||
<FileType>5</FileType>
|
|
||||||
<FilePath>..\..\TOS-CONFIG\tos_config.h</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>devices</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>bc35_28_95.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\devices\bc35_28_95\bc35_28_95.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>esp8266.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\devices\esp8266\esp8266.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>hal</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_hal_uart.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\platform\hal\st\stm32l4xx\src\tos_hal_uart.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>at</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>tos_at.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\net\at\src\tos_at.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>sal_module_wrapper.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\net\sal_module_wrapper\sal_module_wrapper.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>mqtt</GroupName>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<FileName>mqtt_wrapper.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\wrapper\src\mqtt_wrapper.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>transport_wrapper.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\wrapper\src\transport_wrapper.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTConnectClient.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTConnectClient.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTConnectServer.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTConnectServer.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTDeserializePublish.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTDeserializePublish.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTFormat.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTFormat.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTPacket.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTPacket.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTSerializePublish.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTSerializePublish.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTSubscribeClient.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTSubscribeClient.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTSubscribeServer.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTSubscribeServer.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTUnsubscribeClient.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTUnsubscribeClient.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>MQTTUnsubscribeServer.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\src\MQTTUnsubscribeServer.c</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
</Group>
|
|
||||||
<Group>
|
|
||||||
<GroupName>::CMSIS</GroupName>
|
|
||||||
</Group>
|
|
||||||
</Groups>
|
|
||||||
</Target>
|
|
||||||
</Targets>
|
|
||||||
|
|
||||||
<RTE>
|
|
||||||
<apis/>
|
|
||||||
<components>
|
|
||||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
|
|
||||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
|
|
||||||
<targetInfos>
|
|
||||||
<targetInfo name="TencentOS_tiny"/>
|
|
||||||
</targetInfos>
|
|
||||||
</component>
|
|
||||||
</components>
|
|
||||||
<files/>
|
|
||||||
</RTE>
|
|
||||||
|
|
||||||
</Project>
|
|
@@ -1,404 +0,0 @@
|
|||||||
;********************** COPYRIGHT(c) 2017 STMicroelectronics ******************
|
|
||||||
;* File Name : startup_stm32l431xx.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32L431xx Ultra Low Power devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M4 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
|
||||||
;*******************************************************************************
|
|
||||||
;*
|
|
||||||
;* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
;* are permitted provided that the following conditions are met:
|
|
||||||
;* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
;* this list of conditions and the following disclaimer.
|
|
||||||
;* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
;* this list of conditions and the following disclaimer in the documentation
|
|
||||||
;* and/or other materials provided with the distribution.
|
|
||||||
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
||||||
;* may be used to endorse or promote products derived from this software
|
|
||||||
;* without specific prior written permission.
|
|
||||||
;*
|
|
||||||
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
;*
|
|
||||||
;*******************************************************************************
|
|
||||||
;
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x100
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x100
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window WatchDog
|
|
||||||
DCD PVD_PVM_IRQHandler ; PVD/PVM1/PVM2/PVM3/PVM4 through EXTI Line detection
|
|
||||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
|
||||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
|
||||||
DCD FLASH_IRQHandler ; FLASH
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
|
||||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
|
||||||
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
|
|
||||||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
|
|
||||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SDMMC1_IRQHandler ; SDMMC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
|
|
||||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
|
|
||||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD COMP_IRQHandler ; COMP Interrupt
|
|
||||||
DCD LPTIM1_IRQHandler ; LP TIM1 interrupt
|
|
||||||
DCD LPTIM2_IRQHandler ; LP TIM2 interrupt
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6
|
|
||||||
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7
|
|
||||||
DCD LPUART1_IRQHandler ; LP UART1 interrupt
|
|
||||||
DCD QUADSPI_IRQHandler ; Quad SPI global interrupt
|
|
||||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
|
||||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
|
||||||
DCD SAI1_IRQHandler ; Serial Audio Interface 1 global interrupt
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SWPMI1_IRQHandler ; Serial Wire Interface 1 global interrupt
|
|
||||||
DCD TSC_IRQHandler ; Touch Sense Controller global interrupt
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD RNG_IRQHandler ; RNG global interrupt
|
|
||||||
DCD FPU_IRQHandler ; FPU
|
|
||||||
DCD CRS_IRQHandler ; CRS interrupt
|
|
||||||
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT SystemInit
|
|
||||||
IMPORT __main
|
|
||||||
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_PVM_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMP_STAMP_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT SDMMC1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT COMP_IRQHandler [WEAK]
|
|
||||||
EXPORT LPTIM1_IRQHandler [WEAK]
|
|
||||||
EXPORT LPTIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT LPUART1_IRQHandler [WEAK]
|
|
||||||
EXPORT QUADSPI_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C3_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C3_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SAI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SWPMI1_IRQHandler [WEAK]
|
|
||||||
EXPORT TSC_IRQHandler [WEAK]
|
|
||||||
EXPORT RNG_IRQHandler [WEAK]
|
|
||||||
EXPORT FPU_IRQHandler [WEAK]
|
|
||||||
EXPORT CRS_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_PVM_IRQHandler
|
|
||||||
TAMP_STAMP_IRQHandler
|
|
||||||
RTC_WKUP_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
CAN1_TX_IRQHandler
|
|
||||||
CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_TIM15_IRQHandler
|
|
||||||
TIM1_UP_TIM16_IRQHandler
|
|
||||||
TIM1_TRG_COM_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
SDMMC1_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
TIM6_DAC_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_IRQHandler
|
|
||||||
DMA2_Channel5_IRQHandler
|
|
||||||
COMP_IRQHandler
|
|
||||||
LPTIM1_IRQHandler
|
|
||||||
LPTIM2_IRQHandler
|
|
||||||
DMA2_Channel6_IRQHandler
|
|
||||||
DMA2_Channel7_IRQHandler
|
|
||||||
LPUART1_IRQHandler
|
|
||||||
QUADSPI_IRQHandler
|
|
||||||
I2C3_EV_IRQHandler
|
|
||||||
I2C3_ER_IRQHandler
|
|
||||||
SAI1_IRQHandler
|
|
||||||
SWPMI1_IRQHandler
|
|
||||||
TSC_IRQHandler
|
|
||||||
RNG_IRQHandler
|
|
||||||
FPU_IRQHandler
|
|
||||||
CRS_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
|
@@ -1,148 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2014, 2017 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
|
|
||||||
* Ian Craggs - add connack return code definitions
|
|
||||||
* Xiang Rong - 442039 Add makefile to Embedded C client
|
|
||||||
* Ian Craggs - fix for issue #64, bit order in connack response
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MQTTCONNECT_H_
|
|
||||||
#define MQTTCONNECT_H_
|
|
||||||
|
|
||||||
enum connack_return_codes
|
|
||||||
{
|
|
||||||
MQTT_CONNECTION_ACCEPTED = 0,
|
|
||||||
MQTT_UNNACCEPTABLE_PROTOCOL = 1,
|
|
||||||
MQTT_CLIENTID_REJECTED = 2,
|
|
||||||
MQTT_SERVER_UNAVAILABLE = 3,
|
|
||||||
MQTT_BAD_USERNAME_OR_PASSWORD = 4,
|
|
||||||
MQTT_NOT_AUTHORIZED = 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(DLLImport)
|
|
||||||
#define DLLImport
|
|
||||||
#endif
|
|
||||||
#if !defined(DLLExport)
|
|
||||||
#define DLLExport
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
unsigned char all; /**< all connect flags */
|
|
||||||
#if defined(REVERSED)
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int username : 1; /**< 3.1 user name */
|
|
||||||
unsigned int password : 1; /**< 3.1 password */
|
|
||||||
unsigned int willRetain : 1; /**< will retain setting */
|
|
||||||
unsigned int willQoS : 2; /**< will QoS value */
|
|
||||||
unsigned int will : 1; /**< will flag */
|
|
||||||
unsigned int cleansession : 1; /**< clean session flag */
|
|
||||||
unsigned int : 1; /**< unused */
|
|
||||||
} bits;
|
|
||||||
#else
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int : 1; /**< unused */
|
|
||||||
unsigned int cleansession : 1; /**< cleansession flag */
|
|
||||||
unsigned int will : 1; /**< will flag */
|
|
||||||
unsigned int willQoS : 2; /**< will QoS value */
|
|
||||||
unsigned int willRetain : 1; /**< will retain setting */
|
|
||||||
unsigned int password : 1; /**< 3.1 password */
|
|
||||||
unsigned int username : 1; /**< 3.1 user name */
|
|
||||||
} bits;
|
|
||||||
#endif
|
|
||||||
} MQTTConnectFlags; /**< connect flags byte */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines the MQTT "Last Will and Testament" (LWT) settings for
|
|
||||||
* the connect packet.
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/** The eyecatcher for this structure. must be MQTW. */
|
|
||||||
char struct_id[4];
|
|
||||||
/** The version number of this structure. Must be 0 */
|
|
||||||
int struct_version;
|
|
||||||
/** The LWT topic to which the LWT message will be published. */
|
|
||||||
MQTTString topicName;
|
|
||||||
/** The LWT payload. */
|
|
||||||
MQTTString message;
|
|
||||||
/**
|
|
||||||
* The retained flag for the LWT message (see MQTTAsync_message.retained).
|
|
||||||
*/
|
|
||||||
unsigned char retained;
|
|
||||||
/**
|
|
||||||
* The quality of service setting for the LWT message (see
|
|
||||||
* MQTTAsync_message.qos and @ref qos).
|
|
||||||
*/
|
|
||||||
char qos;
|
|
||||||
} MQTTPacket_willOptions;
|
|
||||||
|
|
||||||
|
|
||||||
#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/** The eyecatcher for this structure. must be MQTC. */
|
|
||||||
char struct_id[4];
|
|
||||||
/** The version number of this structure. Must be 0 */
|
|
||||||
int struct_version;
|
|
||||||
/** Version of MQTT to be used. 3 = 3.1 4 = 3.1.1
|
|
||||||
*/
|
|
||||||
unsigned char MQTTVersion;
|
|
||||||
MQTTString clientID;
|
|
||||||
unsigned short keepAliveInterval;
|
|
||||||
unsigned char cleansession;
|
|
||||||
unsigned char willFlag;
|
|
||||||
MQTTPacket_willOptions will;
|
|
||||||
MQTTString username;
|
|
||||||
MQTTString password;
|
|
||||||
} MQTTPacket_connectData;
|
|
||||||
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
unsigned char all; /**< all connack flags */
|
|
||||||
#if defined(REVERSED)
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int reserved : 7; /**< unused */
|
|
||||||
unsigned int sessionpresent : 1; /**< session present flag */
|
|
||||||
} bits;
|
|
||||||
#else
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int sessionpresent : 1; /**< session present flag */
|
|
||||||
unsigned int reserved: 7; /**< unused */
|
|
||||||
} bits;
|
|
||||||
#endif
|
|
||||||
} MQTTConnackFlags; /**< connack flags byte */
|
|
||||||
|
|
||||||
#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
|
|
||||||
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options);
|
|
||||||
DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len);
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent);
|
|
||||||
DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen);
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen);
|
|
||||||
DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen);
|
|
||||||
|
|
||||||
#endif /* MQTTCONNECT_H_ */
|
|
@@ -1,37 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#if !defined(MQTTFORMAT_H)
|
|
||||||
#define MQTTFORMAT_H
|
|
||||||
|
|
||||||
#include "StackTrace.h"
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
|
|
||||||
const char* MQTTPacket_getName(unsigned short packetid);
|
|
||||||
int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data);
|
|
||||||
int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent);
|
|
||||||
int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
|
|
||||||
unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen);
|
|
||||||
int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid);
|
|
||||||
int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
|
|
||||||
MQTTString topicFilters[], int requestedQoSs[]);
|
|
||||||
int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs);
|
|
||||||
int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
|
|
||||||
int count, MQTTString topicFilters[]);
|
|
||||||
char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
|
|
||||||
char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,134 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Xiang Rong - 442039 Add makefile to Embedded C client
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MQTTPACKET_H_
|
|
||||||
#define MQTTPACKET_H_
|
|
||||||
|
|
||||||
#if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32_DLL) || defined(WIN64_DLL)
|
|
||||||
#define DLLImport __declspec(dllimport)
|
|
||||||
#define DLLExport __declspec(dllexport)
|
|
||||||
#elif defined(LINUX_SO)
|
|
||||||
#define DLLImport extern
|
|
||||||
#define DLLExport __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
|
||||||
#define DLLImport
|
|
||||||
#define DLLExport
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum errors
|
|
||||||
{
|
|
||||||
MQTTPACKET_BUFFER_TOO_SHORT = -2,
|
|
||||||
MQTTPACKET_READ_ERROR = -1,
|
|
||||||
MQTTPACKET_READ_COMPLETE
|
|
||||||
};
|
|
||||||
|
|
||||||
enum msgTypes
|
|
||||||
{
|
|
||||||
CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL,
|
|
||||||
PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,
|
|
||||||
PINGREQ, PINGRESP, DISCONNECT
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bitfields for the MQTT header byte.
|
|
||||||
*/
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
unsigned char byte; /**< the whole byte */
|
|
||||||
#if defined(REVERSED)
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int type : 4; /**< message type nibble */
|
|
||||||
unsigned int dup : 1; /**< DUP flag bit */
|
|
||||||
unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
|
|
||||||
unsigned int retain : 1; /**< retained flag bit */
|
|
||||||
} bits;
|
|
||||||
#else
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int retain : 1; /**< retained flag bit */
|
|
||||||
unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
|
|
||||||
unsigned int dup : 1; /**< DUP flag bit */
|
|
||||||
unsigned int type : 4; /**< message type nibble */
|
|
||||||
} bits;
|
|
||||||
#endif
|
|
||||||
} MQTTHeader;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
char* data;
|
|
||||||
} MQTTLenString;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char* cstring;
|
|
||||||
MQTTLenString lenstring;
|
|
||||||
} MQTTString;
|
|
||||||
|
|
||||||
#define MQTTString_initializer {NULL, {0, NULL}}
|
|
||||||
|
|
||||||
int MQTTstrlen(MQTTString mqttstring);
|
|
||||||
|
|
||||||
#include "MQTTConnect.h"
|
|
||||||
#include "MQTTPublish.h"
|
|
||||||
#include "MQTTSubscribe.h"
|
|
||||||
#include "MQTTUnsubscribe.h"
|
|
||||||
#include "MQTTFormat.h"
|
|
||||||
#include "tos_k.h"
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid);
|
|
||||||
DLLExport int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen);
|
|
||||||
|
|
||||||
int MQTTPacket_len(int rem_len);
|
|
||||||
DLLExport int MQTTPacket_equals(MQTTString* a, char* b);
|
|
||||||
|
|
||||||
DLLExport int MQTTPacket_encode(unsigned char* buf, int length);
|
|
||||||
int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value);
|
|
||||||
int MQTTPacket_decodeBuf(unsigned char* buf, int* value);
|
|
||||||
|
|
||||||
int readInt(unsigned char** pptr);
|
|
||||||
char readChar(unsigned char** pptr);
|
|
||||||
void writeChar(unsigned char** pptr, char c);
|
|
||||||
void writeInt(unsigned char** pptr, int anInt);
|
|
||||||
int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata);
|
|
||||||
void writeCString(unsigned char** pptr, const char* string);
|
|
||||||
void writeMQTTString(unsigned char** pptr, MQTTString mqttstring);
|
|
||||||
|
|
||||||
DLLExport int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int (*getfn)(void *, unsigned char*, int); /* must return -1 for error, 0 for call again, or the number of bytes read */
|
|
||||||
void *sck; /* pointer to whatever the system may use to identify the transport */
|
|
||||||
int multiplier;
|
|
||||||
int rem_len;
|
|
||||||
int len;
|
|
||||||
char state;
|
|
||||||
}MQTTTransport;
|
|
||||||
|
|
||||||
int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp);
|
|
||||||
|
|
||||||
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MQTTPACKET_H_ */
|
|
@@ -1,38 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Xiang Rong - 442039 Add makefile to Embedded C client
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MQTTPUBLISH_H_
|
|
||||||
#define MQTTPUBLISH_H_
|
|
||||||
|
|
||||||
#if !defined(DLLImport)
|
|
||||||
#define DLLImport
|
|
||||||
#endif
|
|
||||||
#if !defined(DLLExport)
|
|
||||||
#define DLLExport
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
|
|
||||||
MQTTString topicName, unsigned char* payload, int payloadlen);
|
|
||||||
|
|
||||||
DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
|
|
||||||
unsigned char** payload, int* payloadlen, unsigned char* buf, int len);
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid);
|
|
||||||
DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid);
|
|
||||||
DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid);
|
|
||||||
|
|
||||||
#endif /* MQTTPUBLISH_H_ */
|
|
@@ -1,39 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Xiang Rong - 442039 Add makefile to Embedded C client
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MQTTSUBSCRIBE_H_
|
|
||||||
#define MQTTSUBSCRIBE_H_
|
|
||||||
|
|
||||||
#if !defined(DLLImport)
|
|
||||||
#define DLLImport
|
|
||||||
#endif
|
|
||||||
#if !defined(DLLExport)
|
|
||||||
#define DLLExport
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
|
|
||||||
int count, MQTTString topicFilters[], int requestedQoSs[]);
|
|
||||||
|
|
||||||
DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid,
|
|
||||||
int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len);
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs);
|
|
||||||
|
|
||||||
DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MQTTSUBSCRIBE_H_ */
|
|
@@ -1,38 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Xiang Rong - 442039 Add makefile to Embedded C client
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MQTTUNSUBSCRIBE_H_
|
|
||||||
#define MQTTUNSUBSCRIBE_H_
|
|
||||||
|
|
||||||
#if !defined(DLLImport)
|
|
||||||
#define DLLImport
|
|
||||||
#endif
|
|
||||||
#if !defined(DLLExport)
|
|
||||||
#define DLLExport
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
|
|
||||||
int count, MQTTString topicFilters[]);
|
|
||||||
|
|
||||||
DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[],
|
|
||||||
unsigned char* buf, int len);
|
|
||||||
|
|
||||||
DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid);
|
|
||||||
|
|
||||||
DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len);
|
|
||||||
|
|
||||||
#endif /* MQTTUNSUBSCRIBE_H_ */
|
|
@@ -1,78 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Ian Craggs - fix for bug #434081
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef STACKTRACE_H_
|
|
||||||
#define STACKTRACE_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#define NOSTACKTRACE 1
|
|
||||||
|
|
||||||
#if defined(NOSTACKTRACE)
|
|
||||||
#define FUNC_ENTRY
|
|
||||||
#define FUNC_ENTRY_NOLOG
|
|
||||||
#define FUNC_ENTRY_MED
|
|
||||||
#define FUNC_ENTRY_MAX
|
|
||||||
#define FUNC_EXIT
|
|
||||||
#define FUNC_EXIT_NOLOG
|
|
||||||
#define FUNC_EXIT_MED
|
|
||||||
#define FUNC_EXIT_MAX
|
|
||||||
#define FUNC_EXIT_RC(x)
|
|
||||||
#define FUNC_EXIT_MED_RC(x)
|
|
||||||
#define FUNC_EXIT_MAX_RC(x)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
|
||||||
#define inline __inline
|
|
||||||
#define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)
|
|
||||||
#define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)
|
|
||||||
#define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM)
|
|
||||||
#define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM)
|
|
||||||
#define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM)
|
|
||||||
#define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, -1)
|
|
||||||
#define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM)
|
|
||||||
#define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM)
|
|
||||||
#define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM)
|
|
||||||
#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM)
|
|
||||||
#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM)
|
|
||||||
#else
|
|
||||||
#define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM)
|
|
||||||
#define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1)
|
|
||||||
#define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM)
|
|
||||||
#define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM)
|
|
||||||
#define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM)
|
|
||||||
#define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1)
|
|
||||||
#define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM)
|
|
||||||
#define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM)
|
|
||||||
#define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM)
|
|
||||||
#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM)
|
|
||||||
#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM)
|
|
||||||
|
|
||||||
void StackTrace_entry(const char* name, int line, int trace);
|
|
||||||
void StackTrace_exit(const char* name, int line, void* return_value, int trace);
|
|
||||||
|
|
||||||
void StackTrace_printStack(FILE* dest);
|
|
||||||
char* StackTrace_get(unsigned long);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* STACKTRACE_H_ */
|
|
@@ -1,214 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 <string.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.data)
|
|
||||||
flags.bits.username = 1;
|
|
||||||
if (options->password.cstring || options->password.lenstring.data)
|
|
||||||
flags.bits.password = 1;
|
|
||||||
|
|
||||||
writeChar(&ptr, flags.all);
|
|
||||||
writeInt(&ptr, options->keepAliveInterval);
|
|
||||||
writeMQTTString(&ptr, options->clientID);
|
|
||||||
if (options->willFlag)
|
|
||||||
{
|
|
||||||
writeMQTTString(&ptr, options->will.topicName);
|
|
||||||
writeMQTTString(&ptr, options->will.message);
|
|
||||||
}
|
|
||||||
if (flags.bits.username)
|
|
||||||
writeMQTTString(&ptr, options->username);
|
|
||||||
if (flags.bits.password)
|
|
||||||
writeMQTTString(&ptr, options->password);
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
|
|
||||||
exit: FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into connack data - return code
|
|
||||||
* @param sessionPresent the session present flag returned (only for MQTT 3.1.1)
|
|
||||||
* @param connack_rc returned integer value of the connack return code
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param len the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success, 0 is failure
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
int mylen;
|
|
||||||
MQTTConnackFlags flags = {0};
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != CONNACK)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
if (enddata - curdata < 2)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
flags.all = readChar(&curdata);
|
|
||||||
*sessionPresent = flags.bits.sessionpresent;
|
|
||||||
*connack_rc = readChar(&curdata);
|
|
||||||
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
|
|
||||||
* @param packettype the message type
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rc = -1;
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (buflen < 2)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = packettype;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a disconnect packet into the supplied buffer, ready for writing to a socket
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_disconnect(unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
return MQTTSerialize_zero(buf, buflen, DISCONNECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a disconnect packet into the supplied buffer, ready for writing to a socket
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_pingreq(unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
return MQTTSerialize_zero(buf, buflen, PINGREQ);
|
|
||||||
}
|
|
@@ -1,146 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 "StackTrace.h"
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define min(a, b) ((a < b) ? a : b)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates MQTT protocol name and version combinations
|
|
||||||
* @param protocol the MQTT protocol name as an MQTTString
|
|
||||||
* @param version the MQTT protocol version number, as in the connect packet
|
|
||||||
* @return correct MQTT combination? 1 is true, 0 is false
|
|
||||||
*/
|
|
||||||
int MQTTPacket_checkVersion(MQTTString* protocol, int version)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
if (version == 3 && memcmp(protocol->lenstring.data, "MQIsdp",
|
|
||||||
min(6, protocol->lenstring.len)) == 0)
|
|
||||||
rc = 1;
|
|
||||||
else if (version == 4 && memcmp(protocol->lenstring.data, "MQTT",
|
|
||||||
min(4, protocol->lenstring.len)) == 0)
|
|
||||||
rc = 1;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into connect data structure
|
|
||||||
* @param data the connect data structure to be filled out
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param len the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success, 0 is failure
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
MQTTConnectFlags flags = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = &buf[len];
|
|
||||||
int rc = 0;
|
|
||||||
MQTTString Protocol;
|
|
||||||
int version;
|
|
||||||
int mylen = 0;
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != CONNECT)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
|
|
||||||
|
|
||||||
if (!readMQTTLenString(&Protocol, &curdata, enddata) ||
|
|
||||||
enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
version = (int)readChar(&curdata); /* Protocol version */
|
|
||||||
/* If we don't recognize the protocol version, we don't parse the connect packet on the
|
|
||||||
* basis that we don't know what the format will be.
|
|
||||||
*/
|
|
||||||
if (MQTTPacket_checkVersion(&Protocol, version))
|
|
||||||
{
|
|
||||||
flags.all = readChar(&curdata);
|
|
||||||
data->cleansession = flags.bits.cleansession;
|
|
||||||
data->keepAliveInterval = readInt(&curdata);
|
|
||||||
if (!readMQTTLenString(&data->clientID, &curdata, enddata))
|
|
||||||
goto exit;
|
|
||||||
data->willFlag = flags.bits.will;
|
|
||||||
if (flags.bits.will)
|
|
||||||
{
|
|
||||||
data->will.qos = flags.bits.willQoS;
|
|
||||||
data->will.retained = flags.bits.willRetain;
|
|
||||||
if (!readMQTTLenString(&data->will.topicName, &curdata, enddata) ||
|
|
||||||
!readMQTTLenString(&data->will.message, &curdata, enddata))
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (flags.bits.username)
|
|
||||||
{
|
|
||||||
if (enddata - curdata < 3 || !readMQTTLenString(&data->username, &curdata, enddata))
|
|
||||||
goto exit; /* username flag set, but no username supplied - invalid */
|
|
||||||
if (flags.bits.password &&
|
|
||||||
(enddata - curdata < 3 || !readMQTTLenString(&data->password, &curdata, enddata)))
|
|
||||||
goto exit; /* password flag set, but no password supplied - invalid */
|
|
||||||
}
|
|
||||||
else if (flags.bits.password)
|
|
||||||
goto exit; /* password flag set without username - invalid */
|
|
||||||
rc = 1;
|
|
||||||
}
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the connack packet into the supplied buffer.
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param connack_rc the integer connack return code to be used
|
|
||||||
* @param sessionPresent the MQTT 3.1.1 sessionPresent flag
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rc = 0;
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
MQTTConnackFlags flags = {0};
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (buflen < 2)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = CONNACK;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
|
|
||||||
|
|
||||||
flags.all = 0;
|
|
||||||
flags.bits.sessionpresent = sessionPresent;
|
|
||||||
writeChar(&ptr, flags.all);
|
|
||||||
writeChar(&ptr, connack_rc);
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
@@ -1,107 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 "StackTrace.h"
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define min(a, b) ((a < b) ? 1 : 0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into publish data
|
|
||||||
* @param dup returned integer - the MQTT dup flag
|
|
||||||
* @param qos returned integer - the MQTT QoS value
|
|
||||||
* @param retained returned integer - the MQTT retained flag
|
|
||||||
* @param packetid returned integer - the MQTT packet identifier
|
|
||||||
* @param topicName returned MQTTString - the MQTT topic in the publish
|
|
||||||
* @param payload returned byte buffer - the MQTT publish payload
|
|
||||||
* @param payloadlen returned integer - the length of the MQTT payload
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
|
|
||||||
unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
int mylen = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != PUBLISH)
|
|
||||||
goto exit;
|
|
||||||
*dup = header.bits.dup;
|
|
||||||
*qos = header.bits.qos;
|
|
||||||
*retained = header.bits.retain;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
|
|
||||||
if (!readMQTTLenString(topicName, &curdata, enddata) ||
|
|
||||||
enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
if (*qos > 0)
|
|
||||||
*packetid = readInt(&curdata);
|
|
||||||
|
|
||||||
*payloadlen = enddata - curdata;
|
|
||||||
*payload = curdata;
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into an ack
|
|
||||||
* @param packettype returned integer - the MQTT packet type
|
|
||||||
* @param dup returned integer - the MQTT dup flag
|
|
||||||
* @param packetid returned integer - the MQTT packet identifier
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success, 0 is failure
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
int mylen;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
*dup = header.bits.dup;
|
|
||||||
*packettype = header.bits.type;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
|
|
||||||
if (enddata - curdata < 2)
|
|
||||||
goto exit;
|
|
||||||
*packetid = readInt(&curdata);
|
|
||||||
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
@@ -1,262 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 "StackTrace.h"
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
const char* MQTTPacket_names[] =
|
|
||||||
{
|
|
||||||
"RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
|
|
||||||
"PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
|
|
||||||
"PINGREQ", "PINGRESP", "DISCONNECT"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const char* MQTTPacket_getName(unsigned short packetid)
|
|
||||||
{
|
|
||||||
return MQTTPacket_names[packetid];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data)
|
|
||||||
{
|
|
||||||
int strindex = 0;
|
|
||||||
|
|
||||||
strindex = snprintf(strbuf, strbuflen,
|
|
||||||
"CONNECT MQTT version %d, client id %.*s, clean session %d, keep alive %d",
|
|
||||||
(int)data->MQTTVersion, data->clientID.lenstring.len, data->clientID.lenstring.data,
|
|
||||||
(int)data->cleansession, data->keepAliveInterval);
|
|
||||||
if (data->willFlag)
|
|
||||||
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
|
|
||||||
", will QoS %d, will retain %d, will topic %.*s, will message %.*s",
|
|
||||||
data->will.qos, data->will.retained,
|
|
||||||
data->will.topicName.lenstring.len, data->will.topicName.lenstring.data,
|
|
||||||
data->will.message.lenstring.len, data->will.message.lenstring.data);
|
|
||||||
if (data->username.lenstring.data && data->username.lenstring.len > 0)
|
|
||||||
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
|
|
||||||
", user name %.*s", data->username.lenstring.len, data->username.lenstring.data);
|
|
||||||
if (data->password.lenstring.data && data->password.lenstring.len > 0)
|
|
||||||
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
|
|
||||||
", password %.*s", data->password.lenstring.len, data->password.lenstring.data);
|
|
||||||
return strindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
|
|
||||||
{
|
|
||||||
int strindex = snprintf(strbuf, strbuflen, "CONNACK session present %d, rc %d", sessionPresent, connack_rc);
|
|
||||||
return strindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
|
|
||||||
unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen)
|
|
||||||
{
|
|
||||||
int strindex = snprintf(strbuf, strbuflen,
|
|
||||||
"PUBLISH dup %d, QoS %d, retained %d, packet id %d, topic %.*s, payload length %d, payload %.*s",
|
|
||||||
dup, qos, retained, packetid,
|
|
||||||
(topicName.lenstring.len < 20) ? topicName.lenstring.len : 20, topicName.lenstring.data,
|
|
||||||
payloadlen, (payloadlen < 20) ? payloadlen : 20, payload);
|
|
||||||
return strindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
|
|
||||||
{
|
|
||||||
int strindex = snprintf(strbuf, strbuflen, "%s, packet id %d", MQTTPacket_names[packettype], packetid);
|
|
||||||
if (dup)
|
|
||||||
strindex += snprintf(strbuf + strindex, strbuflen - strindex, ", dup %d", dup);
|
|
||||||
return strindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
|
|
||||||
MQTTString topicFilters[], int requestedQoSs[])
|
|
||||||
{
|
|
||||||
return snprintf(strbuf, strbuflen,
|
|
||||||
"SUBSCRIBE dup %d, packet id %d count %d topic %.*s qos %d",
|
|
||||||
dup, packetid, count,
|
|
||||||
topicFilters[0].lenstring.len, topicFilters[0].lenstring.data,
|
|
||||||
requestedQoSs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs)
|
|
||||||
{
|
|
||||||
return snprintf(strbuf, strbuflen,
|
|
||||||
"SUBACK packet id %d count %d granted qos %d", packetid, count, grantedQoSs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
|
|
||||||
int count, MQTTString topicFilters[])
|
|
||||||
{
|
|
||||||
return snprintf(strbuf, strbuflen,
|
|
||||||
"UNSUBSCRIBE dup %d, packet id %d count %d topic %.*s",
|
|
||||||
dup, packetid, count,
|
|
||||||
topicFilters[0].lenstring.len, topicFilters[0].lenstring.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(MQTT_CLIENT)
|
|
||||||
char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
int rem_length = 0;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int strindex = 0;
|
|
||||||
|
|
||||||
header.byte = buf[index++];
|
|
||||||
index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
|
|
||||||
|
|
||||||
switch (header.bits.type)
|
|
||||||
{
|
|
||||||
|
|
||||||
case CONNACK:
|
|
||||||
{
|
|
||||||
unsigned char sessionPresent, connack_rc;
|
|
||||||
if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_connack(strbuf, strbuflen, connack_rc, sessionPresent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUBLISH:
|
|
||||||
{
|
|
||||||
unsigned char dup, retained, *payload;
|
|
||||||
unsigned short packetid;
|
|
||||||
int qos, payloadlen;
|
|
||||||
MQTTString topicName = MQTTString_initializer;
|
|
||||||
if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
|
|
||||||
&payload, &payloadlen, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
|
|
||||||
topicName, payload, payloadlen);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUBACK:
|
|
||||||
case PUBREC:
|
|
||||||
case PUBREL:
|
|
||||||
case PUBCOMP:
|
|
||||||
{
|
|
||||||
unsigned char packettype, dup;
|
|
||||||
unsigned short packetid;
|
|
||||||
if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SUBACK:
|
|
||||||
{
|
|
||||||
unsigned short packetid;
|
|
||||||
int maxcount = 1, count = 0;
|
|
||||||
int grantedQoSs[1];
|
|
||||||
if (MQTTDeserialize_suback(&packetid, maxcount, &count, grantedQoSs, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_suback(strbuf, strbuflen, packetid, count, grantedQoSs);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UNSUBACK:
|
|
||||||
{
|
|
||||||
unsigned short packetid;
|
|
||||||
if (MQTTDeserialize_unsuback(&packetid, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_ack(strbuf, strbuflen, UNSUBACK, 0, packetid);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PINGREQ:
|
|
||||||
case PINGRESP:
|
|
||||||
case DISCONNECT:
|
|
||||||
strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return strbuf;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MQTT_SERVER)
|
|
||||||
char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
int rem_length = 0;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int strindex = 0;
|
|
||||||
|
|
||||||
header.byte = buf[index++];
|
|
||||||
index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
|
|
||||||
|
|
||||||
switch (header.bits.type)
|
|
||||||
{
|
|
||||||
case CONNECT:
|
|
||||||
{
|
|
||||||
MQTTPacket_connectData data;
|
|
||||||
int rc;
|
|
||||||
if ((rc = MQTTDeserialize_connect(&data, buf, buflen)) == 1)
|
|
||||||
strindex = MQTTStringFormat_connect(strbuf, strbuflen, &data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUBLISH:
|
|
||||||
{
|
|
||||||
unsigned char dup, retained, *payload;
|
|
||||||
unsigned short packetid;
|
|
||||||
int qos, payloadlen;
|
|
||||||
MQTTString topicName = MQTTString_initializer;
|
|
||||||
if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
|
|
||||||
&payload, &payloadlen, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
|
|
||||||
topicName, payload, payloadlen);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUBACK:
|
|
||||||
case PUBREC:
|
|
||||||
case PUBREL:
|
|
||||||
case PUBCOMP:
|
|
||||||
{
|
|
||||||
unsigned char packettype, dup;
|
|
||||||
unsigned short packetid;
|
|
||||||
if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SUBSCRIBE:
|
|
||||||
{
|
|
||||||
unsigned char dup;
|
|
||||||
unsigned short packetid;
|
|
||||||
int maxcount = 1, count = 0;
|
|
||||||
MQTTString topicFilters[1];
|
|
||||||
int requestedQoSs[1];
|
|
||||||
if (MQTTDeserialize_subscribe(&dup, &packetid, maxcount, &count,
|
|
||||||
topicFilters, requestedQoSs, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_subscribe(strbuf, strbuflen, dup, packetid, count, topicFilters, requestedQoSs);;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UNSUBSCRIBE:
|
|
||||||
{
|
|
||||||
unsigned char dup;
|
|
||||||
unsigned short packetid;
|
|
||||||
int maxcount = 1, count = 0;
|
|
||||||
MQTTString topicFilters[1];
|
|
||||||
if (MQTTDeserialize_unsubscribe(&dup, &packetid, maxcount, &count, topicFilters, buf, buflen) == 1)
|
|
||||||
strindex = MQTTStringFormat_unsubscribe(strbuf, strbuflen, dup, packetid, count, topicFilters);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PINGREQ:
|
|
||||||
case PINGRESP:
|
|
||||||
case DISCONNECT:
|
|
||||||
strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strbuf[strbuflen] = '\0';
|
|
||||||
return strbuf;
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -1,414 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Sergio R. Caprile - non-blocking packet read functions for stream transport
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "StackTrace.h"
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encodes the message length according to the MQTT algorithm
|
|
||||||
* @param buf the buffer into which the encoded data is written
|
|
||||||
* @param length the length to be encoded
|
|
||||||
* @return the number of bytes written to buffer
|
|
||||||
*/
|
|
||||||
int MQTTPacket_encode(unsigned char* buf, int length)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
char d = length % 128;
|
|
||||||
length /= 128;
|
|
||||||
/* if there are more digits to encode, set the top bit of this digit */
|
|
||||||
if (length > 0)
|
|
||||||
d |= 0x80;
|
|
||||||
buf[rc++] = d;
|
|
||||||
} while (length > 0);
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decodes the message length according to the MQTT algorithm
|
|
||||||
* @param getcharfn pointer to function to read the next character from the data source
|
|
||||||
* @param value the decoded length returned
|
|
||||||
* @return the number of bytes read from the socket
|
|
||||||
*/
|
|
||||||
int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value)
|
|
||||||
{
|
|
||||||
unsigned char c;
|
|
||||||
int multiplier = 1;
|
|
||||||
int len = 0;
|
|
||||||
#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
*value = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int rc = MQTTPACKET_READ_ERROR;
|
|
||||||
|
|
||||||
if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_READ_ERROR; /* bad data */
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
rc = (*getcharfn)(&c, 1);
|
|
||||||
if (rc != 1)
|
|
||||||
goto exit;
|
|
||||||
*value += (c & 127) * multiplier;
|
|
||||||
multiplier *= 128;
|
|
||||||
} while ((c & 128) != 0);
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(len);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTPacket_len(int rem_len)
|
|
||||||
{
|
|
||||||
rem_len += 1; /* header byte */
|
|
||||||
|
|
||||||
/* now remaining_length field */
|
|
||||||
if (rem_len < 128)
|
|
||||||
rem_len += 1;
|
|
||||||
else if (rem_len < 16384)
|
|
||||||
rem_len += 2;
|
|
||||||
else if (rem_len < 2097151)
|
|
||||||
rem_len += 3;
|
|
||||||
else
|
|
||||||
rem_len += 4;
|
|
||||||
return rem_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char* bufptr;
|
|
||||||
|
|
||||||
int bufchar(unsigned char* c, int count)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
*c = *bufptr++;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MQTTPacket_decodeBuf(unsigned char* buf, int* value)
|
|
||||||
{
|
|
||||||
bufptr = buf;
|
|
||||||
return MQTTPacket_decode(bufchar, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates an integer from two bytes read from the input buffer
|
|
||||||
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
|
|
||||||
* @return the integer value calculated
|
|
||||||
*/
|
|
||||||
int readInt(unsigned char** pptr)
|
|
||||||
{
|
|
||||||
unsigned char* ptr = *pptr;
|
|
||||||
int len = 256*(*ptr) + (*(ptr+1));
|
|
||||||
*pptr += 2;
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads one character from the input buffer.
|
|
||||||
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
|
|
||||||
* @return the character read
|
|
||||||
*/
|
|
||||||
char readChar(unsigned char** pptr)
|
|
||||||
{
|
|
||||||
char c = **pptr;
|
|
||||||
(*pptr)++;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes one character to an output buffer.
|
|
||||||
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
|
|
||||||
* @param c the character to write
|
|
||||||
*/
|
|
||||||
void writeChar(unsigned char** pptr, char c)
|
|
||||||
{
|
|
||||||
**pptr = c;
|
|
||||||
(*pptr)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes an integer as 2 bytes to an output buffer.
|
|
||||||
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
|
|
||||||
* @param anInt the integer to write
|
|
||||||
*/
|
|
||||||
void writeInt(unsigned char** pptr, int anInt)
|
|
||||||
{
|
|
||||||
**pptr = (unsigned char)(anInt / 256);
|
|
||||||
(*pptr)++;
|
|
||||||
**pptr = (unsigned char)(anInt % 256);
|
|
||||||
(*pptr)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a "UTF" string to an output buffer. Converts C string to length-delimited.
|
|
||||||
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
|
|
||||||
* @param string the C string to write
|
|
||||||
*/
|
|
||||||
void writeCString(unsigned char** pptr, const char* string)
|
|
||||||
{
|
|
||||||
int len = strlen(string);
|
|
||||||
writeInt(pptr, len);
|
|
||||||
memcpy(*pptr, string, len);
|
|
||||||
*pptr += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int getLenStringLen(char* ptr)
|
|
||||||
{
|
|
||||||
int len = 256*((unsigned char)(*ptr)) + (unsigned char)(*(ptr+1));
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void writeMQTTString(unsigned char** pptr, MQTTString mqttstring)
|
|
||||||
{
|
|
||||||
if (mqttstring.lenstring.len > 0)
|
|
||||||
{
|
|
||||||
writeInt(pptr, mqttstring.lenstring.len);
|
|
||||||
memcpy(*pptr, mqttstring.lenstring.data, mqttstring.lenstring.len);
|
|
||||||
*pptr += mqttstring.lenstring.len;
|
|
||||||
}
|
|
||||||
else if (mqttstring.cstring)
|
|
||||||
writeCString(pptr, mqttstring.cstring);
|
|
||||||
else
|
|
||||||
writeInt(pptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mqttstring the MQTTString structure into which the data is to be read
|
|
||||||
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
|
|
||||||
* @param enddata pointer to the end of the data: do not read beyond
|
|
||||||
* @return 1 if successful, 0 if not
|
|
||||||
*/
|
|
||||||
int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
/* the first two bytes are the length of the string */
|
|
||||||
if (enddata - (*pptr) > 1) /* enough length to read the integer? */
|
|
||||||
{
|
|
||||||
mqttstring->lenstring.len = readInt(pptr); /* increments pptr to point past length */
|
|
||||||
if (&(*pptr)[mqttstring->lenstring.len] <= enddata)
|
|
||||||
{
|
|
||||||
mqttstring->lenstring.data = (char*)*pptr;
|
|
||||||
*pptr += mqttstring->lenstring.len;
|
|
||||||
rc = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mqttstring->cstring = NULL;
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string
|
|
||||||
* @param mqttstring the string to return the length of
|
|
||||||
* @return the length of the string
|
|
||||||
*/
|
|
||||||
int MQTTstrlen(MQTTString mqttstring)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
if (mqttstring.cstring)
|
|
||||||
rc = strlen(mqttstring.cstring);
|
|
||||||
else
|
|
||||||
rc = mqttstring.lenstring.len;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares an MQTTString to a C string
|
|
||||||
* @param a the MQTTString to compare
|
|
||||||
* @param bptr the C string to compare
|
|
||||||
* @return boolean - equal or not
|
|
||||||
*/
|
|
||||||
int MQTTPacket_equals(MQTTString* a, char* bptr)
|
|
||||||
{
|
|
||||||
int alen = 0,
|
|
||||||
blen = 0;
|
|
||||||
char *aptr;
|
|
||||||
|
|
||||||
if (a->cstring)
|
|
||||||
{
|
|
||||||
aptr = a->cstring;
|
|
||||||
alen = strlen(a->cstring);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aptr = a->lenstring.data;
|
|
||||||
alen = a->lenstring.len;
|
|
||||||
}
|
|
||||||
blen = strlen(bptr);
|
|
||||||
|
|
||||||
return (alen == blen) && (strncmp(aptr, bptr, alen) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to read packet data from some source into a buffer
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param getfn pointer to a function which will read any number of bytes from the needed source
|
|
||||||
* @return integer MQTT packet type, or -1 on error
|
|
||||||
* @note the whole message must fit into the caller's buffer
|
|
||||||
*/
|
|
||||||
int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int))
|
|
||||||
{
|
|
||||||
int rc = -1;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int len = 0;
|
|
||||||
int rem_len = 0;
|
|
||||||
|
|
||||||
/* 1. read the header byte. This has the packet type in it */
|
|
||||||
if ((*getfn)(buf, 1) != 1)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
len = 1;
|
|
||||||
/* 2. read the remaining length. This is variable in itself */
|
|
||||||
|
|
||||||
MQTTPacket_decode(getfn, &rem_len);
|
|
||||||
len += MQTTPacket_encode(buf + 1, rem_len); /* put the original remaining length back into the buffer */
|
|
||||||
|
|
||||||
/* 3. read the rest of the buffer using a callback to supply the rest of the data */
|
|
||||||
if((rem_len + len) > buflen)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
if (rem_len && ((*getfn)(buf + len, rem_len) != rem_len))
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
header.byte = buf[0];
|
|
||||||
rc = header.bits.type;
|
|
||||||
exit:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decodes the message length according to the MQTT algorithm, non-blocking
|
|
||||||
* @param trp pointer to a transport structure holding what is needed to solve getting data from it
|
|
||||||
* @param value the decoded length returned
|
|
||||||
* @return integer the number of bytes read from the socket, 0 for call again, or -1 on error
|
|
||||||
*/
|
|
||||||
static int MQTTPacket_decodenb(MQTTTransport *trp)
|
|
||||||
{
|
|
||||||
unsigned char c;
|
|
||||||
int rc = MQTTPACKET_READ_ERROR;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if(trp->len == 0){ /* initialize on first call */
|
|
||||||
trp->multiplier = 1;
|
|
||||||
trp->rem_len = 0;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
int frc;
|
|
||||||
if (trp->len >= MAX_NO_OF_REMAINING_LENGTH_BYTES)
|
|
||||||
goto exit;
|
|
||||||
if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1)
|
|
||||||
goto exit;
|
|
||||||
if (frc == 0){
|
|
||||||
rc = 0;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
++(trp->len);
|
|
||||||
trp->rem_len += (c & 127) * trp->multiplier;
|
|
||||||
trp->multiplier *= 128;
|
|
||||||
} while ((c & 128) != 0);
|
|
||||||
rc = trp->len;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to read packet data from some source into a buffer, non-blocking
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param trp pointer to a transport structure holding what is needed to solve getting data from it
|
|
||||||
* @return integer MQTT packet type, 0 for call again, or -1 on error
|
|
||||||
* @note the whole message must fit into the caller's buffer
|
|
||||||
*/
|
|
||||||
int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp)
|
|
||||||
{
|
|
||||||
int rc = -1, frc;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
|
|
||||||
switch(trp->state){
|
|
||||||
default:
|
|
||||||
trp->state = 0;
|
|
||||||
/*FALLTHROUGH*/
|
|
||||||
case 0:
|
|
||||||
/* read the header byte. This has the packet type in it */
|
|
||||||
if ((frc=(*trp->getfn)(trp->sck, buf, 1)) == -1)
|
|
||||||
goto exit;
|
|
||||||
if (frc == 0)
|
|
||||||
return 0;
|
|
||||||
trp->len = 0;
|
|
||||||
++trp->state;
|
|
||||||
/*FALLTHROUGH*/
|
|
||||||
/* read the remaining length. This is variable in itself */
|
|
||||||
case 1:
|
|
||||||
if((frc=MQTTPacket_decodenb(trp)) == MQTTPACKET_READ_ERROR)
|
|
||||||
goto exit;
|
|
||||||
if(frc == 0)
|
|
||||||
return 0;
|
|
||||||
trp->len = 1 + MQTTPacket_encode(buf + 1, trp->rem_len); /* put the original remaining length back into the buffer */
|
|
||||||
if((trp->rem_len + trp->len) > buflen)
|
|
||||||
goto exit;
|
|
||||||
++trp->state;
|
|
||||||
/*FALLTHROUGH*/
|
|
||||||
case 2:
|
|
||||||
if(trp->rem_len){
|
|
||||||
/* read the rest of the buffer using a callback to supply the rest of the data */
|
|
||||||
if ((frc=(*trp->getfn)(trp->sck, buf + trp->len, trp->rem_len)) == -1)
|
|
||||||
goto exit;
|
|
||||||
if (frc == 0)
|
|
||||||
return 0;
|
|
||||||
trp->rem_len -= frc;
|
|
||||||
trp->len += frc;
|
|
||||||
if(trp->rem_len)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
header.byte = buf[0];
|
|
||||||
rc = header.bits.type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
trp->state = 0;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
@@ -1,169 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
#include "StackTrace.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines the length of the MQTT publish packet that would be produced using the supplied parameters
|
|
||||||
* @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0)
|
|
||||||
* @param topicName the topic name to be used in the publish
|
|
||||||
* @param payloadlen the length of the payload to be sent
|
|
||||||
* @return the length of buffer needed to contain the serialized version of the packet
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen)
|
|
||||||
{
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
len += 2 + MQTTstrlen(topicName) + payloadlen;
|
|
||||||
if (qos > 0)
|
|
||||||
len += 2; /* packetid */
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the supplied publish data into the supplied buffer, ready for sending
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param dup integer - the MQTT dup flag
|
|
||||||
* @param qos integer - the MQTT QoS value
|
|
||||||
* @param retained integer - the MQTT retained flag
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @param topicName MQTTString - the MQTT topic in the publish
|
|
||||||
* @param payload byte buffer - the MQTT publish payload
|
|
||||||
* @param payloadlen integer - the length of the MQTT payload
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
|
|
||||||
MQTTString topicName, unsigned char* payload, int payloadlen)
|
|
||||||
{
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rem_len = 0;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(qos, topicName, payloadlen)) > buflen)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
header.bits.type = PUBLISH;
|
|
||||||
header.bits.dup = dup;
|
|
||||||
header.bits.qos = qos;
|
|
||||||
header.bits.retain = retained;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
|
|
||||||
|
|
||||||
writeMQTTString(&ptr, topicName);
|
|
||||||
|
|
||||||
if (qos > 0)
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
|
|
||||||
memcpy(ptr, payload, payloadlen);
|
|
||||||
ptr += payloadlen;
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the ack packet into the supplied buffer.
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param type the MQTT packet type
|
|
||||||
* @param dup the MQTT dup flag
|
|
||||||
* @param packetid the MQTT packet identifier
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rc = 0;
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (buflen < 4)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
header.bits.type = packettype;
|
|
||||||
header.bits.dup = dup;
|
|
||||||
header.bits.qos = (packettype == PUBREL) ? 1 : 0;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a puback packet into the supplied buffer.
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid)
|
|
||||||
{
|
|
||||||
return MQTTSerialize_ack(buf, buflen, PUBACK, 0, packetid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a pubrel packet into the supplied buffer.
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param dup integer - the MQTT dup flag
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid)
|
|
||||||
{
|
|
||||||
return MQTTSerialize_ack(buf, buflen, PUBREL, dup, packetid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes a pubrel packet into the supplied buffer.
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @return serialized length, or error if 0
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid)
|
|
||||||
{
|
|
||||||
return MQTTSerialize_ack(buf, buflen, PUBCOMP, 0, packetid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,137 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 <string.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines the length of the MQTT subscribe packet that would be produced using the supplied parameters
|
|
||||||
* @param count the number of topic filter strings in topicFilters
|
|
||||||
* @param topicFilters the array of topic filter strings to be used in the publish
|
|
||||||
* @return the length of buffer needed to contain the serialized version of the packet
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int len = 2; /* packetid */
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
len += 2 + MQTTstrlen(topicFilters[i]) + 1; /* length + topic + req_qos */
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the supplied subscribe data into the supplied buffer, ready for sending
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied bufferr
|
|
||||||
* @param dup integer - the MQTT dup flag
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @param count - number of members in the topicFilters and reqQos arrays
|
|
||||||
* @param topicFilters - array of topic filter names
|
|
||||||
* @param requestedQoSs - array of requested QoS
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, int count,
|
|
||||||
MQTTString topicFilters[], int requestedQoSs[])
|
|
||||||
{
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rem_len = 0;
|
|
||||||
int rc = 0;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (MQTTPacket_len(rem_len = MQTTSerialize_subscribeLength(count, topicFilters)) > buflen)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = SUBSCRIBE;
|
|
||||||
header.bits.dup = dup;
|
|
||||||
header.bits.qos = 1;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
|
|
||||||
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
writeMQTTString(&ptr, topicFilters[i]);
|
|
||||||
writeChar(&ptr, requestedQoSs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into suback data
|
|
||||||
* @param packetid returned integer - the MQTT packet identifier
|
|
||||||
* @param maxcount - the maximum number of members allowed in the grantedQoSs array
|
|
||||||
* @param count returned integer - number of members in the grantedQoSs array
|
|
||||||
* @param grantedQoSs returned array of integers - the granted qualities of service
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success, 0 is failure
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
int mylen;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != SUBACK)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
if (enddata - curdata < 2)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
*packetid = readInt(&curdata);
|
|
||||||
|
|
||||||
*count = 0;
|
|
||||||
while (curdata < enddata)
|
|
||||||
{
|
|
||||||
if (*count > maxcount)
|
|
||||||
{
|
|
||||||
rc = -1;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
grantedQoSs[(*count)++] = readChar(&curdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,112 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into subscribe data
|
|
||||||
* @param dup integer returned - the MQTT dup flag
|
|
||||||
* @param packetid integer returned - the MQTT packet identifier
|
|
||||||
* @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
|
|
||||||
* @param count - number of members in the topicFilters and requestedQoSs arrays
|
|
||||||
* @param topicFilters - array of topic filter names
|
|
||||||
* @param requestedQoSs - array of requested QoS
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
|
|
||||||
int requestedQoSs[], unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = -1;
|
|
||||||
int mylen = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != SUBSCRIBE)
|
|
||||||
goto exit;
|
|
||||||
*dup = header.bits.dup;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
|
|
||||||
*packetid = readInt(&curdata);
|
|
||||||
|
|
||||||
*count = 0;
|
|
||||||
while (curdata < enddata)
|
|
||||||
{
|
|
||||||
if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
|
|
||||||
goto exit;
|
|
||||||
if (curdata >= enddata) /* do we have enough data to read the req_qos version byte? */
|
|
||||||
goto exit;
|
|
||||||
requestedQoSs[*count] = readChar(&curdata);
|
|
||||||
(*count)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the supplied suback data into the supplied buffer, ready for sending
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @param count - number of members in the grantedQoSs array
|
|
||||||
* @param grantedQoSs - array of granted QoS
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rc = -1;
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (buflen < 2 + count)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = SUBACK;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, 2 + count); /* write remaining length */
|
|
||||||
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
writeChar(&ptr, grantedQoSs[i]);
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,106 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 <string.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines the length of the MQTT unsubscribe packet that would be produced using the supplied parameters
|
|
||||||
* @param count the number of topic filter strings in topicFilters
|
|
||||||
* @param topicFilters the array of topic filter strings to be used in the publish
|
|
||||||
* @return the length of buffer needed to contain the serialized version of the packet
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int len = 2; /* packetid */
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
len += 2 + MQTTstrlen(topicFilters[i]); /* length + topic*/
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the supplied unsubscribe data into the supplied buffer, ready for sending
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @param dup integer - the MQTT dup flag
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @param count - number of members in the topicFilters array
|
|
||||||
* @param topicFilters - array of topic filter names
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
|
|
||||||
int count, MQTTString topicFilters[])
|
|
||||||
{
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rem_len = 0;
|
|
||||||
int rc = -1;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (MQTTPacket_len(rem_len = MQTTSerialize_unsubscribeLength(count, topicFilters)) > buflen)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = UNSUBSCRIBE;
|
|
||||||
header.bits.dup = dup;
|
|
||||||
header.bits.qos = 1;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
|
|
||||||
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
writeMQTTString(&ptr, topicFilters[i]);
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into unsuback data
|
|
||||||
* @param packetid returned integer - the MQTT packet identifier
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return error code. 1 is success, 0 is failure
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int buflen)
|
|
||||||
{
|
|
||||||
unsigned char type = 0;
|
|
||||||
unsigned char dup = 0;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
rc = MQTTDeserialize_ack(&type, &dup, packetid, buf, buflen);
|
|
||||||
if (type == UNSUBACK)
|
|
||||||
rc = 1;
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,102 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes the supplied (wire) buffer into unsubscribe data
|
|
||||||
* @param dup integer returned - the MQTT dup flag
|
|
||||||
* @param packetid integer returned - the MQTT packet identifier
|
|
||||||
* @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
|
|
||||||
* @param count - number of members in the topicFilters and requestedQoSs arrays
|
|
||||||
* @param topicFilters - array of topic filter names
|
|
||||||
* @param buf the raw buffer data, of the correct length determined by the remaining length field
|
|
||||||
* @param buflen the length in bytes of the data in the supplied buffer
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
|
|
||||||
unsigned char* buf, int len)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
unsigned char* curdata = buf;
|
|
||||||
unsigned char* enddata = NULL;
|
|
||||||
int rc = 0;
|
|
||||||
int mylen = 0;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
header.byte = readChar(&curdata);
|
|
||||||
if (header.bits.type != UNSUBSCRIBE)
|
|
||||||
goto exit;
|
|
||||||
*dup = header.bits.dup;
|
|
||||||
|
|
||||||
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
|
|
||||||
enddata = curdata + mylen;
|
|
||||||
|
|
||||||
*packetid = readInt(&curdata);
|
|
||||||
|
|
||||||
*count = 0;
|
|
||||||
while (curdata < enddata)
|
|
||||||
{
|
|
||||||
if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
|
|
||||||
goto exit;
|
|
||||||
(*count)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 1;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes the supplied unsuback data into the supplied buffer, ready for sending
|
|
||||||
* @param buf the buffer into which the packet will be serialized
|
|
||||||
* @param buflen the length in bytes of the supplied buffer
|
|
||||||
* @param packetid integer - the MQTT packet identifier
|
|
||||||
* @return the length of the serialized data. <= 0 indicates error
|
|
||||||
*/
|
|
||||||
int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid)
|
|
||||||
{
|
|
||||||
MQTTHeader header = {0};
|
|
||||||
int rc = 0;
|
|
||||||
unsigned char *ptr = buf;
|
|
||||||
|
|
||||||
FUNC_ENTRY;
|
|
||||||
if (buflen < 2)
|
|
||||||
{
|
|
||||||
rc = MQTTPACKET_BUFFER_TOO_SHORT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
header.byte = 0;
|
|
||||||
header.bits.type = UNSUBACK;
|
|
||||||
writeChar(&ptr, header.byte); /* write header */
|
|
||||||
|
|
||||||
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
|
|
||||||
|
|
||||||
writeInt(&ptr, packetid);
|
|
||||||
|
|
||||||
rc = ptr - buf;
|
|
||||||
exit:
|
|
||||||
FUNC_EXIT_RC(rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,42 +0,0 @@
|
|||||||
###################################################################
|
|
||||||
#automatic detection QTOP and LOCALDIR
|
|
||||||
CUR_DIR := $(realpath $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
|
|
||||||
TRYQTOP := $(shell if [ -n "$$QTOP" ] ; then\
|
|
||||||
echo $$QTOP;\
|
|
||||||
else\
|
|
||||||
cd $(CUR_DIR); while /usr/bin/test ! -d qmk ; do \
|
|
||||||
dir=`cd ../;pwd`; \
|
|
||||||
if [ "$$dir" = "/" ] ; then \
|
|
||||||
echo Cannot find QTOP in $(firstword $(MAKEFILE_LIST)) 1>&2; \
|
|
||||||
exit 1; \
|
|
||||||
fi ; \
|
|
||||||
cd $$dir; \
|
|
||||||
done ; \
|
|
||||||
pwd; \
|
|
||||||
fi)
|
|
||||||
QTOP ?= $(realpath ${TRYQTOP})
|
|
||||||
|
|
||||||
ifeq ($(QTOP),)
|
|
||||||
$(error Please run this in a tree)
|
|
||||||
endif
|
|
||||||
LOCALDIR = $(patsubst %/,%,$(subst $(realpath $(QTOP))/,,$(CUR_DIR)))
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
|
|
||||||
TREE_LIB_ENABLE=1
|
|
||||||
lib=
|
|
||||||
subdirs=
|
|
||||||
|
|
||||||
CFGFLAGS += -I$(CUR_DIR)/3rdparty/include
|
|
||||||
CFGFLAGS += -I$(CUR_DIR)/wrapper/include
|
|
||||||
CFGFLAGS += -I$(QTOP)/net/sal_module_wrapper
|
|
||||||
|
|
||||||
LSRCS_DIR += 3rdparty/src
|
|
||||||
LSRCS_DIR += wrapper/src
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include ${QTOP}/qmk/generic/Make.tpl
|
|
||||||
|
|
||||||
|
|
@@ -1,92 +0,0 @@
|
|||||||
#ifndef _MQTT_WRAPPER_H_
|
|
||||||
#define _MQTT_WRAPPER_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "MQTTPacket.h"
|
|
||||||
#include "transport_wrapper.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief connection option
|
|
||||||
*/
|
|
||||||
typedef struct mqtt_connect_option_st {
|
|
||||||
unsigned short keep_alive_interval; /**< keep alive */
|
|
||||||
unsigned char cleansession; /**< clean session flag */
|
|
||||||
char *client_id; /**< client id */
|
|
||||||
char *username; /**< username */
|
|
||||||
char *password; /**< password */
|
|
||||||
} mqtt_con_opt_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief publish/receive parameter for a certain subscirbed topic
|
|
||||||
*/
|
|
||||||
typedef struct mqtt_publish_option_st {
|
|
||||||
int qos; /**< quality of service */
|
|
||||||
unsigned char retained; /**< RETAIN flag */
|
|
||||||
unsigned char dup; /**< DUP flag */
|
|
||||||
unsigned short id; /**< message id */
|
|
||||||
|
|
||||||
char *topic; /**< mqtt topic */
|
|
||||||
|
|
||||||
unsigned char *payload; /**< mqtt payload */
|
|
||||||
int payload_len; /**< mqtt payload length */
|
|
||||||
} mqtt_pub_opt_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief subscribe parameter for a certain topic
|
|
||||||
*/
|
|
||||||
typedef struct mqtt_subscribe_option_st {
|
|
||||||
int req_qos; /**< request quality of service */
|
|
||||||
int count; /**< number of members in the topicFilters and reqQos arrays */
|
|
||||||
unsigned char dup; /**< DUP flag */
|
|
||||||
unsigned short id; /**< message id */
|
|
||||||
char *topic; /**< mqtt topic */
|
|
||||||
} mqtt_sub_opt_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Connect to mqtt server.
|
|
||||||
*
|
|
||||||
* @param[in] host mqtt server(domain name and ip address both are fine).
|
|
||||||
* @param[in] port mqtt port.
|
|
||||||
* @param[in] opt mqtt connect parameter.
|
|
||||||
*
|
|
||||||
* @return socket id or error if -1.
|
|
||||||
*/
|
|
||||||
int tos_mqtt_connect(char *host, const char *port, mqtt_con_opt_t *opt);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Publish a message.
|
|
||||||
*
|
|
||||||
* @param[in] sock socket id returned by a tos_mqtt_connect.
|
|
||||||
* @param[in] opt mqtt publish parameter.
|
|
||||||
*
|
|
||||||
* @return successful if 0, or error if -1.
|
|
||||||
*/
|
|
||||||
int tos_mqtt_publish(int sock, mqtt_pub_opt_t *opt);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Subscribe a topic.
|
|
||||||
*
|
|
||||||
* @param[in] sock socket id returned by a tos_mqtt_connect.
|
|
||||||
* @param[in] opt mqtt subscribe parameter.
|
|
||||||
*
|
|
||||||
* @return successful if 0, or error if -1.
|
|
||||||
*/
|
|
||||||
int tos_mqtt_subscribe(int sock, mqtt_sub_opt_t *opt);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Receive a message.
|
|
||||||
* message of any subscribed topic is received.
|
|
||||||
*
|
|
||||||
* @param[out] topic what topic do we receive.
|
|
||||||
* @param[in] topic_len length of the topic buffer.
|
|
||||||
* @param[out] payload what payload of the topic do we receive.
|
|
||||||
* @param[in] payload_len length of the topic payload.
|
|
||||||
*
|
|
||||||
* @return incoming payload length, or error if -1.
|
|
||||||
*/
|
|
||||||
int tos_mqtt_receive(char *topic, int topic_len, unsigned char *payload, int payload_len);
|
|
||||||
|
|
||||||
#endif /* _MQTT_WRAPPER_H_ */
|
|
||||||
|
|
@@ -1,32 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Sergio R. Caprile - "commonalization" from prior samples and/or documentation extension
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __TRANSPORT_WRAPPER_H__
|
|
||||||
#define __TRANSPORT_WRAPPER_H__
|
|
||||||
|
|
||||||
int transport_sendPacketBuffer(int sock, unsigned char *buf, int buflen);
|
|
||||||
|
|
||||||
int transport_getdata(unsigned char *buf, int count);
|
|
||||||
|
|
||||||
int transport_getdatanb(void *sck, unsigned char* buf, int count);
|
|
||||||
|
|
||||||
int transport_open(char *host, const char *port);
|
|
||||||
|
|
||||||
int transport_close(int sock);
|
|
||||||
|
|
||||||
#endif /* __TRANSPORT_WRAPPER_H__ */
|
|
||||||
|
|
@@ -1,156 +0,0 @@
|
|||||||
#include "mqtt_wrapper.h"
|
|
||||||
|
|
||||||
#define BUFFER_LEN 256
|
|
||||||
static unsigned char buffer[BUFFER_LEN];
|
|
||||||
|
|
||||||
static MQTTPacket_connectData mqtt_form_connect_packet(mqtt_con_opt_t *opt)
|
|
||||||
{
|
|
||||||
MQTTPacket_connectData connect_packet = MQTTPacket_connectData_initializer;
|
|
||||||
|
|
||||||
connect_packet.clientID.cstring = opt->client_id;
|
|
||||||
connect_packet.keepAliveInterval = opt->keep_alive_interval;
|
|
||||||
connect_packet.cleansession = opt->cleansession;
|
|
||||||
connect_packet.username.cstring = opt->username;
|
|
||||||
connect_packet.password.cstring = opt->password;
|
|
||||||
|
|
||||||
return connect_packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tos_mqtt_connect(char *host, const char *port, mqtt_con_opt_t *opt)
|
|
||||||
{
|
|
||||||
int sock = 0;
|
|
||||||
int serialize_len = 0;
|
|
||||||
unsigned char session_present, connack_rc;
|
|
||||||
MQTTPacket_connectData connect_packet;
|
|
||||||
|
|
||||||
sock = transport_open(host, port);
|
|
||||||
if (sock < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
connect_packet = mqtt_form_connect_packet(opt);
|
|
||||||
serialize_len = MQTTSerialize_connect(buffer, sizeof(buffer), &connect_packet);
|
|
||||||
if (serialize_len == 0) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transport_sendPacketBuffer(sock, buffer, serialize_len) < 0) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wait for connack */
|
|
||||||
if (MQTTPacket_read(buffer, sizeof(buffer), transport_getdata) != CONNACK) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MQTTDeserialize_connack(&session_present, &connack_rc, buffer, sizeof(buffer)) != 1) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connack_rc != 0) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sock;
|
|
||||||
|
|
||||||
errout:
|
|
||||||
transport_close(sock);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tos_mqtt_publish(int sock, mqtt_pub_opt_t*opt)
|
|
||||||
{
|
|
||||||
int serialize_len;
|
|
||||||
MQTTString pub_topic;
|
|
||||||
|
|
||||||
pub_topic.cstring = opt->topic;
|
|
||||||
pub_topic.lenstring.data = NULL;
|
|
||||||
pub_topic.lenstring.len = 0;
|
|
||||||
|
|
||||||
serialize_len = MQTTSerialize_publish(buffer, sizeof(buffer), opt->dup, opt->qos,
|
|
||||||
opt->retained, opt->id, pub_topic, opt->payload,
|
|
||||||
opt->payload_len);
|
|
||||||
if (serialize_len <= 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transport_sendPacketBuffer(sock, buffer, serialize_len) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (MQTTPacket_read(buffer, sizeof(buffer), transport_getdata) != PUBACK) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tos_mqtt_subscribe(int sock, mqtt_sub_opt_t *opt)
|
|
||||||
{
|
|
||||||
unsigned short packet_id;
|
|
||||||
int max_count, granted_qos;
|
|
||||||
int serialize_len;
|
|
||||||
MQTTString sub_topic;
|
|
||||||
|
|
||||||
sub_topic.cstring = opt->topic;
|
|
||||||
sub_topic.lenstring.data = NULL;
|
|
||||||
sub_topic.lenstring.len = 0;
|
|
||||||
|
|
||||||
serialize_len = MQTTSerialize_subscribe(buffer, sizeof(buffer), opt->dup, opt->id,
|
|
||||||
opt->count, &sub_topic, &opt->req_qos);
|
|
||||||
if (serialize_len <= 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transport_sendPacketBuffer(sock, buffer, serialize_len) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MQTTPacket_read(buffer, sizeof(buffer), transport_getdata) != SUBACK) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MQTTDeserialize_suback(&packet_id, 1, &max_count, &granted_qos, buffer, sizeof(buffer)) != 1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tos_mqtt_receive(char *topic, int topic_len, unsigned char *payload, int payload_len)
|
|
||||||
{
|
|
||||||
int topic_copy_len, qos;
|
|
||||||
unsigned char dup, retained;
|
|
||||||
unsigned short packet_id;
|
|
||||||
unsigned char *incoming_data;
|
|
||||||
int incoming_data_len, payload_copy_len;
|
|
||||||
MQTTString incoming_topic;
|
|
||||||
|
|
||||||
if (MQTTPacket_read(buffer, sizeof(buffer), transport_getdata) != PUBLISH) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MQTTDeserialize_publish(&dup, &qos, &retained, &packet_id,
|
|
||||||
&incoming_topic, &incoming_data, &incoming_data_len,
|
|
||||||
buffer, sizeof(buffer)) != 1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (payload) {
|
|
||||||
payload_copy_len = incoming_data_len < payload_len ? incoming_data_len : payload_len;
|
|
||||||
memcpy(payload, incoming_data, payload_copy_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topic) {
|
|
||||||
topic_copy_len = incoming_topic.lenstring.len < topic_len ? incoming_topic.lenstring.len : topic_len;
|
|
||||||
strncpy(topic, incoming_topic.lenstring.data, topic_copy_len);
|
|
||||||
if (topic_copy_len <= topic_len - 1) {
|
|
||||||
topic[topic_copy_len] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return incoming_data_len;
|
|
||||||
}
|
|
||||||
|
|
@@ -1,72 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Sergio R. Caprile - "commonalization" from prior samples and/or documentation extension
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "sal_module_wrapper.h"
|
|
||||||
#include "transport_wrapper.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
This simple low-level implementation assumes a single connection for a single thread. Thus, a static
|
|
||||||
variable is used for that connection.
|
|
||||||
On other scenarios, the user must solve this by taking into account that the current implementation of
|
|
||||||
MQTTPacket_read() has a function pointer for a function call to get the data to a buffer, but no provisions
|
|
||||||
to know the caller or other indicator (the socket id): int (*getfn)(unsigned char*, int)
|
|
||||||
*/
|
|
||||||
static int msock = -1;
|
|
||||||
|
|
||||||
int transport_sendPacketBuffer(int sock, unsigned char *buf, int buflen)
|
|
||||||
{
|
|
||||||
return tos_sal_module_send(sock, buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int transport_getdata(unsigned char *buf, int count)
|
|
||||||
{
|
|
||||||
return tos_sal_module_recv(msock, buf, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
int transport_getdatanb(void *sck, unsigned char *buf, int count)
|
|
||||||
{
|
|
||||||
/* sck: pointer to whatever the system may use to identify the transport */
|
|
||||||
int sock = *((int *)sck);
|
|
||||||
|
|
||||||
/* this call will return after the timeout set on initialization if no bytes;
|
|
||||||
in your system you will use whatever you use to get whichever outstanding
|
|
||||||
bytes your socket equivalent has ready to be extracted right now, if any,
|
|
||||||
or return immediately */
|
|
||||||
int rc = tos_sal_module_recv(sock, buf, count);
|
|
||||||
if (rc == -1) {
|
|
||||||
/* check error conditions from your system here, and return -1 */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
return >=0 for a socket descriptor, <0 for an error code
|
|
||||||
@todo Basically moved from the sample without changes, should accomodate same usage for 'sock' for clarity,
|
|
||||||
removing indirections
|
|
||||||
*/
|
|
||||||
int transport_open(char *addr, const char *port)
|
|
||||||
{
|
|
||||||
msock = tos_sal_module_connect(addr, port, TOS_SAL_PROTO_TCP);
|
|
||||||
return msock;
|
|
||||||
}
|
|
||||||
|
|
||||||
int transport_close(int sock)
|
|
||||||
{
|
|
||||||
return tos_sal_module_close(sock);
|
|
||||||
}
|
|
||||||
|
|
@@ -1,15 +0,0 @@
|
|||||||
#ifndef _TOS_MQTT_CONFIG_H_
|
|
||||||
#define _TOS_MQTT_CONFIG_H_
|
|
||||||
|
|
||||||
#define MQTT_SERVER_IP "111.230.189.156"
|
|
||||||
#define MQTT_SERVER_PORT "1883"
|
|
||||||
#define MQTT_PRODUCT_ID "RUAP1R610V"
|
|
||||||
#define MQTT_DEV_NAME "supowang"
|
|
||||||
#define MQTT_CLIENT_ID "RUAP1R610Vsupowang"
|
|
||||||
#define MQTT_USR_NAME "RUAP1R610Vsupowang;12010126;LQUY4;1620700055"
|
|
||||||
#define MQTT_PASSWORD "98398cb32f7cb9d73da51fea84bf400c7f17a3303548624731d76fa8db3b43ff;hmacsha256"
|
|
||||||
#define MQTT_SUBSCRIBE_TOPIC "RUAP1R610V/supowang/data"
|
|
||||||
#define MQTT_PUBLISH_TOPIC "RUAP1R610V/supowang/data"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,95 +0,0 @@
|
|||||||
#include "esp8266.h"
|
|
||||||
#include "mqtt_wrapper.h"
|
|
||||||
#include "mqtt_config.h"
|
|
||||||
|
|
||||||
#define USE_ESP8266
|
|
||||||
|
|
||||||
static hal_uart_port_t esp8266_port = HAL_UART_PORT_0;
|
|
||||||
|
|
||||||
void mqtt_set_esp8266_port(hal_uart_port_t port) {
|
|
||||||
esp8266_port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void mqtt_demo(void)
|
|
||||||
{
|
|
||||||
int count = 1;
|
|
||||||
int sock_id = 0;
|
|
||||||
uint8_t read_data[40];
|
|
||||||
int read_len;
|
|
||||||
char topic[30];
|
|
||||||
char buffer[32];
|
|
||||||
|
|
||||||
mqtt_con_opt_t con_opt;
|
|
||||||
con_opt.keep_alive_interval = 2000;
|
|
||||||
con_opt.cleansession = 1;
|
|
||||||
con_opt.username = MQTT_USR_NAME;
|
|
||||||
con_opt.password = MQTT_PASSWORD;
|
|
||||||
con_opt.client_id = MQTT_CLIENT_ID;
|
|
||||||
|
|
||||||
mqtt_pub_opt_t pub_opt;
|
|
||||||
pub_opt.dup = 0;
|
|
||||||
pub_opt.qos = 0;
|
|
||||||
pub_opt.retained = 0;
|
|
||||||
pub_opt.id = 0;
|
|
||||||
pub_opt.topic = MQTT_PUBLISH_TOPIC;
|
|
||||||
|
|
||||||
mqtt_sub_opt_t sub_opt;
|
|
||||||
sub_opt.count = 1;
|
|
||||||
sub_opt.dup = 0;
|
|
||||||
sub_opt.id = 1;
|
|
||||||
sub_opt.req_qos = 0;
|
|
||||||
sub_opt.topic = MQTT_SUBSCRIBE_TOPIC;
|
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
|
||||||
esp8266_sal_init(esp8266_port);
|
|
||||||
esp8266_join_ap("SheldonDai", "srnr6x9xbhmb0");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_NB_BC35
|
|
||||||
int bc35_28_95_sal_init(hal_uart_port_t uart_port);
|
|
||||||
bc35_28_95_sal_init(HAL_UART_PORT_0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sock_id = tos_mqtt_connect(MQTT_SERVER_IP, MQTT_SERVER_PORT, &con_opt);
|
|
||||||
|
|
||||||
printf("socket id: %d\r\n",sock_id);
|
|
||||||
|
|
||||||
if (tos_mqtt_subscribe(sock_id, &sub_opt) != 0) {
|
|
||||||
printf("subscribe failed!!!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "@%3.1f@%3.1f@%.1f", 25.8,80.6, 90.1);
|
|
||||||
|
|
||||||
printf("publish topic\r\n");
|
|
||||||
pub_opt.topic = MQTT_PUBLISH_TOPIC;
|
|
||||||
pub_opt.payload = (unsigned char *)buffer;
|
|
||||||
pub_opt.payload_len = sizeof(buffer);
|
|
||||||
if (tos_mqtt_publish(sock_id, &pub_opt) != 0) {
|
|
||||||
printf("publish failed!!!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("MQTT count: %d\r\n",count);
|
|
||||||
printf("read buf\r\n");
|
|
||||||
read_len = tos_mqtt_receive(topic, sizeof(topic), read_data, sizeof(read_data));
|
|
||||||
if (read_len >= 0) {
|
|
||||||
printf("---------->topic: %s, payload: %s, payload_len: %d\n", topic, read_data, read_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
|
||||||
tos_task_delay(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void application_entry(void *arg)
|
|
||||||
{
|
|
||||||
mqtt_demo();
|
|
||||||
while (1) {
|
|
||||||
printf("This is a mqtt demo!\r\n");
|
|
||||||
tos_task_delay(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user