summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h
blob: 160d1ca81b4e7db233c78d02be7ec5eec37b8d18 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**************************************************************************//**
  \file nwkGroup.h

  \brief Interface of the group table.

  \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:
    2010-07-20 Max Gekk - Created.
   Last change:
    $Id: nwkGroup.h 18320 2011-08-23 14:02:26Z ataradov $
 ******************************************************************************/
#if !defined _NWK_GROUP_H
#define _NWK_GROUP_H

/******************************************************************************
                               Includes section
 ******************************************************************************/
#include <appFramework.h>
#include <nlmeReset.h>

/******************************************************************************
                              Definitions section
 ******************************************************************************/
/** Value that can not be used as a group data parameter. */
#define NWK_INVALID_GROUP_DATA 0x00U
/** Universal group data. It means any group data value. */
#define NWK_ANY_GROUP_DATA 0xFFU

/******************************************************************************
                                Types section
 ******************************************************************************/
/** Type of data linked to group. */
typedef uint8_t NWK_GroupData_t;
/** Type of group address. */
typedef GroupAddr_t NWK_GroupAddr_t;

/** Type of group table entry. */
typedef struct _NWK_GroupTableEntry_t
{
  /** The data used by user, for example APS end point. */
  NWK_GroupData_t data;
  /** Address of group. */
  NWK_GroupAddr_t addr;
} NWK_GroupTableEntry_t;

/** Type of size of the group table.*/
typedef uint8_t NWK_GroupTableSize_t;

/** Type of internal variables of group component. */
typedef struct _NWK_GroupTable_t
{
  /** Pointer to first entry of the group table. */
  NWK_GroupTableEntry_t *begin;
  /** Pointer to memory after last entry of the group table. */
  NWK_GroupTableEntry_t *end;
} NWK_GroupTable_t;

/******************************************************************************
                               Prototypes section
 ******************************************************************************/
#if defined _GROUP_TABLE_
/**************************************************************************//**
  \brief Add new entry to the group table.

  \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
  \param[in] data - value linked to group. Valid range 0x01 - 0xfe.

  \return 'true' if entry is added successfully otherwise 'false'.
 ******************************************************************************/
bool NWK_AddGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);

/**************************************************************************//**
  \brief Remove group entries from the group table.

  \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
  \param[in] data - value linked to group. Valid range 0x01 - 0xff.
                    If data is equal to NWK_ANY_GROUP_DATA then remove
                    all entries with given group address.

  \return 'true' if any entry is removed successfully otherwise 'false'.
 ******************************************************************************/
bool NWK_RemoveGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);

/**************************************************************************//**
  \brief Remove all group entries with given group data

  \param[in] data - value linked to group. Valid range 0x01 - 0xff.
                    If data is equal to NWK_ANY_GROUP_DATA then remove
                    all entries from table.

  \return 'true' if any entry is removed successfully otherwise 'false'.
 ******************************************************************************/
bool NWK_RemoveAllGroups(const NWK_GroupData_t data);

/**************************************************************************//**
  \brief Check group address and data in the group table.

  \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
  \param[in] data - value linked to group. Valid range 0x01 - 0xff.
                    If data is equal to NWK_ANY_GROUP_DATA that means
                    any enties with given group address.

  \return 'true' if pair addr and data is found in the group table
           otherwise 'false'.
 ******************************************************************************/
bool NWK_IsGroupMember(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);

/**************************************************************************//**
  \brief Get remaining groups capacity.

  \return number of free entries in the group table.
 ******************************************************************************/
NWK_GroupTableSize_t NWK_GroupCapacity(void);

/**************************************************************************//**
  \brief Get first or next non-free entry from the groups table.

  \param[in] entry - address of the current entry or NULL to get the first entry.

  \return pointer to the next non-free entry or NULL if no more entries exist.
 ******************************************************************************/
NWK_GroupTableEntry_t* NWK_NextGroup(NWK_GroupTableEntry_t *entry);

/**************************************************************************//**
  \brief Allocate and initialize the group table.

  \param[in] powerFailureControl - stack restoring after power failure control bitfield;
                                  affects on initialization procedure.
 ******************************************************************************/
void NWK_ResetGroups(const NWK_PowerFailureControl_t powerFailureControl);

#else
#define NWK_ResetGroups(powerFailureControl) (void)0
#endif /* _GROUP_TABLE_ */
#endif /* _NWK_GROUP_H */
/** eof nwkGroup.h */