色yeye在线视频观看_亚洲人亚洲精品成人网站_一级毛片免费播放_91精品一区二区中文字幕_一区二区三区日本视频_成人性生交大免费看

當(dāng)前位置: > 華清遠(yuǎn)見教育科技集團(tuán) > 嵌入式學(xué)習(xí) > 講師博文 > BitCloud協(xié)議解析之——網(wǎng)絡(luò)
BitCloud協(xié)議解析之——網(wǎng)絡(luò)
時(shí)間:2016-12-12作者:華清遠(yuǎn)見

1.1 網(wǎng)絡(luò)建立與加入

(1)首先在Main函數(shù)中,會(huì)有這樣的語句:

for(;;)
        {
                SYS_RunTask();
        }

通過SYS_RunTask函數(shù),系統(tǒng)會(huì)調(diào)用BitCloud協(xié)議棧中的用戶應(yīng)用程序,即APL_TaskHandler()。

(2)
        void APL_TaskHandler(void)
        {
                if (appStatePosted)
                {
                        appStatePosted = false;
                        appTaskHandler();
                }
                if (appSubStatePosted)
                {
                        appSubStatePosted = false;
                        appSubtaskHandler();
                }
        }

(3)按照流程程序調(diào)用appTaskHandler();該函數(shù)中對(duì)各種狀態(tài)進(jìn)行判斷執(zhí)行相應(yīng)操作。

static void appTaskHandler(void)
        {
                switch (appState)
                        {
                                case APP_INITIAL_STATE:
                                initHardware();
                                initNetwork();
                                break;
                                case APP_JOINING_STATE:
                                startNetwork();
                                break;
                                case APP_JOINED_STATE:
                                break;
                                case APP_LEAVE_STATE:
                                leaveNetwork();
                                break;
                        }
        }

(3.9)硬件初始化函數(shù)

static void initHardware(void)
        {
                #ifdef BOARD_SAM3S_PIRRD
                // Register interrupts
                HAL_InstallInterruptVector(SysTick_IRQn, SysTick_Handler);
                // Configure LEDS
                LED_Configure(APP_LED_0);
                // Configure SRAM
                BOARD_ConfigureSram();
                // Configure system tick timer
                TimeTick_Configure(BOARD_MCK);
                // Configure LCD
                appLCD_Init();
                #else
                // Configure LEDS
                BSP_OpenLeds();
                // Configure communication medium
                appMediumInit();
                #endif // BOARD_SAM3S_PIRRD
        }

(4)網(wǎng)絡(luò)初始化

static void initNetwork(void)
        {
                CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);//將設(shè)備在網(wǎng)絡(luò)中的角色配置為終端設(shè)備。
                if (DEV_TYPE_ENDDEVICE == deviceType)
                        {
                                bool rxOnWhenIdleFlag = false;
                                CS_WriteParameter(CS_RX_ON_WHEN_IDLE_ID, &rxOnWhenIdleFlag);
                        }
        }

// 命令請(qǐng)求參數(shù)的配置

apsCommandReq.dstAddrMode = APS_SHORT_ADDRESS;
        apsCommandReq.dstAddress.shortAddress = 0;
        apsCommandReq.profileId = APP_PROFILE_ID;
        apsCommandReq.dstEndpoint = APP_CONTROL_ENDPOINT;
        apsCommandReq.clusterId = APP_CLUSTER_ID;
        apsCommandReq.srcEndpoint = APP_CONTROL_ENDPOINT;
        apsCommandReq.asdu = (uint8_t *)&appCommandFrame.command;
        apsCommandReq.asduLength = 0;
        apsCommandReq.txOptions.acknowledgedTransmission = 1;
        apsCommandReq.radius = 0;
        apsCommandReq.APS_DataConf = apsCommandReqConf;

// 數(shù)據(jù)塊請(qǐng)求的配置


                  

然后調(diào)用startNerwork()啟動(dòng)搜尋網(wǎng)絡(luò)。

static void startNetwork(void)
        {
                blinkTimer.interval = BLINK_TIMER_INTERVAL;
                blinkTimer.mode = TIMER_REPEAT_MODE;
                blinkTimer.callback = blinkTimerFired;
                HAL_StartAppTimer(&blinkTimer);
                startNetworkReq.ZDO_StartNetworkConf = ZDO_StartNetworkConf;
                ZDO_StartNetworkReq(&startNetworkReq);
        }

定時(shí)器由static HAL_AppTimer_t blinkTimer;進(jìn)行聲明,當(dāng)時(shí)間到達(dá)時(shí),blinkTimerFired函數(shù)中對(duì)LED燈的狀態(tài)進(jìn)行改變。這樣就達(dá)到在搜尋網(wǎng)絡(luò)的過程中LED燈閃爍的效果,直到網(wǎng)絡(luò)加入成功。

下層關(guān)于加入網(wǎng)絡(luò)的回應(yīng)通過ZDO_StartNetworkConf回調(diào)函數(shù)完成。

