Ejemplo n.º 1
0
/*********************************************************************
 * @fn          OTA_Dongle_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void OTA_Dongle_Init( byte task_id )
{
    OTA_Dongle_TaskID = task_id;
    uint8 RxOnIdle = TRUE;

    OTA_Dongle_SeqNo = 0;

    ZMacSetReq( ZMacRxOnIdle, &RxOnIdle );

    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( OTA_DONGLE_ENDPOINT, &OTA_Dongle_CmdCallbacks );

    // Register the application's attribute list
    zcl_registerAttrList( OTA_DONGLE_ENDPOINT, OTA_DONGLE_MAX_ATTRIBUTES, OTA_Dongle_Attrs );

    // Register the application's cluster option list
    zcl_registerClusterOptionList( OTA_DONGLE_ENDPOINT, OTA_DONGLE_MAX_OPTIONS, OTA_Dongle_Options );

    // Register the Application to receive the unprocessed Foundation command/response messages
    zcl_registerForMsg( OTA_Dongle_TaskID );

    // Register for all key events - This app will handle all key events
    RegisterForKeys( OTA_Dongle_TaskID );

    // Register endpoints
    afRegister( &ota_DongleEp );
    afRegister( &ota_SysAppEp );

    // Register with the ZDO to receive Match Descriptor Responses
    ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
    ZDO_RegisterForZDOMsg(task_id, Device_annce);

    // Start a timer to notify the console about the dongle
    osal_start_timerEx( OTA_Dongle_TaskID, OTA_DONGLE_DONGLE_NOTIFY_EVT, 4000 );
}
Ejemplo n.º 2
0
/*********************************************************************
 * @fn          zclHomelink_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void zclHomelink_Init( byte task_id )
{
  zclHomelink_UARTInit();

  zclHomelink_TaskID = task_id;

  // Set destination address to indirect for bindings
  zclHomelink_BindDstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  zclHomelink_BindDstAddr.endPoint = 0;
  zclHomelink_BindDstAddr.addr.shortAddr = 0;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclHomelink_SimpleDesc[0] );
  zclHA_Init( &zclHomelink_SimpleDesc[1] );
  zclHA_Init( &zclHomelink_SimpleDesc[2] );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( ENDPOINT, &zclHomelink_CmdCallbacks );
  zclGeneral_RegisterCmdCallbacks( ENDPOINT+1, &zclHomelink_CmdCallbacks );
  zclGeneral_RegisterCmdCallbacks( ENDPOINT+2, &zclHomelink_CmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( ENDPOINT, SAMPLESW_MAX_ATTRIBUTES, zclHomelink_Attrs );
  zcl_registerAttrList( ENDPOINT+1, SAMPLESW_MAX_ATTRIBUTES, zclHomelink_Attrs );
  zcl_registerAttrList( ENDPOINT+2, SAMPLESW_MAX_ATTRIBUTES, zclHomelink_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclHomelink_TaskID );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclHomelink_TaskID );

  ZDO_RegisterForZDOMsg( zclHomelink_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( zclHomelink_TaskID, Match_Desc_rsp );
}
Ejemplo n.º 3
0
/*********************************************************************
 * @fn          zclSampleSw_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void zclSampleSw_Init( byte task_id )
{
  osal_nv_write(ZCD_NV_EXTADDR, 0, Z_EXTADDR_LEN, ieeeAddr);
  zclSampleSw_TaskID = task_id;

  // Set destination address to indirect
  zclSampleSw_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  zclSampleSw_DstAddr.endPoint = 0;
  zclSampleSw_DstAddr.addr.shortAddr = 0;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclSampleSw_SimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT, &zclSampleSw_CmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( SAMPLESW_ENDPOINT, SAMPLESW_MAX_ATTRIBUTES, zclSampleSw_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclSampleSw_TaskID );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclSampleSw_TaskID );

  // Register for a test endpoint
  afRegister( &sampleSw_TestEp );

  ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, Match_Desc_rsp );
}
Ejemplo n.º 4
0
/*********************************************************************
 * @fn      GenericApp_Init
 *
 * @brief   Initialization function for the Generic App Task.
 *          This is called during initialization and should contain
 *          any application specific initialization (ie. hardware
 *          initialization/setup, table initialization, power up
 *          notificaiton ... ).
 *
 * @param   task_id - the ID assigned by OSAL.  This ID should be
 *                    used to send messages and set timers.
 *
 * @return  none
 */
