2015-02-15 星期日 3:35:47
Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#define ZG_DEVICETYPE_COORDINATOR 0x00
#define ZG_DEVICETYPE_ROUTER 0x01
#define ZG_DEVICETYPE_ENDDEVICE 0x02
// Default Device Logical Type
#if !defined ( DEVICE_LOGICAL_TYPE )
#
if
( ZG_BUILD_COORDINATOR_TYPE )
// If capable, default to coordinator
#define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_COORDINATOR
#elif ( ZG_BUILD_RTR_TYPE )
.............
uint8 zgDeviceLogicalType = DEVICE_LOGICAL_TYPE;
//在 ZDApp.c 文件中定义了设备初始状态和启动模式:
devState = DEV_INIT;
devStartMode = MODE_HARD;
|
流程
代码跟踪
//ZDO_NETWORK_INIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
void
ZDApp_Init( uint8 task_id )
{
......
ZDOInitDevice( 0 );
......
}
uint8 ZDOInitDevice( uint16 startDelay )
{
......
// Trigger the network start
ZDApp_NetworkInit( extendedDelay );
......
}
//ZDO_NETWORK_INIT
void
ZDApp_NetworkInit( uint16 delay )
{
if
( delay )
{
// Wait awhile before starting the device
osal_start_timerEx( ZDAppTaskID, ZDO_NETWORK_INIT, delay
);
}
else
{
osal_set_event( ZDAppTaskID, ZDO_NETWORK_INIT );
}
}
|
//ZDO_StartDevice
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
UINT16 ZDApp_event_loop( uint8 task_id, UINT16 events )
{
......
if
( events & ZDO_NETWORK_INIT )
{
// Initialize apps and start the network
devState = DEV_INIT;
osal_set_event( ZDAppTaskID, ZDO_STATE_CHANGE_EVT );
ZDO_StartDevice( (uint8)ZDO_Config_Node_Descriptor.LogicalType, devStartMode,
DEFAULT_BEACON_ORDER, DEFAULT_SUPERFRAME_ORDER );
// Return unprocessed events
return
(events ^ ZDO_NETWORK_INIT);
}
......
}
|
//ZDO_NETWORK_START && ZDO_STATE_CHANGE_EVT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
void
ZDO_NetworkFormationConfirmCB( ZStatus_t Status )
{
......
//ZDO_NETWORK_START
osal_set_event( ZDAppTaskID, ZDO_NETWORK_START );
......
}
UINT16 ZDApp_event_loop( uint8 task_id, UINT16 events )
{
......
//ZDO_NETWORK_START
if
( events & ZDO_NETWORK_START )
{
ZDApp_NetworkStartEvt();
// Return unprocessed events
return
(events ^ ZDO_NETWORK_START);
}
......
//ZDO_STATE_CHANGE_EVT
if
( events & ZDO_STATE_CHANGE_EVT )
{
ZDO_UpdateNwkStatus( devState );
// Return unprocessed events
return
(events ^ ZDO_STATE_CHANGE_EVT);
}
......
}
void
ZDApp_NetworkStartEvt(
void
)
{
......
//ZDO_STATE_CHANGE_EVT
osal_set_event( ZDAppTaskID, ZDO_STATE_CHANGE_EVT );
......
}
|
Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#define ZG_DEVICETYPE_COORDINATOR 0x00
#define ZG_DEVICETYPE_ROUTER 0x01
#define ZG_DEVICETYPE_ENDDEVICE 0x02
// Default Device Logical Type
#if !defined ( DEVICE_LOGICAL_TYPE )
......
#elif ( ZG_BUILD_RTR_TYPE )
#define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_ROUTER
......
......
uint8 zgDeviceLogicalType = DEVICE_LOGICAL_TYPE;
//在 ZDApp.c 文件中定义了设备初始状态和启动模式:
devState = DEV_INIT;
devStartMode = MODE_JOIN;
|
Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#define ZG_DEVICETYPE_COORDINATOR 0x00
#define ZG_DEVICETYPE_ROUTER 0x01
#define ZG_DEVICETYPE_ENDDEVICE 0x02
// Default Device Logical Type
#if !defined ( DEVICE_LOGICAL_TYPE )
......
#elif ( ZG_BUILD_ENDDEVICE_TYPE )
// Must be an end device
#define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_ENDDEVICE
#
else
#error ZSTACK_DEVICE_BUILD must be defined as something!
#endif
#endif
......
......
uint8 zgDeviceLogicalType = DEVICE_LOGICAL_TYPE;
//在 ZDApp.c 文件中定义了设备初始状态和启动模式:
devState = DEV_INIT;
devStartMode = MODE_JOIN;
|
流程
代码跟踪
参见代码。