static void ZDO_StartNetworkConf(ZDO_StartNetworkConf_t* conf)
        {
                HAL_StopAppTimer(&blinkTimer); //首先關(guān)掉定時(shí)器
                if (ZDO_SUCCESS_STATUS == conf->status)//如果加入網(wǎng)絡(luò)成功
                        {
                                restartStateMachines(APP_JOINED_STATE);//設(shè)置網(wǎng)絡(luò)狀態(tài)為已加入
                                LED_Clear(APP_LED_0); //關(guān)閉LED網(wǎng)絡(luò)指示燈
  &nbsnbsp;                             //注冊(cè)終端節(jié)點(diǎn)
                                registerControlEndpointReq.simpleDescriptor = &controlEndpoint;
                                registerControlEndpointReq.APS_DataInd = APS_DataIndControl;
                                APS_RegisterEndpointReq(®isterControlEndpointReq);
                                registerDataEndpointReq.simpleDescriptor = &dataEndpoint;
                                registerDataEndpointReq.APS_DataInd = APS_DataIndData;
                                APS_RegisterEndpointReq(®isterDataEndpointReq);
                                HAL_StartAppTimer(&nwkInfoTimer);
                        }
                else
                setState(APP_JOINING_STATE);
        }

2.2 數(shù)據(jù)傳輸中網(wǎng)絡(luò)體現(xiàn)

2.2.1 網(wǎng)絡(luò)角色的設(shè)置

在所有ZigBee網(wǎng)絡(luò)中,共有三種網(wǎng)絡(luò)角色:協(xié)調(diào)器、路由設(shè)備、終端設(shè)備。

要想讓節(jié)點(diǎn)能夠加入到ZigBee網(wǎng)絡(luò)之中,在初始化網(wǎng)絡(luò)的時(shí)候需要給節(jié)點(diǎn)分配網(wǎng)絡(luò)角色。例如:

static void initNetwork(void)
        {
                DeviceType_t deviceType = DEVICE_TYPE_COORDINATOR;//設(shè)置為協(xié)調(diào)器
                // DeviceType_t deviceType = APP_SENDER_DEVICE_TYPE ;
                CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);
                ...
        }

需要注意的是,在整個(gè)ZigBee網(wǎng)絡(luò)之中,有且只能有一個(gè)協(xié)調(diào)器用于創(chuàng)建一個(gè)ZigBee網(wǎng)絡(luò)。然后通過CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);將參數(shù)寫入文件。

2.2.2 網(wǎng)絡(luò)參數(shù)的使用

在進(jìn)行數(shù)據(jù)發(fā)送之前,首先要弄清楚的是被發(fā)送數(shù)據(jù)的目的網(wǎng)絡(luò)地址。在程序中通過 apsCommandReq.dstAddress.shortAddress = imageReceiving.currentRequest->address;進(jìn)行設(shè)置。然后通信雙方通過相同的endpoint進(jìn)行操作。

發(fā)表評(píng)論
評(píng)論列表(網(wǎng)友評(píng)論僅供網(wǎng)友表達(dá)個(gè)人看法,并不表明本站同意其觀點(diǎn)或證實(shí)其描述)
主站蜘蛛池模板: 国产成人啪精品视频网站午夜 | 成人午夜精品久久久久久久网站 | 亚洲av日韩av天堂影片精品一 | 97久久精品人人做人人爽 | 人妻熟妇乱又伦精品HD | 精品欧美А∨无码黑人大战少妇 | 美女18禁一区二区三区视频 | 久久AV喷潮久久AV高清 | 亚洲色自偷自拍另类小说 | 亚洲国产欧美中文手机在线 | 婷婷五月六月激情综合色中文字幕 | 羞羞影院午夜男女爽爽影视 | 精品无人区麻豆乱码1区2区 | 亚洲AV成人无码人在线观看堂 | 国产乱对白精彩 | 麻豆动漫 | 最好看的中文在线观看 | 波多野结衣一区二区三区中文字幕 | 成人无码黄动漫在线播放 | 麻豆视频传媒入口 | 国模无码视频一区二区三区 | 久久无码AV中文出轨人妻 | 欧美成人26uuu欧美毛片 | 荫蒂添的好舒服a片 | 老司机免费福利在线观看 | 国产成AV人片在线观看天堂无码 | 午夜大胆裸体A级人体片 | 性色黄 | 无码乱人伦一区二区亚洲一 | 中文日韩亚洲欧美制服 | 人人爽久久涩噜噜噜丁香 | 欧美Z0ZO人禽交欧美人禽交 | 精品中文字幕在线播放 | 亚洲欧美国产精品专区久久 | 精品一区二区三区影院在线午夜 | 国产成人AV在线影院 | 中国国产精品视频 | 国产激情视频在线播放 | 日本大片免A费观看视频三区 | 欲妇荡岳丰满少妇岳 | 大地资源在线观看中文第二页 |