void GenericApp_Init( byte task_id )
{
  GenericApp_TaskID = task_id;
  GenericApp_NwkState = DEV_INIT;
  GenericApp_TransID = 0;

  // Device hardware initialization can be added here or in main() (Zmain.c).
  // If the hardware is application specific - add it here.
  // If the hardware is other parts of the device add it in main().

  GenericApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent; //¶Ç°e¼Ò¦¡-AddrNotPresent=0; AddrBroadcast=15(¼s¼½)
  GenericApp_DstAddr.endPoint = 0;
  GenericApp_DstAddr.addr.shortAddr = 0;

  // Fill out the endpoint description.
  GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
  GenericApp_epDesc.task_id = &GenericApp_TaskID;
  GenericApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
  GenericApp_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &GenericApp_epDesc );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( GenericApp_TaskID );

  // Update the display
#if defined ( LCD_SUPPORTED )
    HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
#endif
    
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, Match_Desc_rsp );
}
Ejemplo n.º 5
0
/*********************************************************************
 * @fn          zclSampleSw_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void zclSampleSw_Init( byte task_id )
{
  zclSampleSw_TaskID = task_id;

#ifdef ZCL_ON_OFF
  // Set destination address to indirect
  zclSampleSw_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  zclSampleSw_DstAddr.endPoint = 0;
  zclSampleSw_DstAddr.addr.shortAddr = 0;
#endif

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclSampleSw_SimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT, &zclSampleSw_CmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( SAMPLESW_ENDPOINT, SAMPLESW_MAX_ATTRIBUTES, zclSampleSw_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclSampleSw_TaskID );

#ifdef ZCL_EZMODE
  // Register EZ-Mode
  zcl_RegisterEZMode( &zclSampleSw_RegisterEZModeData );

  // Register with the ZDO to receive Match Descriptor Responses
  ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
#endif

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclSampleSw_TaskID );

  // Register for a test endpoint
  afRegister( &sampleSw_TestEp );

  ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( zclSampleSw_TaskID, Match_Desc_rsp );

#ifdef LCD_SUPPORTED
  HalLcdWriteString ( (char *)sDeviceName, HAL_LCD_LINE_3 );
#endif

#if defined (OTA_CLIENT) && (OTA_CLIENT == TRUE)
  // Register for callback events from the ZCL OTA
  zclOTA_Register(zclSampleSw_TaskID);
#endif

}
Ejemplo n.º 6
0
/*********************************************************************
 * @fn      SerialApp_Init
 *
 * @brief   This is called during OSAL tasks' initialization.
 *
 * @param   task_id - the Task ID assigned by OSAL.
 *
 * @return  none
 */
void SerialApp_Init( uint8 task_id )
{
  halUARTCfg_t uartConfig;

  SerialApp_MsgID = 0x00;
  SerialApp_SeqRx = 0xC3;
  SerialApp_TaskID = task_id;

  SerialApp_DstAddr.endPoint = 0;
  SerialApp_DstAddr.addr.shortAddr = 0;
  SerialApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;

  SerialApp_RspDstAddr.endPoint = 0;
  SerialApp_RspDstAddr.addr.shortAddr = 0;
  SerialApp_RspDstAddr.addrMode = (afAddrMode_t)AddrNotPresent;

  afRegister( (endPointDesc_t *)&SerialApp_epDesc );

  RegisterForKeys( task_id );

  uartConfig.configured           = TRUE;              // 2430 don't care.
  uartConfig.baudRate             = SERIAL_APP_BAUD;
  uartConfig.flowControl          = TRUE;
  uartConfig.flowControlThreshold = SERIAL_APP_THRESH;
  uartConfig.rx.maxBufSize        = SERIAL_APP_RX_MAX;
  uartConfig.tx.maxBufSize        = SERIAL_APP_TX_MAX;
  uartConfig.idleTimeout          = SERIAL_APP_IDLE;   // 2430 don't care.
  uartConfig.intEnable            = TRUE;              // 2430 don't care.
#if SERIAL_APP_LOOPBACK
  uartConfig.callBackFunc         = rxCB_Loopback;
#else
  uartConfig.callBackFunc         = rxCB;
#endif
  HalUARTOpen (SERIAL_APP_PORT, &uartConfig);
  
#if defined ( LCD_SUPPORTED )
  HalLcdWriteString( "SerialApp2", HAL_LCD_LINE_2 );
#endif

  
  HalLedSet(HAL_LED_1,HAL_LED_MODE_OFF);
  HalLedSet(HAL_LED_2,HAL_LED_MODE_OFF);
  HalLedSet(HAL_LED_3,HAL_LED_MODE_OFF);
  
  ZDO_RegisterForZDOMsg( SerialApp_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( SerialApp_TaskID, Match_Desc_rsp );
  osal_start_timerEx(SerialApp_TaskID,SERIALAPP_MSG_AUTOMATCH,2000);
}
Ejemplo n.º 7
0
/*********************************************************************
 * @fn          rangeext_Init
 *
 * @brief       Initialization function for the ZCL App Application.
 *
 * @param       uint8 task_id - range extender task id
 *
 * @return      none
 */
void rangeext_Init( uint8 task_id )
{
  rangeExtTaskID = task_id;

  // setup ESP destination address
  ESPAddr.addrMode = (afAddrMode_t)Addr16Bit;
  ESPAddr.endPoint = RANGEEXT_ENDPOINT;
  ESPAddr.addr.shortAddr = 0;

  // register SE endpoint
  zclSE_Init( &rangeExtSimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( RANGEEXT_ENDPOINT, &rangeext_GenCmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( RANGEEXT_ENDPOINT, RANGEEXT_MAX_ATTRIBUTES, rangeExtAttrs );

  // Register the application's cluster option list
  zcl_registerClusterOptionList( RANGEEXT_ENDPOINT, RANGEEXT_MAX_OPTIONS, rangeExtOptions );

  // Register the application's attribute data validation callback function
  zcl_registerValidateAttrData( rangeext_ValidateAttrDataCB );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( rangeExtTaskID );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( rangeExtTaskID );

  // Register with the ZDO to receive Match Descriptor Responses
  ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
}
Ejemplo n.º 8
0
/*********************************************************************
 * @fn      GenericApp_Init
 *
 * @brief   Initialization function for the Generic App Task.
 *          This is called during initialization and should contain
 *          any application specific initialization (ie. hardware
 *          initialization/setup, table initialization, power up
 *          notificaiton ... ).
 *
 * @param   task_id - the ID assigned by OSAL.  This ID should be
 *                    used to send messages and set timers.
 *
 * @return  none
 */
void GenericApp_Init( byte task_id )
{
  GenericApp_TaskID = task_id;
  GenericApp_NwkState = DEV_INIT;
  GenericApp_TransID = 0;

  // Device hardware initialization can be added here or in main() (Zmain.c).
  // If the hardware is application specific - add it here.
  // If the hardware is other parts of the device add it in main().

  GenericApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  GenericApp_DstAddr.endPoint = 0;
  GenericApp_DstAddr.addr.shortAddr = 0;

  // Fill out the endpoint description.
  GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
  GenericApp_epDesc.task_id = &GenericApp_TaskID;
  GenericApp_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
  GenericApp_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &GenericApp_epDesc );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( GenericApp_TaskID );

  // Update the display
#if defined ( LCD_SUPPORTED )
    HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
#endif
    
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, Match_Desc_rsp );
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, SPI_INCOMING_ZAPP_DATA );

  /*****for SHP *************begin******************/{
  //extern void shp_example_init_called_by_system(void);
  //shp_example_init_called_by_system();
  /*****for SHP *************end********************/}

  //QBing
  MT_UartRegisterTaskID(GenericApp_TaskID);
  MT_UartZAppBufferLengthRegister(100);
  osal_start_timerEx(GenericApp_TaskID,GENERICAPP_TIMER_EVT,1000);
}
Ejemplo n.º 9
0
/*********************************************************************
 * @fn          zllSampleBridge_Init
 *
 * @brief       Initialization function for the Sample Bridge App task.
 *
 * @param       task_id
 *
 * @return      none
 */
void zllSampleBridge_Init( byte task_id )
{
  zllSampleBridge_TaskID = task_id;

  // Set destination address to indirect
  zllSampleBridge_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  zllSampleBridge_DstAddr.endPoint = 0;
  zllSampleBridge_DstAddr.addr.shortAddr = 0;

  // init linked list in NV
  zllSampleBridge_InitLinkedTargets();

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( SAMPLEBRIDGE_ENDPOINT, &zllSampleBridge_GenCmdCBs );

  // Register for ZCL Light Link Cluster Library callback functions
  zclLL_RegisterCmdCallbacks( SAMPLEBRIDGE_ENDPOINT, &zllSampleBridge_LLCmdCBs );

  // Register the application's attribute list
  zcl_registerAttrList( SAMPLEBRIDGE_ENDPOINT, SAMPLEBRIDGE_MAX_ATTRIBUTES, zllSampleBridge_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zllInitiator_RegisterForMsg( zllSampleBridge_TaskID );

  // Register the application for ZDO messages for device discovery
  ZDO_RegisterForZDOMsg( zllSampleBridge_TaskID, Device_annce );
  ZDO_RegisterForZDOMsg( zllSampleBridge_TaskID, Active_EP_rsp );
  ZDO_RegisterForZDOMsg( zllSampleBridge_TaskID, Simple_Desc_rsp );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zllSampleBridge_TaskID );

  zllInitiator_RegisterApp( &zllSampleBridge_SimpleDesc, &zllSampleBridge_DeviceInfo );

  zllInitiator_RegisterIdentifyCB( zllSampleBridge_IdentifyCB );

  zllInitiator_RegisterNotifyTLCB( zllSampleBridge_ProcessTL );

  zllInitiator_RegisterResetAppCB ( zllSampleBridge_BasicResetCB );

  zllInitiator_InitDevice();

}
/*********************************************************************
 * @fn      SAPI_Init
 *
 * @brief   Initialization function for the Simple API Task.
 *          This is called during initialization and should contain
 *          any application specific initialization (ie. hardware
 *          initialization/setup, table initialization, power up
 *          notification ... ).
 *
 * @param   task_id - the ID assigned by OSAL.  This ID should be
 *                    used to send messages and set timers.
 *
 * @return  none
 */
void SAPI_Init( byte task_id )
{
  sapi_TaskID = task_id;
  sapi_bindInProgress = 0xffff;

  sapi_epDesc.task_id = &sapi_TaskID;
  sapi_epDesc.endPoint = 0;
  
#if ( SAPI_CB_FUNC )
  sapi_epDesc.endPoint = zb_SimpleDesc.EndPoint;
  sapi_epDesc.task_id = &sapi_TaskID;
  sapi_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&zb_SimpleDesc;
  sapi_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint/interface description with the AF
  afRegister( &sapi_epDesc );
#endif

  // Turn off match descriptor response by default
  afSetMatch(sapi_epDesc.simpleDesc->EndPoint, FALSE);

  // Register callback evetns from the ZDApp
  ZDO_RegisterForZDOMsg( sapi_TaskID, NWK_addr_rsp );
  ZDO_RegisterForZDOMsg( sapi_TaskID, Match_Desc_rsp );

#if ( SAPI_CB_FUNC )
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
  // Register for HAL events
  RegisterForKeys( sapi_TaskID );

  if ( HalKeyRead () == HAL_KEY_SW_5)
  {
    // If SW5 is pressed and held while powerup, force auto-start and nv-restore off and reset
    uint8 startOptions = ZCD_STARTOPT_CLEAR_STATE | ZCD_STARTOPT_CLEAR_CONFIG;
    zb_WriteConfiguration( ZCD_NV_STARTUP_OPTION, sizeof(uint8), &startOptions );
    zb_SystemReset();
  }
#endif // HAL_KEY

  // Set an event to start the application
  osal_set_event(task_id, ZB_ENTRY_EVENT);
#endif
}
Ejemplo n.º 11
0
//Initialization function for the Park Way task. This is called during initialization and should contain any application specific initialization (ie. hardware initialization/setup, table initialization, power up notificaiton ... )
void ParkWay_Init( uint8 task_id )
{
  ParkWay_TaskID = task_id;
  ParkWay_NwkState = DEV_INIT;
  ParkWay_TransID = 0;

  // Device hardware initialization can be added here or in main() (Zmain.c).
  // If the hardware is application specific - add it here.
  // If the hardware is other parts of the device add it in main().

  ParkWay_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  ParkWay_DstAddr.endPoint = 0;
  ParkWay_DstAddr.addr.shortAddr = 0;

  // Fill out the endpoint description.
  ParkWay_epDesc.endPoint = ParkWay_ENDPOINT;
  ParkWay_epDesc.task_id = &ParkWay_TaskID;
  ParkWay_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&ParkWay_SimpleDesc;
  ParkWay_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &ParkWay_epDesc );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( ParkWay_TaskID );

  // Update the display
