summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h
blob: f12c1b9bd95d6c8b8b7c0adee8567cbb70ef6632 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**************************************************************************//**
  \file nwkManager.h

  \brief Interface of the network manager.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
   History:
    2009-06-08 Max Gekk - Created.
   Last change:
    $Id: nwkManager.h 17448 2011-06-09 13:53:59Z ataradov $
 ******************************************************************************/
#if !defined _NWK_MANAGER_H
#define _NWK_MANAGER_H

/******************************************************************************
                               Includes section
 ******************************************************************************/
#include <nwkConfig.h>
#include <appFramework.h>
#include <mac.h>
#include <nldeData.h>
#include <nwkFrame.h>

/******************************************************************************
                              Define(s) section
 ******************************************************************************/
#define NWK_UPDATE_TX_PARAMETERS \
  {NWK_TX_DELAY_BROADCAST, nwkPrepareUpdateTx, nwkConfirmUpdateTx, true}

/******************************************************************************
                                Types section
 ******************************************************************************/
/** Internal states of the report command component */
typedef enum _NwkManagerState_t
{
  NWK_MANAGER_IDLE_STATE = 0xFB,
  NWK_MANAGER_FIRST_STATE = 0x83,
  NWK_MANAGER_MAC_SCAN_STATE = NWK_MANAGER_FIRST_STATE,
  NWK_MANAGER_PREPARE_MAC_DATA_STATE = 0x84,
  NWK_MANAGER_SEND_UPDATE_CMD_STATE = 0x85,
  NWK_MANAGER_SET_PAN_ID_STATE = 0x86,
  NWK_MANAGER_LAST_STATE
} NwkManagerState_t;

/** Internal variables of the network manager component. */
typedef struct _NwkManager_t
{
  /** Finite-state machine */
  NwkManagerState_t state;
  PanId_t newPanId; /* New non conflicted panId. */
  /* Range non conflicted panId from newPanId field. */
  PanId_t nonConflictRange;
  /** MLME-SCAN request primitive's parameters. */
  MAC_ScanReq_t macScan;
} NwkManager_t;

/******************************************************************************
                                Prototypes section
 ******************************************************************************/
#if defined _RESOLVE_PANID_CONFLICT_ && defined _NETWORK_MANAGER_
/**************************************************************************//**
  \brief Processing a conflict of panId by the network manager.
 ******************************************************************************/
NWK_PRIVATE void nwkDetectPanIdConflictByNwkManager(void);

/**************************************************************************//**
  \brief Reset the report command component.
 ******************************************************************************/
NWK_PRIVATE void nwkResetNetworkManager(void);

/**************************************************************************//**
  \brief Action when a report command is received.

  \param[in] payload - pointer to NPDU of NWK report command.
  \param[in] header  - nwk header.
  \param[in] parse   - parsed header fields.
  \return 'true' - continue command processing otherwise 'false'.
******************************************************************************/
NWK_PRIVATE bool nwkReportFrameInd(const uint8_t *const payload,
  const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);

/**************************************************************************//**
  \brief Prepare header and payload of the update command.

  \param[in] outPkt - pointer to output packet.
  \return None.
 ******************************************************************************/
NWK_PRIVATE void nwkPrepareUpdateTx(NwkOutputPacket_t *const outPkt);

/**************************************************************************//**
  \brief Confirmation of the update command transmission.

  \param[in] outPkt - pointer to output packet.
  \param[in] status - network status of the update command transmission.
  \return None.
 ******************************************************************************/
NWK_PRIVATE void nwkConfirmUpdateTx(NwkOutputPacket_t *const outPkt,
  const NWK_Status_t status);

/******************************************************************************
  \brief nwkNetworkManager idle checking.

  \return true, if nwkNetworkManager performs no activity, false - otherwise.
 ******************************************************************************/
NWK_PRIVATE bool nwkNetworkManagerIsIdle(void);

#else /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */

/* Interface of the network manager is disabled. */
INLINE void nwkDetectPanIdConflictByNwkManager(void) {}
#define nwkResetNetworkManager() (void)0
#define nwkReportFrameInd NULL
#define nwkPrepareUpdateTx NULL
#define nwkConfirmUpdateTx NULL
#define nwkNetworkManagerIsIdle NULL

#endif /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */
#endif /* _NWK_MANAGER_H */
/* eof nwkManager.h */