基于CC2530的SerialApp,實現的串口透傳之前有項目使用過,可以在這個例程上稍作修改,就可以滿足串口透傳基本的使用了。
延時大概是30ms左右。
受限于ZigBee本身的特性,不適合用于大數量的傳輸。
0.png (35.41 KB, 下載次數: 69)
下載附件
2018-12-5 19:06 上傳
全部資料51hei下載地址:
ZStack-2.5.1a.zip
(6.68 MB, 下載次數: 101)
2018-12-5 11:57 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
12.串口透傳之無線QQ.pdf
(804.18 KB, 下載次數: 52)
2018-12-5 11:57 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
Z-STACK之cc2530串口驅動詳解.pdf
(422.36 KB, 下載次數: 51)
2018-12-5 11:57 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
串口透明傳輸實驗分析.pdf
(194.4 KB, 下載次數: 51)
2018-12-5 11:57 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
Zigbee 協議棧學習之串口透明傳輸實驗(SerialApp)流程分析
第一個功能:協調器的組網,終端設備和路由設備發現網絡以及加入網絡
//第一步:Z-Stack 由 main()函數開始執行,main()函數共做了 2 件事:一是系統初始化,另外一件是開
始執行輪轉查詢式操作系統
int main( void )
{
.......
// Initialize the operating system
osal_init_system(); //第二步,操作系統初始化
......
osal_start_system(); //初始化完系統任務事件后,正式開始執行操作系統
......
}
//第二步,進入 osal_init_system()函數,執行操作系統初始化
uint8 osal_init_system( void ) //初始化操作系統,其中最重要的是,初始化操作系統的任務
{
// Initialize the Memory Allocation System
osal_mem_init();
// Initialize the message queue
osal_qHead = NULL;
// Initialize the timers
osalTimerInit();
// Initialize the Power Management System
osal_pwrmgr_init();
// Initialize the system tasks.
osalInitTasks(); //第三步,執行操作系統任務初始化函數
// Setup efficient search for the first free block of heap.
osal_mem_kick();
return ( SUCCESS );
}
//第三步,進入 osalInitTasks()函數,執行操作系統任務初始化
void osalInitTasks( void ) //第三步,初始化操作系統任務
{
uint8 taskID = 0;
tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
//任務優先級由高向低依次排列,高優先級對應 taskID 的值反而小
macTaskInit( taskID++ ); //不需要用戶考慮
nwk_init( taskID++ ); //不需要用戶考慮
Hal_Init( taskID++ ); //硬件抽象層初始化,需要我們考慮
#if defined( MT_TASK )
MT_TaskInit( taskID++ );
#endif
APS_Init( taskID++ ); //不需要用戶考慮
#if defined ( ZIGBEE_FRAGMENTATION )
APSF_Init( taskID++ );
#endif
ZDApp_Init( taskID++ ); //第四步,ZDApp 層,初始化 ,執行 ZDApp_init 函數后,如果是協調器將建立網絡,
如果是終端設備將加入網絡。
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
ZDNwkMgr_Init( taskID++ );
#endif
SerialApp_Init( taskID ); //應用層 SerialApp 層初始化,需要用戶考慮 在此處設置了一個按鍵觸發事件,
//當有按鍵按下的時候,產生一個系統消息
}
//第四步,進入 ZDApp_init()函數,執行 ZDApp 層初始化
//The first step
void ZDApp_Init( uint8 task_id ) //The first step,ZDApp 層初始化。
{
// Save the task ID
ZDAppTaskID = task_id;
// Initialize the ZDO global device short address storage
ZDAppNwkAddr.addrMode = Addr16Bit;
ZDAppNwkAddr.addr.shortAddr = INVALID_NODE_ADDR;
(void)NLME_GetExtAddr(); // Load the saveExtAddr pointer.
// Check for manual "Hold Auto Start"
ZDAppCheckForHoldKey();
// Initialize ZDO items and setup the device - type of device to create.
ZDO_Init();
// Register the endpoint description with the AF
// This task doesn't have a Simple description, but we still need
// to register the endpoint.
afRegister( (endPointDesc_t *)&ZDApp_epDesc );
#if defined( ZDO_USERDESC_RESPONSE )
ZDApp_InitUserDesc();
#endif // ZDO_USERDESC_RESPONSE
// Start the device?
if ( devState != DEV_HOLD ) //devState 初值為 DEV_INIT , 所以在初始化 ZDA 層時,就執行該條件
語句
{
ZDOInitDevice( 0 ); //The second step, 接著轉到 ZDOInitDevice()函數,執行 The third step;
}
else
{
// Blink LED to indicate HOLD_START
HalLedBlink ( HAL_LED_4, 0, 50, 500 );
}
ZDApp_RegisterCBs();
} /* ZDApp_Init() */
//The third step,執行 ZDOInitDevice()函數,執行設備初始化
uint8 ZDOInitDevice( uint16 startDelay ) //The third step, ZDO層初始化設備,
{
.......
// Trigger the network start
ZDApp_NetworkInit( extendedDelay ); //網絡初始化,跳到相應的函數里頭,執行 The fourth step
.......
}
//The fouth step,執行 ZDApp_NetWorkInit()函數
void ZDApp_NetworkInit( uint16 delay ) //The fourth step,網絡初始化
{
if ( delay )
{
// Wait awhile before starting the device
osal_start_timerEx( ZDAppTaskID, ZDO_NETWORK_INIT, delay ); //發 送 ZDO_NETWORK_INIT(網絡初始化)消息到 ZDApp 層,轉到 //ZDAp
p 層,執行 The fifth step , ZDApp_event_loop() 函數
}
else
{
osal_set_event( ZDAppTaskID, ZDO_NETWORK_INIT );
}
}
//The fifth step,轉到 ZDApp_event_loop()函數
UINT16 ZDApp_event_loop( uint8 task_id, UINT16 events )
{
if ( events & ZDO_NETWORK_INIT ) //The fivth step,網絡初始化事件處理
{
// Initialize apps and start the network
devState = DEV_INIT;
//設備邏輯類型,啟動模式,信標時間,超幀長度,接著轉到 The sixth step,去啟動設備,接著執行 The sixth
step,轉到 ZDO_StartDevice()
ZDO_StartDevice( (uint8)ZDO_Config_Node_Descriptor.LogicalType, devStartMode,
DEFAULT_BEACON_ORDER, DEFAULT_SUPERFRAME_ORDER );
…………
…………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
|