⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coordinator.c

📁 JENNIC无线传感器网络 ZIGBEE 文件资料
💻 C
字号:
/**************************************************************************** * * MODULE:             Jenie Null Coordinator Node * COMPONENT:          $RCSfile: Coordinator.c,v $ * * VERSION: * * REVISION:           0.0 * * DATED:              2007/05/29 15:40:19 * * STATUS:             Exp * * AUTHOR:             MM * * DESCRIPTION: * * * LAST MODIFIED BY:   $Author: mroyc $ *                     $Modtime: $ * **************************************************************************** * * This software is owned by Jennic and/or its supplier and is protected * under applicable copyright laws. All rights are reserved. We grant You, * and any third parties, a license to use this software solely and * exclusively on Jennic products. You, and any third parties must reproduce * the copyright and warranty notice and any other legend of ownership on each * copy or partial copy of the software. * * THIS SOFTWARE IS PROVIDED "AS IS". JENNIC MAKES NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, * ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES, * BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. * * Copyright Jennic Ltd 2005, 2006. All rights reserved * ****************************************************************************//****************************************************************************//***        Include files                                                 ***//****************************************************************************/#include <jendefs.h>#include <gdb.h>#include <string.h>#include "jenie.h"#include "utils.h"#include "config.h"/****************************************************************************//***        Macro Definitions                                             ***//****************************************************************************//****************************************************************************//***        Type Definitions                                              ***//****************************************************************************/typedef enum{    APP_STATE_WAITING_FOR_NETWORK,    APP_STATE_NETWORK_UP,    APP_STATE_RUNNING} teAppState;typedef struct{    teAppState eAppState;} tsAppData;/****************************************************************************//***        Local Function Prototypes                                     ***//****************************************************************************//****************************************************************************//***        Exported Variables                                            ***//****************************************************************************//****************************************************************************//***        Local Variables                                               ***//****************************************************************************/PRIVATE tsAppData sAppData;/**************************************************************************** * * NAME: gJenie_CbNetworkApplicationID * * DESCRIPTION: * Entry point for application from boot loader. Initialises system. * * RETURNS: * Nothing * ****************************************************************************/PUBLIC void vJenie_CbConfigureNetwork(void){    /* Change default network config */    gJenie_Channel              = CHANNEL;    gJenie_NetworkApplicationID = SERVICE_PROFILE_ID;    gJenie_PanID                = PAN_ID;}PUBLIC void vJenie_CbInit(bool_t bWarmStart){    /* Initialise utilities */    vUtils_Init();    memset(&sAppData, 0, sizeof(sAppData));    vUtils_Debug("Jenie Init Coordinator");    if(eJenie_Start(E_JENIE_COORDINATOR) != E_JENIE_SUCCESS)    {        vUtils_Debug("!!Failed to start Jenie!!");        while(1);    }}/**************************************************************************** * * NAME: gJenie_CbMain * * DESCRIPTION: * Main user routine. This is called by the Basic Operating System (BOS) * at regular intervals. * * RETURNS: * void * ****************************************************************************/PUBLIC void vJenie_CbMain(void){    switch(sAppData.eAppState)    {    case APP_STATE_WAITING_FOR_NETWORK:        /* nothing to do till network is up and running */        break;    case APP_STATE_NETWORK_UP:        /* as we are a coorinator, allow nodes to associate with us */        vUtils_Debug("enabling association");        eJenie_SetPermitJoin(TRUE);        /* go to the running state */        sAppData.eAppState = APP_STATE_RUNNING;         break;    case APP_STATE_RUNNING:        /* do all necessary processing here */        break;    default:        vUtils_DisplayMsg("!!Unknown state!!", sAppData.eAppState);        while(1);    }}    /**************************************************************************** * * NAME: vJenie_CbStackMgmtEvent * * DESCRIPTION: * Used to receive stack management events * * PARAMETERS:      Name            		RW  Usage *					*psStackMgmtEvent		R	Pointer to event structure * * RETURNS: * void * ****************************************************************************/PUBLIC void vJenie_CbStackMgmtEvent(teEventType eEventType, void *pvEventPrim){    switch(eEventType)    {    case E_JENIE_NETWORK_UP:                    /* Indicates stack is up and running */        vUtils_Debug("network up");        if(sAppData.eAppState == APP_STATE_WAITING_FOR_NETWORK)        {            sAppData.eAppState = APP_STATE_NETWORK_UP;        }        break;    case E_JENIE_REG_SVC_RSP:        vUtils_Debug("Reg service response");        break;    case E_JENIE_SVC_REQ_RSP:        vUtils_Debug("Service req response");        break;    case E_JENIE_POLL_CMPLT:        break;    case E_JENIE_PACKET_SENT:        vUtils_Debug("Packet sent");        break;    case E_JENIE_PACKET_FAILED:        vUtils_Debug("Packet failed");        break;    case E_JENIE_CHILD_JOINED:        vUtils_Debug("Child Joined");        break;    default:        /* Unknown data event type */        break;   }}/**************************************************************************** * * NAME: vJenie_CbStackDataEvent * * DESCRIPTION: * Used to receive stack data events * * PARAMETERS:      Name            		RW  Usage *					*psStackDataEvent		R	Pointer to data structure * RETURNS: * void * ****************************************************************************/PUBLIC void vJenie_CbStackDataEvent(teEventType eEventType, void *pvEventPrim){    switch(eEventType)    {    case E_JENIE_DATA:        vUtils_Debug("Data event");        break;    case E_JENIE_DATA_TO_SERVICE:        vUtils_Debug("Data to service event");        break;    case E_JENIE_DATA_ACK:        vUtils_Debug("Data ack");        break;    case E_JENIE_DATA_TO_SERVICE_ACK:        vUtils_Debug("Data to service ack");        break;    default:        // Unknown data event type        break;    }}/**************************************************************************** * * NAME: vJenie_CbHwEvent * * DESCRIPTION: * Adds events to the hardware event queue. * * PARAMETERS:      Name            RW  Usage *                  u32Device       R   Peripheral responsible for interrupt e.g DIO *					u32ItemBitmap	R   Source of interrupt e.g. DIO bit map * * RETURNS: * void * ****************************************************************************/PUBLIC void vJenie_CbHwEvent(uint32 u32DeviceId,uint32 u32ItemBitmap){    /* Not used in this application */}/****************************************************************************//***        END OF FILE                                                   ***//****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -