NLMEDE.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. /**************************************************************************************************
  2. Filename: NLMEDE.h
  3. Revised: $Date: 2011-05-05 15:49:12 -0700 (Thu, 05 May 2011) $
  4. Revision: $Revision: 25881 $
  5. Description: Network layer interface NLME and NLDE.
  6. Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef NLMEDE_H
  34. #define NLMEDE_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "ZMAC.h"
  42. #include "AssocList.h"
  43. #include "nwk_bufs.h"
  44. /*********************************************************************
  45. * MACROS
  46. */
  47. /*********************************************************************
  48. * CONSTANTS
  49. */
  50. // Tx Options (bitmap values)
  51. #define TX_OPTIONS_GTS 0x01
  52. #define TX_OPTIONS_SECURITY_ENABLE 0x02
  53. // Beacon Order Values
  54. #define BEACON_ORDER_NO_BEACONS 15
  55. #define BEACON_ORDER_4_MINUTES 14 // 245760 milliseconds
  56. #define BEACON_ORDER_2_MINUTES 13 // 122880 milliseconds
  57. #define BEACON_ORDER_1_MINUTE 12 // 61440 milliseconds
  58. #define BEACON_ORDER_31_SECONDS 11 // 30720 milliseconds
  59. #define BEACON_ORDER_15_SECONDS 10 // 15360 MSecs
  60. #define BEACON_ORDER_7_5_SECONDS 9 // 7680 MSecs
  61. #define BEACON_ORDER_4_SECONDS 8 // 3840 MSecs
  62. #define BEACON_ORDER_2_SECONDS 7 // 1920 MSecs
  63. #define BEACON_ORDER_1_SECOND 6 // 960 MSecs
  64. #define BEACON_ORDER_480_MSEC 5
  65. #define BEACON_ORDER_240_MSEC 4
  66. #define BEACON_ORDER_120_MSEC 3
  67. #define BEACON_ORDER_60_MSEC 2
  68. #define BEACON_ORDER_30_MSEC 1
  69. #define BEACON_ORDER_15_MSEC 0
  70. #define STARTING_SCAN_DURATION 5
  71. #define MAX_SCAN_DURATION 15
  72. #define ENERGY_SCAN_INCREMENT 16
  73. /* Definition of scan application */
  74. #define NLME_ED_SCAN 0
  75. #define NLME_DISC_SCAN 1
  76. #define NLME_PID_SCAN 2
  77. // CapabilityFlags Bitmap values
  78. #define CAPINFO_ALTPANCOORD 0x01
  79. #define CAPINFO_DEVICETYPE_FFD 0x02
  80. #define CAPINFO_DEVICETYPE_RFD 0x00
  81. #define CAPINFO_POWER_AC 0x04
  82. #define CAPINFO_RCVR_ON_IDLE 0x08
  83. #define CAPINFO_SECURITY_CAPABLE 0x40
  84. #define CAPINFO_ALLOC_ADDR 0x80
  85. // *********************** BROADCAST SUPPORT **********************************
  86. // Broadcast address definitions
  87. enum bcast_addr_e {
  88. NWK_BROADCAST_SHORTADDR_RESRVD_F8 = 0xFFF8,
  89. NWK_BROADCAST_SHORTADDR_RESRVD_F9,
  90. NWK_BROADCAST_SHORTADDR_RESRVD_FA,
  91. NWK_BROADCAST_SHORTADDR_RESRVD_FB,
  92. NWK_BROADCAST_SHORTADDR_DEVZCZR, // 0xFFFC: Routers and Coordinators
  93. NWK_BROADCAST_SHORTADDR_DEVRXON, // 0xFFFD: Everyone with RxOnWhenIdle == TRUE
  94. // 0xFFFE: Reserved (legacy: used for 'invalid address')
  95. NWK_BROADCAST_SHORTADDR_DEVALL = 0xFFFF
  96. };
  97. typedef enum bcast_addr_e bcast_addr_t;
  98. #define NWK_BROADCAST_SHORTADDR NWK_BROADCAST_SHORTADDR_DEVALL
  99. // Broadcast filter support
  100. #define NWK_BROADCAST_FILTER_DEVALL ((uint8)0x01)
  101. #define NWK_BROADCAST_FILTER_DEVRXON ((uint8)0x02)
  102. #define NWK_BROADCAST_FILTER_DEVZCZR ((uint8)0x04)
  103. #define NWK_BROADCAST_FILTER_RESRVD ((uint8)0x08)
  104. #define NWK_BROADCAST_FILTER_ANY ( \
  105. NWK_BROADCAST_FILTER_DEVALL | \
  106. NWK_BROADCAST_FILTER_DEVRXON | \
  107. NWK_BROADCAST_FILTER_DEVZCZR | \
  108. NWK_BROADCAST_FILTER_RESRVD \
  109. )
  110. enum addr_filter_e {
  111. ADDR_NOT_BCAST, // not a broadcast address
  112. ADDR_BCAST_NOT_ME, // broadcast address but not for me based on capabilities
  113. ADDR_BCAST_FOR_ME // broadcast for me based on capabilities
  114. };
  115. typedef enum addr_filter_e addr_filter_t;
  116. // Join indication type - MAC associate or rejoin
  117. #define NWK_ASSOC_JOIN 0
  118. #define NWK_ASSOC_REJOIN_UNSECURE 1
  119. #define NWK_ASSOC_REJOIN_SECURE 2
  120. #define NWK_FRAME_TYPE_MASK 0x03
  121. #define NWK_FRAMETYPE_FORCE_SEQ 0x80
  122. // *********************** END BROADCAST SUPPORT **********************************
  123. // NV Enables - for use when saving NV [NLME_UpdateNV()]
  124. #define NWK_NV_NIB_ENABLE 0x01
  125. #define NWK_NV_DEVICELIST_ENABLE 0x02
  126. #define NWK_NV_BINDING_ENABLE 0x04
  127. #define NWK_NV_ADDRMGR_ENABLE 0x08
  128. /*********************************************************************
  129. * TYPEDEFS
  130. */
  131. typedef enum
  132. {
  133. nwkSequenceNum = 0x81,
  134. nwkPassiveAckTimeout,
  135. nwkMaxBroadcastRetries,
  136. nwkMaxChildren,
  137. nwkMaxDepth,
  138. nwkMaxRouters,
  139. nwkNeighborTable,
  140. nwkBroadcastDeliveryTime,
  141. nwkReportConstantCost,
  142. nwkRouteDiscRetries, // 0x8a
  143. nwkRoutingTable,
  144. nwkSecureAllFrames,
  145. nwkSecurityLevel,
  146. nwkSymLink,
  147. nwkCapabilityInfo, // 0x8f
  148. // next 5 attributes are only needed for alternate addressing...
  149. //nwkUseTreeAddrAlloc, // boolean
  150. //nwkUseTreeRouting, // boolean
  151. //nwkNextAddress, // 16 bit
  152. //nwkAvailableAddresses, // 16 bit
  153. //nwkAddressIncrement, // 16 bit
  154. nwkTransactionPersistenceTime = 0x95, // 16 bit
  155. //nwkShortAddress, // 16 bit
  156. //nwkStackProfile,
  157. nwkProtocolVersion = 0x98,
  158. //nwkAllowAddressReuse, // Boolean
  159. //nwkGroupIDTable,
  160. // non-standard items
  161. nwkRouteDiscoveryTime = 0x9B,
  162. nwkNumNeighborTableEntries,
  163. nwkNumRoutingTableEntries,
  164. nwkNwkState,
  165. nwkMAX_NIB_ITEMS // Must be the last entry
  166. }ZNwkAttributes_t;
  167. typedef struct
  168. {
  169. uint16 panId;
  170. byte logicalChannel;
  171. byte routerCapacity;
  172. byte deviceCapacity;
  173. byte version;
  174. byte stackProfile;
  175. uint16 chosenRouter;
  176. uint8 chosenRouterLinkQuality;
  177. uint8 chosenRouterDepth;
  178. uint8 extendedPANID[Z_EXTADDR_LEN];
  179. byte updateId;
  180. void *nextDesc;
  181. } networkDesc_t;
  182. // Src route subframe format
  183. typedef struct
  184. {
  185. uint8 relayCnt;
  186. uint8 relayIdx;
  187. uint16* relayList;
  188. } NLDE_SrcFrameFormat_t;
  189. typedef struct
  190. {
  191. uint8 bufLength;
  192. uint8 hdrLen;
  193. uint8 frameType;
  194. uint8 protocolVersion;
  195. uint8 discoverRoute;
  196. uint8 multicast;
  197. uint8 secure;
  198. uint8 dstExtAddrSet;
  199. uint8 srcExtAddrSet;
  200. uint16 dstAddr;
  201. uint16 srcAddr;
  202. uint16 macDstAddr;
  203. uint16 transID; // Only used in local messaging
  204. uint8 radius;
  205. uint8 broadcastId;
  206. uint8* dstExtAddr;
  207. uint8* srcExtAddr;
  208. uint8 nsduLength;
  209. uint8 srcRouteSet; //If this flag is set, srcfd shall present
  210. NLDE_SrcFrameFormat_t srcfd; //Source route frame data
  211. uint8* nsdu;
  212. } NLDE_FrameFormat_t;
  213. typedef struct
  214. {
  215. uint8 LinkQuality; /* The link quality of the received data frame */
  216. uint8 correlation; /* The raw correlation value of the received data frame */
  217. int8 rssi; /* The received RF power in units dBm */
  218. } NLDE_Signal_t;
  219. #define NLME_SCAN_FIELDS_RES_SIZE 1
  220. typedef struct
  221. {
  222. uint8 frameType;
  223. uint8 hdrLen;
  224. uint16 dstAddr;
  225. uint16 srcAddr;
  226. uint8 srcRouteSet; // If this flag is set, srcfd shall present
  227. NLDE_SrcFrameFormat_t srcfd; // Source route frame data
  228. uint8* nsdu;
  229. uint8 nsduLen;
  230. uint8 nsduHandle;
  231. uint16 nsduHandleOptions;
  232. uint8 secure;
  233. uint8 discoverRoute;
  234. uint8 radius;
  235. uint8 seqNum;
  236. uint8 multicast;
  237. uint8 dstExtAddrSet;
  238. uint8 srcExtAddrSet;
  239. uint8* dstExtAddr;
  240. uint8* srcExtAddr;
  241. uint16 transID; // Only used for local messaging
  242. void* fd;
  243. } NLDE_FrameData_t;
  244. typedef struct
  245. {
  246. //ZMacDataReq_t mfd;
  247. NLDE_FrameData_t nfd;
  248. } NLDE_DataReq_t;
  249. typedef struct
  250. {
  251. uint8 overhead;
  252. uint8 nsduLen;
  253. uint8 secure;
  254. } NLDE_DataReqAlloc_t;
  255. typedef struct
  256. {
  257. uint32 channels;
  258. uint8 duration;
  259. uint8 scanType;
  260. uint8 scanApp;
  261. } NLME_ScanFields_t;
  262. typedef struct
  263. {
  264. nwkDB_t* db;
  265. ZStatus_t status;
  266. } NLDE_DataCnf_t;
  267. typedef struct
  268. {
  269. uint8* extAddr;
  270. uint8 removeChildren;
  271. uint8 rejoin;
  272. uint8 silent;
  273. } NLME_LeaveReq_t;
  274. typedef struct
  275. {
  276. uint8 removeChildren;
  277. uint8 rejoin;
  278. } NLME_LeaveRsp_t;
  279. typedef struct
  280. {
  281. uint16 dstAddr;
  282. uint8 extAddr[Z_EXTADDR_LEN];
  283. uint8 removeChildren;
  284. uint8 rejoin;
  285. uint8 status;
  286. } NLME_LeaveCnf_t;
  287. typedef struct
  288. {
  289. uint16 srcAddr;
  290. uint8 extAddr[Z_EXTADDR_LEN];
  291. uint8 request;
  292. uint8 removeChildren;
  293. uint8 rejoin;
  294. } NLME_LeaveInd_t;
  295. typedef struct
  296. {
  297. uint16 sourceAddr;
  298. uint16 panID;
  299. uint8 logicalChannel;
  300. uint8 permitJoining;
  301. uint8 routerCapacity;
  302. uint8 deviceCapacity;
  303. uint8 protocolVersion;
  304. uint8 stackProfile ;
  305. uint8 LQI ;
  306. uint8 depth ;
  307. uint8 updateID;
  308. uint8 extendedPanID[Z_EXTADDR_LEN];
  309. } NLME_beaconInd_t;
  310. /*********************************************************************
  311. * GLOBAL VARIABLES
  312. */
  313. extern byte NLME_PermitJoining;
  314. extern byte NLME_AssocPermission;
  315. extern uint16 savedResponseRate; // Backed response rate for rejoin request
  316. // network discovery scan fields
  317. extern NLME_ScanFields_t* NLME_ScanFields;
  318. /*********************************************************************
  319. * NWK Data Service
  320. * NLDE-DATA
  321. */
  322. /*
  323. * This function requests the transfer of data using the NWK layer
  324. * data service.
  325. *
  326. * @MT SPI_CMD_NLDE_DATA_REQ
  327. *
  328. */
  329. extern ZStatus_t NLDE_DataReq( NLDE_DataReq_t* req );
  330. /*
  331. * This function allocates a request buffer for use with the NWK layer
  332. * data service.
  333. *
  334. */
  335. extern NLDE_DataReq_t* NLDE_DataReqAlloc( NLDE_DataReqAlloc_t* dra );
  336. /*
  337. * This function reports the results of a request to transfer a data
  338. * PDU (NSDU) from a local APS sub-layer entity to a single peer APS
  339. * sub-layer entity.
  340. *
  341. * @MT SPI_CB_NLDE_DATA_CNF
  342. *
  343. */
  344. extern void NLDE_DataCnf( NLDE_DataCnf_t* cnf );
  345. /*
  346. * This function indicates the transfer of a data PDU (NSDU) from the
  347. * NWK layer to the local APS sub-layer entity.
  348. *
  349. * @MT SPI_CB_NLDE_DATA_IND
  350. */
  351. extern void NLDE_DataIndication( NLDE_FrameFormat_t *ff, NLDE_Signal_t *sig, uint32 timestamp );
  352. /*********************************************************************
  353. * NWK Management Service
  354. * NLME-NETWORK-FORMATION
  355. * NLME-NETWORK-DISCOVERY
  356. * NLME-PERMIT-JOINING
  357. * NLME-JOIN
  358. * NLME-DIRECT-JOIN
  359. * NLME-ORPHAN-JOIN
  360. * NLME-START-ROUTER
  361. * NLME-SYNC
  362. * NLME-LEAVE
  363. * NLME-RESET
  364. * NLME-GET
  365. * NLME-SET
  366. */
  367. /*
  368. * This function allows the next higher layer to request that the device
  369. * form a new network and become the ZigBee Coordinator for that network.
  370. *
  371. * @MT SPI_CMD_NLME_INIT_COORD_REQ
  372. * (uint16 PanId,
  373. * uint32 ScanChannels,
  374. * byte BeaconOrder,
  375. * byte ScanDuration,
  376. * byte SuperFrameOrder,
  377. * byte BatteryLifeExtension)
  378. *
  379. */
  380. extern ZStatus_t NLME_NetworkFormationRequest( uint16 PanId, uint8* ExtendedPANID, uint32 ScanChannels,
  381. byte ScanDuration, byte BeaconOrder,
  382. byte SuperframeOrder, byte BatteryLifeExtension );
  383. /*
  384. * This function reports the results of the request to form a new
  385. * network.
  386. *
  387. * @MT SPI_CB_NLME_INITCOORD_CNF
  388. *
  389. */
  390. extern void NLME_NetworkFormationConfirm( ZStatus_t Status );
  391. /* This function requests the NWK layer to discover neighboring routers
  392. *
  393. * @MT SPI_CMD_NLME_NWK_DISC_REQ
  394. *
  395. */
  396. extern ZStatus_t NLME_NetworkDiscoveryRequest( uint32 ScanChannels,
  397. uint8 scanDuration);
  398. /* This function allows the NWK layer to discover neighboring routers
  399. * without affecting the current nwk state
  400. */
  401. extern ZStatus_t NLME_NwkDiscReq2( NLME_ScanFields_t* fields );
  402. /* This function cleans up the NWK layer after a call to
  403. * NLME_NwkDiscReq2
  404. */
  405. extern void NLME_NwkDiscTerm( void );
  406. /* This function returns network discovery confirmation
  407. *
  408. * @MT SPI_CB_NLME_NWK_DISC_CNF
  409. *
  410. */
  411. extern void NLME_NetworkDiscoveryConfirm(uint8 status);
  412. /*
  413. * This function defines how the next higher layer of a coordinator device
  414. * to permit devices to join its network for a fixed period.
  415. *
  416. * @MT SPI_CMD_NLME_PERMIT_JOINING_REQ
  417. *
  418. */
  419. extern ZStatus_t NLME_PermitJoiningRequest( byte PermitDuration );
  420. /*
  421. * This function handles the NWK_PERMITJOIN_EVT event.
  422. *
  423. */
  424. extern void NLME_PermitJoiningEvent( void );
  425. /*
  426. * This function allows the next higher layer to request the device to join
  427. * itself to a specific network.
  428. *
  429. * @MT SPI_CMD_NLME_JOIN_REQ
  430. *
  431. */
  432. extern ZStatus_t NLME_JoinRequest( uint8 *extendedPANID, uint16 PanId,
  433. uint8 channel, uint8 CapabilityFlags,
  434. uint16 chosenParent, uint8 parentDepth );
  435. /*
  436. * This function allows the next higher layer to request to directly join
  437. * another device to this device
  438. * The result is contained in the return value and there is no confirm primitive
  439. *
  440. * @MT SPI_CMD_NLME_DIRECT_JOIN_REQ
  441. *
  442. */
  443. extern ZStatus_t NLME_DirectJoinRequest( byte *DevExtAddress, byte capInfo );
  444. /*
  445. * This function allows the next higher layer to request to directly join
  446. * another device, specified by the short address, to this device
  447. * The result is contained in the return value and there is no confirm primitive
  448. */
  449. extern ZStatus_t NLME_DirectJoinRequestWithAddr( byte *DevExtAddress, uint16 shortAddress, uint8 capInfo );
  450. /*
  451. * This function allows the next higher layer to request the device
  452. * to search for its parent.
  453. *
  454. * @MT SPI_CMD_NLME_ORPHAN_JOIN_REQ
  455. *
  456. */
  457. extern ZStatus_t NLME_OrphanJoinRequest( uint32 ScanChannels, byte ScanDuration );
  458. /*
  459. * This function allows the next higher layer to request the device
  460. * to rejoin the network.
  461. */
  462. extern ZStatus_t NLME_ReJoinRequest( uint8 *ExtendedPANID, uint8 channel );
  463. /*
  464. * This function allows the next higher layer to request the device
  465. * to rejoin the network "non-securely".
  466. */
  467. extern ZStatus_t NLME_ReJoinRequestUnsecure( uint8 *ExtendedPANID, uint8 channel );
  468. /*
  469. * This function allows the next higher layer to be notified of the
  470. * results of its request to join itself to a network.
  471. *
  472. * @MT SPI_CB_NLME_JOIN_CNF
  473. * (byte *DeviceAddress,
  474. * uint16 PanId,
  475. * byte Status)
  476. *
  477. */
  478. extern void NLME_JoinConfirm( uint16 PanId, ZStatus_t Status );
  479. /*
  480. * This function allows the next higher layer of a coordinator to be
  481. * notified of a remote join request.
  482. *
  483. * @MT SPI_CB_NLME_JOIN_IND
  484. *
  485. */
  486. extern ZStatus_t NLME_JoinIndication( uint16 ShortAddress,
  487. uint8 *ExtendedAddress,
  488. uint8 CapabilityFlags,
  489. uint8 type );
  490. /*
  491. * This function allows the next higher layer to request a device to function
  492. * as a router. NOTE: the BeaconOrder and SuperframeOrder parameters are not
  493. * used in this version -- the values obtained during network formation or
  494. * joining are used instead, ensuring commonality with the ZDO COORDINATOR.
  495. *
  496. * @MT SPI_CMD_NLME_START_ROUTER_REQ
  497. *
  498. */
  499. extern ZStatus_t NLME_StartRouterRequest( byte BeaconOrder,
  500. byte SuperframeOrder,
  501. byte BatteryLifeExtension );
  502. /*
  503. * This function reports the results of the request to start
  504. * functioning as a router.
  505. *
  506. * @MT SPI_CB_NLME_START_ROUTER_CNF
  507. *
  508. */
  509. extern void NLME_StartRouterConfirm( ZStatus_t Status );
  510. /*
  511. * This function reports the beacon notification received due
  512. * to network discovery
  513. *
  514. */
  515. extern void NLME_beaconNotifyInd(NLME_beaconInd_t *pBeacon);
  516. /*
  517. * This function allows the next higher layer to request that itself
  518. * or another device leave the network.
  519. *
  520. * @MT SPI_CMD_NLME_LEAVE_REQ
  521. *
  522. */
  523. extern ZStatus_t NLME_LeaveReq( NLME_LeaveReq_t* req );
  524. /*
  525. * This function allows the next higher layer to be notified of the
  526. * results of its request for itself or another device to leave the
  527. * network.
  528. *
  529. * @MT SPI_CB_NLME_LEAVE_CNF
  530. *
  531. */
  532. extern void NLME_LeaveCnf( NLME_LeaveCnf_t* cnf );
  533. /*
  534. * This function allows the next higher layer of a device to be
  535. * notified of a remote leave request.
  536. *
  537. * @MT SPI_CB_NLME_LEAVE_IND
  538. *
  539. */
  540. extern void NLME_LeaveInd( NLME_LeaveInd_t* ind );
  541. /*
  542. * This function allows the next higher layer to respond to a leave
  543. * indication.
  544. */
  545. extern ZStatus_t NLME_LeaveRsp( NLME_LeaveRsp_t* rsp );
  546. /*
  547. * This function allows the next higher layer to request that the NWK layer
  548. * perform a reset operation.
  549. *
  550. * @MT SPI_CMD_NLME_RESET_REQ
  551. *
  552. */
  553. extern ZStatus_t NLME_ResetRequest( void );
  554. /*
  555. * This function allows the next higher layer to request
  556. * synchronization with its parent and extract data
  557. *
  558. * @MT SPI_CMD_NLME_SYNC_REQ
  559. */
  560. extern ZStatus_t NLME_SyncRequest( byte Track );
  561. /*
  562. * This function allows the next higher layer to be notified of the
  563. * loss of synchronization at the MAC sub-layer.
  564. *
  565. * @MT SPI_CB_NLME_SYNC_IND
  566. * (byte Status)
  567. *
  568. */
  569. extern void NLME_SyncIndication( byte type, uint16 shortAddr );
  570. /*
  571. * This function stub allows the next higher layer to be notified of
  572. * a permit joining timeout.
  573. */
  574. extern void NLME_PermitJoiningTimeout( void );
  575. /*
  576. * This function allows the next higher layer to be notified of a
  577. * Poll Confirm from the MAC sub-layer.
  578. *
  579. * @MT SPI_CB_NLME_POLL_CNF
  580. * (byte Status)
  581. *
  582. */
  583. extern void NLME_PollConfirm( byte status );
  584. /*
  585. * This function allows the next higher layer to read the value of
  586. * an attribute from the NIB.
  587. *
  588. * @MT SPI_CMD_NLME_GET_REQ
  589. *
  590. */
  591. extern ZStatus_t NLME_GetRequest( ZNwkAttributes_t NIBAttribute, uint16 Index,
  592. void *Value );
  593. /*
  594. * This function allows the next higher layer to write the value of an
  595. * attribute into the NIB.
  596. *
  597. * @MT SPI_CMD_NLME_SET_REQ
  598. *
  599. */
  600. extern ZStatus_t NLME_SetRequest( ZNwkAttributes_t NIBAttribute,
  601. uint16 Index,
  602. void *Value );
  603. /*
  604. * This function allows the higher layers to initiate route discovery
  605. * to a given destination address
  606. *
  607. * @MT SPI_CMD_NLME_ROUTE_DISC_REQ
  608. *
  609. */
  610. extern ZStatus_t NLME_RouteDiscoveryRequest( uint16 DstAddress, byte options, uint8 radius );
  611. /*
  612. * This function allow to indicate to higher layer the existence of
  613. * concentrator and its nwk address
  614. */
  615. extern void NLME_ConcentratorIndication( uint16 nwkAddr, uint8 *extAddr, uint8 pktCost );
  616. /*
  617. * This function allows the next higher layer to request an energy scan
  618. * to evaluate channels in the local area.
  619. */
  620. extern ZStatus_t NLME_EDScanRequest( uint32 ScanChannels, uint8 scanDuration);
  621. /*
  622. * This function returns list of energy measurements.
  623. */
  624. extern void NLME_EDScanConfirm( uint8 status, uint32 scannedChannels, uint8 *energyDetectList );
  625. /*********************************************************************
  626. * NWK Helper Functions
  627. */
  628. /*
  629. * This function will return a pointer to the device's IEEE 64 bit address
  630. *
  631. * This function resides in nwk_util.c.
  632. */
  633. extern byte *NLME_GetExtAddr( void );
  634. /*
  635. * This function will return this device's 16 bit short address
  636. *
  637. * This function resides in nwk_util.c.
  638. */
  639. extern uint16 NLME_GetShortAddr( void );
  640. /*
  641. * This function will return the MAC's Coordinator's short (16bit) address
  642. * which is this device's parent, not necessarily the Zigbee coordinator.
  643. *
  644. * This function resides in nwk_util.c.
  645. */
  646. extern uint16 NLME_GetCoordShortAddr( void );
  647. /*
  648. * This function will return the MAC's Coordinator's Extented (64bit) address
  649. * which is this device's parent, not necessarily the Zigbee coordinator.
  650. *
  651. * This function resides in nwk_util.c.
  652. */
  653. extern void NLME_GetCoordExtAddr( byte * );
  654. /*
  655. * Use this function to request a single MAC data request.
  656. */
  657. extern ZMacStatus_t NwkPollReq( byte securityEnable );
  658. /*
  659. * Use this function to set/change the Network Poll Rate. If the
  660. * newRate is set to 0, it will turn off the auto polling, 1 will do a
  661. * one time poll.
  662. */
  663. extern void NLME_SetPollRate( uint16 newRate );
  664. /*
  665. * Use this function to set/change the Network Queued Poll Rate.
  666. * This is used after receiving a data indication to poll immediately
  667. * for queued messages.
  668. */
  669. extern void NLME_SetQueuedPollRate( uint16 newRate );
  670. /*
  671. * Use this function to set/change the Network Queued Poll Rate.
  672. * This is used after receiving a data confirmation to poll immediately
  673. * for response messages.
  674. */
  675. extern void NLME_SetResponseRate( uint16 newRate );
  676. /*
  677. * Initialize the Nwk, Assoc device list, and binding NV Items
  678. * returns ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
  679. * exist in NV, NV_OPER_FAILED if failure.
  680. */
  681. extern byte NLME_InitNV( void );
  682. /*
  683. * Set defaults for the Nwk, Assoc device list, and binding NV Items
  684. */
  685. extern void NLME_SetDefaultNV( void );
  686. /*
  687. * Restore network memory items from NV.
  688. */
  689. extern byte NLME_RestoreFromNV( void );
  690. /*
  691. * Write network items to NV.
  692. * enables - bit mask of items to save:
  693. * NWK_NV_NIB_ENABLE
  694. * NWK_NV_DEVICELIST_ENABLE
  695. * NWK_NV_BINDING_ENABLE
  696. * NWK_NV_ADDRMGR_ENABLE
  697. */
  698. void NLME_UpdateNV( byte enables );
  699. /*
  700. * NLME_CheckNewAddrSet
  701. *
  702. * We have a new address pair (short and extended) - check our database.
  703. * dontChange - Don't change our address just issue conflict (It was taken
  704. * out since the Spec was changed again. All devices will
  705. * change address upon any circumstances.
  706. *
  707. * Returns ZSuccess if in data base and matches
  708. * ZUnsupportedMode if not in database
  709. * ZFailure if short address is in database,
  710. * but extended address doesn't match database
  711. *
  712. * If ZFailure is returned, the stack already sent out an address conflict
  713. * route error - already called NLME_ReportAddressConflict().
  714. */
  715. extern ZStatus_t NLME_CheckNewAddrSet( uint16 shortAddr, uint8 *extAddr );
  716. /*
  717. * Issues a Router Error with Address conflict and handles the
  718. * conflict locally for itself and children (RFDs).
  719. */
  720. extern void NLME_ReportAddressConflict( uint16 shortAddr, uint8 forceSpecialMode );
  721. extern void NLME_CoordinatorInit( void );
  722. extern void NLME_DeviceJoiningInit( void );
  723. extern void (*pnwk_ScanPANChanSelect)( ZMacScanCnf_t *param );
  724. extern void (*pnwk_ScanPANChanVerify)( ZMacScanCnf_t *param );
  725. extern void (*pnwk_ScanJoiningOrphan)( ZMacScanCnf_t *param );
  726. extern void (*pNLME_NetworkFormationConfirm)( ZStatus_t Status );
  727. extern void NLME_InitStochasticAddressing( void );
  728. extern void NLME_InitTreeAddressing( void );
  729. extern ZStatus_t NLME_ReadNwkKeyInfo(uint16 index, uint16 len, void *keyinfo, uint16 NvId);
  730. /****************************************************************************
  731. ****************************************************************************/
  732. #ifdef __cplusplus
  733. }
  734. #endif
  735. #endif /* NLMEDE_H */