summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h
blob: 75bf12c1bc2325fa60033a7f85d9d797516106a4 (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
/**************************************************************************//**
  \file nwkSync.h

  \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:
    2007-06-27 V. Panov - Created.
    2008-12-10 M. Gekk  - Reduction of usage of the RAM at separate compiling.
    2009-03-10 M. Gekk  - Refactoring.
   Last change:
    $Id: nwkSync.h 17448 2011-06-09 13:53:59Z ataradov $
 ******************************************************************************/
#if !defined _NWK_SYNC_H
#define _NWK_SYNC_H

/*****************************************************************************
                               Includes section
 *****************************************************************************/
#include <nwkConfig.h>
#include <queue.h>
#include <mac.h>

/******************************************************************************
                              Definitions section
 ******************************************************************************/
/** Maximum synchronization attempts. */
#define MAX_SYNC_FAIL_COUNTER 8U

/******************************************************************************
                                Types section
 ******************************************************************************/
/** Internal states of NLME-SYNC component */
typedef enum _NwkSyncState_t
{
  NWK_SYNC_IDLE_STATE = 0x31,
  NWK_SYNC_FIRST_STATE = 0xA3,
  NWK_SYNC_BEGIN_STATE = NWK_SYNC_FIRST_STATE,
  NWK_SYNC_MAC_POLL_STATE = 0xA4,
  NWK_SYNC_CONFIRM_STATE = 0xA5,
  NWK_SYNC_LAST_STATE
} NwkSyncState_t;

/** Internal parameters of NLME-SYNC component. */
typedef struct _NwkSync_t
{
  /** Internal component's state*/
  NwkSyncState_t state;
  /** Counter of synchronization attempts */
  uint8_t counter;
  /** Queue of NLME-SYNC.request from an upper layer */
  QueueDescriptor_t queue;
  /** MLME-POLL request primitive's parameters */
  MAC_PollReq_t macReq; /**< macReq must be no in union */
} NwkSync_t;

/*****************************************************************************
                            Prototypes section
 *****************************************************************************/
#if defined _ENDDEVICE_
/*************************************************************************//**
  \brief Main task handler of NLME-SYNC component
 *****************************************************************************/
NWK_PRIVATE void nwkSyncTaskHandler(void);

/*************************************************************************//**
  \brief Reset NLME-SYNC component.
 *****************************************************************************/
NWK_PRIVATE void nwkResetSync(void);

/******************************************************************************
  \brief nwkSync idle checking.

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

#else /* _ENDDEVICE_ */

#define nwkSyncTaskHandler NULL
#define nwkSyncIsIdle NULL
#define nwkResetSync() (void)0

#endif /* _ENDDEVICE_ */
#endif /* _NWK_SYNC_H */
/** eof nwkSync.h */