#if defined ( LCD_SUPPORTED )
  HalLcdWriteString( "ParkWay-Coord", HAL_LCD_LINE_1 );
#endif

  ZDO_RegisterForZDOMsg( ParkWay_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( ParkWay_TaskID, Match_Desc_rsp );

  osal_start_timerEx(   ParkWay_TaskID,
                        POLL_PARWAY_EVT,
                        TIME_PARKWAY_POLL);
}
void zclEnergyHarvester_Init( byte task_id ) {
  zclEnergyHarvester_TaskID = task_id;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclSampleLight_SimpleDesc );

  // Register for a test endpoint
  afRegister( &testEp );
  
  zcl_registerPlugin( ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT,
    ZCL_CLUSTER_ID_MS_ALL,
    zclEnergyHarvester_HdlIncoming );
  
  ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, End_Device_Bind_rsp );
  
#if DEV_TYPE == COORDINATOR
  ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, Device_annce );
#else
  adc_Init();
  
  // Configure signal from off-chip timer to be wake-up signal
  GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_3 , GPIO_DIR_MODE_IN );
  
  // Configure deep sleep in power mode 3, woken up by off-chip timer
  SysCtrlDeepSleepSetting();
  SysCtrlPowerModeSet( SYS_CTRL_PM_3 );
  GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_4 , GPIO_DIR_MODE_IN );
  HWREG( SYS_CTRL_IWE ) = 0x02;
  GPIOPowIntTypeSet( GPIO_B_BASE, GPIO_PIN_4, GPIO_POW_RISING_EDGE );
  GPIOPowIntClear( GPIO_B_BASE, GPIO_PIN_4 );
  GPIOPowIntEnable( GPIO_B_BASE, GPIO_PIN_4 );
  
  // Done with off-chip timer acknowledge
  GPIOPinWrite( GPIO_B_BASE, GPIO_PIN_5, GPIO_PIN_5 );
#endif
}
Ejemplo n.º 13
0
/*********************************************************************
 * @fn          zclRouterVersion1_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void zclRouterVersion1_Init( byte task_id )
{
  zclRouterVersion1_TaskID = task_id;

  // Set destination address to indirect
  zclRouterVersion1_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
  zclRouterVersion1_DstAddr.endPoint = 2;
  zclRouterVersion1_DstAddr.addr.shortAddr = 0x0000;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclRouterVersion1_SimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( ROUTERVERSION1_ENDPOINT, &zclRouterVersion1_CmdCallbacks );
  // Register the application's attribute list
  zcl_registerAttrList( ROUTERVERSION1_ENDPOINT, zclRouterVersion1_NumAttributes, zclRouterVersion1_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclRouterVersion1_TaskID );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclRouterVersion1_TaskID );

  // Register for a test endpoint
  afRegister( &sampleLight_TestEp );

  ZDO_RegisterForZDOMsg(task_id, Device_annce);

  osal_start_timerEx(zclRouterVersion1_TaskID, SET_PARAMETER, 1000);
  HAL_CONFIG_IO_OUTPUT(1,2,0);
  HAL_CONFIG_IO_OUTPUT(1,3,0);
  HAL_CONFIG_IO_OUTPUT(0,0,0);
  HAL_CONFIG_IO_OUTPUT(0,1,0);
  HAL_CONFIG_IO_OUTPUT(0,2,0);
  HAL_CONFIG_IO_OUTPUT(0,3,0);
  HAL_CONFIG_IO_OUTPUT(0,4,0);
  HAL_CONFIG_IO_OUTPUT(0,7,0);
  HalLedSet(HAL_LED_1,HAL_LED_MODE_OFF);
  HalLedSet(HAL_LED_2,HAL_LED_MODE_OFF);
  //ZDOInitDevice(0);
   if (ZDApp_ReadNetworkRestoreState() == 0) {
      ZDOInitDevice(0);
    }
}
/*********************************************************************
 * @fn          zclSampleTemperatureSensor_Init
 *
 * @brief       Initialization function for the zclGeneral layer.
 *
 * @param       none
 *
 * @return      none
 */
