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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

cc2530学习笔记

發布時間:2023/12/9 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cc2530学习笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

case KEY_CHANGE://按鍵事件

case AF_INCOMING_MSG_CMD://接收數據事件,調用函數AF_DataRequest()接收數據

case ZDO_STATE_CHANGE:
//只要網絡狀態發生改變,就通過ZDO_STATE_CHANGE事件通知所有的任務。
//同時完成對協調器,路由器,終端的設置

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

?

case SAMPLEAPP_PERIODIC_CLUSTERID: //收到廣播數據
case SAMPLEAPP_FLASH_CLUSTERID: //收到組播數據


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

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


/接收屬于本應用任務SampleApp的消息,以SampleApp_TaskID標記
MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );

消息結構體:
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+消息內容+內容大小
MSGpkt->hdr.event + MSGpkt->clusterId + MSGpkt->cmd.Data + MSGpkt->cmd.DataLength


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

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

?

?

?

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

typedef struct
{
union
{
uint16 shortAddr; //短地址
ZLongAddr_t extAddr; //IEEE地址
} addr;
afAddrMode_t addrMode; //傳送模式
uint8 endPoint; //端點號
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; //點播


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; //點播
SampleApp_P2P_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_P2P_DstAddr.addr.shortAddr = 0x0000; //發給協調器 地址為0

轉載于:https://www.cnblogs.com/yihujiu/p/6020756.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。