日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

cc2530学习笔记

發(fā)布時(shí)間:2023/12/9 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cc2530学习笔记 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

case KEY_CHANGE://按鍵事件

case AF_INCOMING_MSG_CMD://接收數(shù)據(jù)事件,調(diào)用函數(shù)AF_DataRequest()接收數(shù)據(jù)

case ZDO_STATE_CHANGE:
//只要網(wǎng)絡(luò)狀態(tài)發(fā)生改變,就通過ZDO_STATE_CHANGE事件通知所有的任務(wù)。
//同時(shí)完成對協(xié)調(diào)器,路由器,終端的設(shè)置

SAMPLEAPP_SEND_PERIODIC_MSG_EVT, //周期性事件處理函數(shù)
SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT ); //每5s處理一次

?

case SAMPLEAPP_PERIODIC_CLUSTERID: //收到廣播數(shù)據(jù)
case SAMPLEAPP_FLASH_CLUSTERID: //收到組播數(shù)據(jù)


//接收數(shù)據(jù),參數(shù)為接收到的數(shù)據(jù)
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )

//分析發(fā)送周期信息
void SampleApp_SendPeriodicMessage( void )


/接收屬于本應(yīng)用任務(wù)SampleApp的消息,以SampleApp_TaskID標(biāo)記
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );

消息結(jié)構(gòu)體:
typedef struct
{
osal_event_hdr_t hdr; /* OSAL Message header */
uint16 groupId; /* Message's group ID - 0 if not set */
uint16 clusterId; /* Message's cluster ID */
afAddrType_t srcAddr; /* Source Address, if endpoint is STUBAPS_INTER_PAN_EP,
it's an InterPAN message */
uint16 macDestAddr; /* MAC header destination short address */
uint8 endPoint; /* destination endpoint */
uint8 wasBroadcast; /* TRUE if network destination was a broadcast address */
uint8 LinkQuality; /* The link quality of the received data frame */
uint8 correlation; /* The raw correlation value of the received data frame */
int8 rssi; /* The received RF power in units dBm */
uint8 SecurityUse; /* deprecated */
uint32 timestamp; /* receipt timestamp from MAC */
uint8 nwkSeqNum; /* network header frame sequence number */
afMSGCommandFormat_t cmd; /* Application Data */
} afIncomingMSGPacket_t;

typedef struct
{
uint8 TransSeqNumber;
uint16 DataLength; // Number of bytes in TransData
uint8 *Data;
} afMSGCommandFormat_t;


event+簇id+消息內(nèi)容+內(nèi)容大小
MSGpkt->hdr.event + MSGpkt->clusterId + MSGpkt->cmd.Data + MSGpkt->cmd.DataLength


uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )觸發(fā)接收或者發(fā)送

開始消息----》判斷事件AF_INCOMING_MSG_CMD----》處理函數(shù)----》SAMPLEAPP_PERIODIC_CLUSTERID簇ID

?

?

?

typedef enum
{
afAddrNotPresent = AddrNotPresent,
afAddr16Bit = Addr16Bit, //點(diǎn)播方式
afAddr64Bit = Addr64Bit,
afAddrGroup = AddrGroup, //組播方式
afAddrBroadcast = AddrBroadcast //廣播方式
} afAddrMode_t;

typedef struct
{
union
{
uint16 shortAddr; //短地址
ZLongAddr_t extAddr; //IEEE地址
} addr;
afAddrMode_t addrMode; //傳送模式
uint8 endPoint; //端點(diǎn)號
uint16 panId; // used for the INTER_PAN feature
} afAddrType_t;

afAddrType_t SampleApp_Periodic_DstAddr; //廣播
afAddrType_t SampleApp_Flash_DstAddr; //組播
afAddrType_t SampleApp_P2P_DstAddr; //點(diǎn)播


SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;//廣播
SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF; //廣播地址

// Setup for the flash command's destination address - Group 1
SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;//組播
SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;

SampleApp_P2P_DstAddr.addrMode = (afAddrMode_t)Addr16Bit; //點(diǎn)播
SampleApp_P2P_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_P2P_DstAddr.addr.shortAddr = 0x0000; //發(fā)給協(xié)調(diào)器 地址為0

轉(zhuǎn)載于:https://www.cnblogs.com/yihujiu/p/6020756.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的cc2530学习笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。