void zclSampleTemperatureSensor_Init( byte task_id )
{
  zclSampleTemperatureSensor_TaskID = task_id;

  // Set destination address to indirect
  zclSampleTemperatureSensor_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  zclSampleTemperatureSensor_DstAddr.endPoint = 0;
  zclSampleTemperatureSensor_DstAddr.addr.shortAddr = 0;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclSampleTemperatureSensor_SimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( SAMPLETEMPERATURESENSOR_ENDPOINT, &zclSampleTemperatureSensor_CmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( SAMPLETEMPERATURESENSOR_ENDPOINT, SAMPLETEMPERATURESENSOR_MAX_ATTRIBUTES, zclSampleTemperatureSensor_Attrs );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclSampleTemperatureSensor_TaskID );

#ifdef ZCL_EZMODE
  // Register EZ-Mode
  zcl_RegisterEZMode( &zclSampleTemperatureSensor_RegisterEZModeData );

  // Register with the ZDO to receive Match Descriptor Responses
  ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
#endif

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclSampleTemperatureSensor_TaskID );

  // Register for a test endpoint
  afRegister( &sampleTemperatureSensor_TestEp );

#ifdef LCD_SUPPORTED
  // display the device name
  HalLcdWriteString( (char *)sDeviceName, HAL_LCD_LINE_3 );
#endif
}
Ejemplo n.º 15
0
/*********************************************************************
 * @fn          loadcontrol_Init
 *
 * @brief       Initialization function for the ZCL App Application.
 *
 * @param       uint8 task_id - load control task id
 *
 * @return      none
 */
void loadcontrol_Init( uint8 task_id )
{
  loadControlTaskID = task_id;

  // setup destination address for ESP
  ESPAddr.addrMode = (afAddrMode_t)Addr16Bit;
  ESPAddr.endPoint = LOADCONTROL_ENDPOINT;
  ESPAddr.addr.shortAddr = 0;

  // register for SE endpoint
  zclSE_Init( &loadControlSimpleDesc );

  // Register the ZCL General Cluster Library callback functions
  zclGeneral_RegisterCmdCallbacks( LOADCONTROL_ENDPOINT, &loadcontrol_GenCmdCallbacks );

  // Register the ZCL SE Cluster Library callback functions
  zclSE_RegisterCmdCallbacks( LOADCONTROL_ENDPOINT, &loadcontrol_SECmdCallbacks );

  // Register the application's attribute list
  zcl_registerAttrList( LOADCONTROL_ENDPOINT, LOADCONTROL_MAX_ATTRIBUTES, loadControlAttrs );

  // Register the application's cluster option list
  zcl_registerClusterOptionList( LOADCONTROL_ENDPOINT, LOADCONTROL_MAX_OPTIONS, loadControlOptions );

  // Register the application's attribute data validation callback function
  zcl_registerValidateAttrData( loadcontrol_ValidateAttrDataCB );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( loadControlTaskID );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( loadControlTaskID );

  // Register with the ZDO to receive Match Descriptor Responses
  ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);

  // Start the timer to sync LoadControl timer with the osal timer
  osal_start_timerEx( loadControlTaskID, LOADCONTROL_UPDATE_TIME_EVT, LOADCONTROL_UPDATE_TIME_PERIOD );
}
Ejemplo n.º 16
0
void GenericApp_Init( uint8 task_id )
{
  uint16 size;
  
  GenericApp_TaskID = task_id;
  GenericApp_NwkState = DEV_INIT;
  GenericApp_TransID = 0;
  
  uint8 networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
  devStartModes_t devStartMode = MODE_RESUME; 
  

  //GenericApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent; //(afAddrMode_t)Addr16Bit;
  GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
  GenericApp_DstAddr.endPoint = GENERICAPP_ENDPOINT;
  GenericApp_DstAddr.addr.shortAddr = 0xFFFF;

  // Fill out the endpoint description.
  GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
  GenericApp_epDesc.task_id = &GenericApp_TaskID;
  GenericApp_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
  GenericApp_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &GenericApp_epDesc );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( GenericApp_TaskID );

  // Update the display
#if defined ( LCD_SUPPORTED )
  HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
#endif

  
#if !defined( ZDO_COORDINATOR )
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( GenericApp_TaskID, Match_Desc_rsp );
  
