資源簡介
從onenet例程修改過來的,使用STM32F407+ESP8266接入onenet平臺的最終修改代碼。

代碼片段和文件信息
/**
************************************************************
************************************************************
************************************************************
* 文件名:? dStream.c
*
* 作者:? 張繼瑞
*
* 日期:? 2017-09-11
*
* 版本:? V1.1
*
* 說明:? cJson格式數據流通用封裝
*
* 修改記錄: V1.1:修復當數據流flag全為0時封裝錯誤的bug。
************************************************************
************************************************************
************************************************************
**/
//協議封裝文件
#include?“dStream.h“
//C庫
#include?
#include?
//==========================================================
// 函數名稱: DSTREAM_toString
//
// 函數功能: 將數值轉為字符串
//
// 入口參數: StreamArray:數據流
// buf:轉換后的緩存
// pos:數據流中的哪個數據
// bufLen:緩存長度
//
// 返回參數: 無
//
// 說明:
//==========================================================
void?DSTREAM_toString(DATA_STREAM?*streamArray?char?*buf?unsigned?short?pos?unsigned?short?bufLen)
{
memset(buf?0?bufLen);
switch((unsigned?char)streamArray[pos].dataType)
{
case?TYPE_BOOL:
snprintf(buf?bufLen?“%d“?*(_Bool?*)streamArray[pos].dataPoint);
break;
case?TYPE_CHAR:
snprintf(buf?bufLen?“%d“?*(signed?char?*)streamArray[pos].dataPoint);
break;
case?TYPE_UCHAR:
snprintf(buf?bufLen?“%d“?*(unsigned?char?*)streamArray[pos].dataPoint);
break;
case?TYPE_SHORT:
snprintf(buf?bufLen?“%d“?*(signed?short?*)streamArray[pos].dataPoint);
break;
case?TYPE_USHORT:
snprintf(buf?bufLen?“%d“?*(unsigned?short?*)streamArray[pos].dataPoint);
break;
case?TYPE_INT:
snprintf(buf?bufLen?“%d“?*(signed?int?*)streamArray[pos].dataPoint);
break;
case?TYPE_UINT:
snprintf(buf?bufLen?“%d“?*(unsigned?int?*)streamArray[pos].dataPoint);
break;
case?TYPE_LONG:
snprintf(buf?bufLen?“%ld“?*(signed?long?*)streamArray[pos].dataPoint);
break;
case?TYPE_ULONG:
snprintf(buf?bufLen?“%ld“?*(unsigned?long?*)streamArray[pos].dataPoint);
break;
case?TYPE_FLOAT:
snprintf(buf?bufLen?“%f“?*(float?*)streamArray[pos].dataPoint);
break;
case?TYPE_DOUBLE:
snprintf(buf?bufLen?“%f“?*(double?*)streamArray[pos].dataPoint);
break;
case?TYPE_GPS:
snprintf(buf?bufLen?“{\“lon\“:%s\“lat\“:%s}“?(char?*)streamArray[pos].dataPoint?(char?*)(streamArray[pos].dataPoint)?+?16);
break;
case?TYPE_STRING:
snprintf(buf?bufLen?“\“%s\““?(char?*)streamArray[pos].dataPoint);
break;
}
}
//==========================================================
// 函數名稱: ?DSTREAM_GetDataStream_Body
//
// 函數功能: 獲取數據流格式消息體
//
// 入口參數: type:格式類型
// streamArray:數據流結構
// streamArrayCnt:數據流個數
// buffer:緩存
// maxLen:最大緩存長度
// offset:偏移
//
// 返回參數: Body的長度,0-失敗
//
// 說明:
//==========================================================
short?DSTREAM_GetDataStream_Body(uns
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-02-26?08:23??stm32f407_iot\
?????目錄???????????0??2018-02-26?12:31??stm32f407_iot\MDK\
?????目錄???????????0??2018-02-26?08:23??stm32f407_iot\MDK\DebugConfig\
?????文件????????2084??2015-10-27?12:06??stm32f407_iot\MDK\DebugConfig\Target_1_STM32F407ZGTx.dbgconf
?????文件????????2084??2015-10-27?12:06??stm32f407_iot\MDK\DebugConfig\stm32f4_project_STM32F407ZGTx.dbgconf
?????文件??????123683??2018-02-26?12:31??stm32f407_iot\MDK\Jli
?????文件?????????762??2018-02-26?09:06??stm32f407_iot\MDK\Jli
?????目錄???????????0??2018-02-26?08:23??stm32f407_iot\MDK\Listings\
?????文件???????77572??2018-02-26?08:24??stm32f407_iot\MDK\Listings\startup_stm32f40_41xxx.lst
?????文件??????203095??2018-02-26?12:31??stm32f407_iot\MDK\Listings\stm32f407_ex.map
?????目錄???????????0??2018-02-26?12:31??stm32f407_iot\MDK\ob
?????文件????????9817??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件?????????237??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件???????19248??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件???????15087??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件?????????276??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件???????37792??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件???????14474??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件?????????357??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件???????18276??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件??????460115??2018-02-26?12:31??stm32f407_iot\MDK\ob
?????文件????????2152??2018-02-26?12:31??stm32f407_iot\MDK\ob
?????文件??????492288??2018-02-26?12:31??stm32f407_iot\MDK\ob
?????文件??????443768??2018-02-26?08:23??stm32f407_iot\MDK\ob
?????文件????????1743??2018-02-26?08:23??stm32f407_iot\MDK\ob
?????文件??????482424??2018-02-26?08:23??stm32f407_iot\MDK\ob
?????文件??????459918??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件????????2292??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件??????521616??2018-02-26?08:24??stm32f407_iot\MDK\ob
?????文件??????449814??2018-02-26?09:03??stm32f407_iot\MDK\ob
?????文件????????1986??2018-02-26?09:03??stm32f407_iot\MDK\ob
............此處省略242個文件信息
評論
共有 條評論