aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-lib/inc/ucs_nodeobserver_pb.h
blob: a76e1ee645590f20e88588176bc9981c6332d831 (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
/*------------------------------------------------------------------------------------------------*/
/* UNICENS V2.1.0-3491                                                                            */
/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
/*                                                                                                */
/* This program is free software: you can redistribute it and/or modify                           */
/* it under the terms of the GNU General Public License as published by                           */
/* the Free Software Foundation, either version 2 of the License, or                              */
/* (at your option) any later version.                                                            */
/*                                                                                                */
/* This program is distributed in the hope that it will be useful,                                */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
/* GNU General Public License for more details.                                                   */
/*                                                                                                */
/* You should have received a copy of the GNU General Public License                              */
/* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
/*                                                                                                */
/* You may also obtain this software under a propriety license from Microchip.                    */
/* Please contact Microchip for further information.                                              */
/*------------------------------------------------------------------------------------------------*/

/*!
 * \file
 * \brief Public header file of the CNodeObserver class
 */
/*!
 * \addtogroup G_UCS_MGR
 * @{
 */

#ifndef UCS_NODEOBSERVER_PB_H
#define UCS_NODEOBSERVER_PB_H

/*------------------------------------------------------------------------------------------------*/
/* Includes                                                                                       */
/*------------------------------------------------------------------------------------------------*/
#include "ucs_rules.h"
#include "ucs_rm_pb.h"

#ifdef __cplusplus
extern "C"
{
#endif

/*! \brief Manager report codes */
typedef enum Ucs_MgrReport_
{
    UCS_MGR_REP_IGNORED_UNKNOWN   = 0, /*!< \brief A discovered node is ignored due to a wrong signature,
                                        *          a missing entry in the \ref Ucs_Mgr_InitData_t "nodes_list_ptr",
                                        *          or since the desired node address is not within the following range:
                                        *          0x200..0x2FF, 0x500..0xEFF.
                                        */
    UCS_MGR_REP_IGNORED_DUPLICATE = 1, /*!< \brief A discovered node is ignored due since it is a duplicate
                                        *          of an alredy welcomed node.
                                        */
    UCS_MGR_REP_AVAILABLE         = 2, /*!< \brief A discovered node was successfully "welcomed" 
                                        *          in the network.
                                        */
    UCS_MGR_REP_NOT_AVAILABLE     = 3  /*!< \brief A previously welcomed node became invalid and is 
                                        *          no longer accessible in the network.
                                        */
} Ucs_MgrReport_t;

/*! \brief Optional callback function that reports events on ignored, welcomed and lost nodes.
 *  \param code             Report code
 *  \param node_address     The desired node_address of the node which is defined in it's signature.
 *  \param node_ptr         Reference to the node object which is part of the \ref Ucs_Mgr_InitData_t "nodes_list_ptr".
 *                          The reference is \c NULL if \c code is \c UCS_MGR_REP_IGNORED_UNKNOWN or 
 *                          \c UCS_MGR_REP_IGNORED_DUPLICATE.
 *  \param user_ptr         User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr".
 */
typedef void (*Ucs_MgrReportCb_t)(Ucs_MgrReport_t code, uint16_t node_address, Ucs_Rm_Node_t *node_ptr, void *user_ptr);

/*! \brief   The initialization data of the Manager */
typedef struct Ucs_Mgr_InitData_
{
    bool enabled;                       /*!< \brief If set to \c false the application must
                                         *          handle network startup, node discovery and
                                         *          rooting by hand.
                                         */
    uint16_t packet_bw;                 /*!< \brief The desired packet bandwidth.\mns_name_inic{PacketBW} */
    
    Ucs_Rm_Route_t *routes_list_ptr;    /*!< \brief Reference to a list of routes */
    uint16_t routes_list_size;          /*!< \brief Number of routes in the list */
    
    Ucs_Rm_Node_t *nodes_list_ptr;      /*!< \brief Reference to the list of nodes */
    uint16_t nodes_list_size;           /*!< \brief Number of nodes in the list */

    Ucs_MgrReportCb_t report_fptr;      /*!< \brief Optional callback function notifying node events */

} Ucs_Mgr_InitData_t;


#ifdef __cplusplus
}               /* extern "C" */
#endif

#endif  /* ifndef UCS_NODEOBSERVER_PB_H */

/*! @} */

/*------------------------------------------------------------------------------------------------*/
/* End of file                                                                                    */
/*------------------------------------------------------------------------------------------------*/