#endif
  
#if defined ( BUILD_ALL_DEVICES )
  size = osal_nv_item_len( ZCD_NV_LOGICAL_TYPE );
  if( size  <= sizeof(zgDeviceLogicalType) && size != 0 )
  {
    cb_ReadConfiguration( ZCD_NV_LOGICAL_TYPE, sizeof(zgDeviceLogicalType), &zgDeviceLogicalType);
  }
  
#endif

#if defined ( HOLD_AUTO_START )
  if(start_flag == 1)
  {
      ZDOInitDevice(0);
  }
#endif
  serial_init();
  
  init_cc2530();
  
  HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
  
}
Ejemplo n.º 17
0
/*********************************************************************
 * @fn      HVACTest_Init
 *
 * @brief   Initialization function for the Generic App Task.
 *          This is called during initialization and should contain
 *          any application specific initialization (ie. hardware
 *          initialization/setup, table initialization, power up
 *          notificaiton ... ).
 *
 * @param   task_id - the ID assigned by OSAL.  This ID should be
 *                    used to send messages and set timers.
 *
 * @return  none
 */
void HVACTest_Init( uint8 task_id )
{
  HVACTest_TaskID = task_id;
  HVACTest_NwkState = DEV_INIT;
  HVACTest_TransID = 0;
  uint8 initVersion = 0;
  uint8 startupMsg[4] = {0xFF,0xFF,0,0};

  // use this code to trick compiler
  initVersion = firm_version + hardware_version + chip_version;
  (void)initVersion;  
  
  // Device hardware initialization can be added here or in main() (Zmain.c).
  // If the hardware is application specific - add it here.
  // If the hardware is other parts of the device add it in main().
  hvac_STM32ResetInit();
  // Register UART, init UART
  MT_UartInit ();
  MT_UartRegisterTaskID (HVACTest_TaskID);
  
  HVACTest_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
  HVACTest_DstAddr.endPoint = HVACQUEEN_ENDPOINT;
  HVACTest_DstAddr.addr.shortAddr = 0;

  // Fill out the endpoint description.
  HVACTest_epDesc.endPoint = HVACQUEEN_ENDPOINT;
  HVACTest_epDesc.task_id = &HVACTest_TaskID;
  HVACTest_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&HVACTest_SimpleDesc;
  HVACTest_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &HVACTest_epDesc );
  
  // Register ZDO Message
  ZDO_RegisterForZDOMsg( HVACTest_TaskID, Device_annce );
  ZDO_RegisterForZDOMsg( HVACTest_TaskID, End_Device_Bind_rsp );
  ZDO_RegisterForZDOMsg( HVACTest_TaskID, Match_Desc_rsp );

  // Init critical resource
  ptl0_initPTL0Status();
  
  // check valid MAC address?
  //
  // If a mac address copy is valid in flash, send "FF FF FF" Msg to 
  // STM32 and start the zigbee network.
  //
  // If not, send "FF FF 00" Msg to STM32, and prepare to handle MAC 
  // address message.
  //
  // The forth byte is the firmware version
  
// Test program, no need init white list
// However, to disable any device to join, enable the empty white list function
  
  // Add firmware version
  startupMsg[3] = firm_version;
    
  // send valid flash startup mag
  while(HalUARTWrite(0, startupMsg, 4) != 4)
  {
#ifdef WDT_IN_PM1
    // clear WDT
    WDCTL |= WDCLP1; 
    WDCTL |= WDCLP2;
#endif
    HalUARTPoll();
  }
   
  // start network directly, form a network and check
  ZDOInitDevice(0);
 
  // Init timer
  osal_start_timerEx( HVACTest_TaskID,
               HVAC_PTL0_GUT_EVT,
               HVAC_PTL0_FAIL_TIMEOUT );
  
  // WDT
#ifdef WDT_IN_PM1
  // Start WDT reset timer
  osal_start_timerEx( HVACTest_TaskID,
                      HVAC_WDT_CLEAR_EVT,
                      HVAC_WDT_CLEAR_TIMEOUT ); 
#endif
  
#if defined( IAR_ARMCM3_LM )
  // Register this task with RTOS task initiator
  RTOS_RegisterApp( task_id, HVACQUEEN_RTOS_MSG_EVT );
#endif
}