summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_network.h
blob: e97a3e7533dc0db144487691803faed03820f703 (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
/*******************************************************************************
 * Copyright (C) ST-Ericsson SA 2011
 * License terms: 3-clause BSD license
 ******************************************************************************/
#ifndef _R_A2_NETWORK_H_
#define _R_A2_NETWORK_H_
/**
 *  @addtogroup ldr_communication_serv
 *  @{
 *    @addtogroup a2_family
 *    @{
 *      @addtogroup ldr_network_layer
 *      @{
 */

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "error_codes.h"
#include "t_basicdefinitions.h"
#include "t_a2_network.h"
#include "t_communication_service.h"

/*******************************************************************************
 * Declaration of functions
 ******************************************************************************/
/**
 * Initializes the A2 family network layer.
 *
 * @param [in,out] Communication_p Communication module context.
 *
 * @retval E_SUCCESS                   After successful execution.
 * @retval E_FAILED_TO_INIT_COM_DEVICE Fail to initialize the communication
 *                                     device.
 */
ErrorCode_e A2_Network_Initialize(Communication_t *Communication_p);

/**
 * Shut down the A2 network layer.
 *
 * @param [in,out] Communication_p Communication module context.
 *
 * @retval  E_SUCCESS After successful execution.
 */
ErrorCode_e A2_Network_Shutdown(const Communication_t *const Communication_p);

/**
 * Cancel retransmission of packets.
 *
 * @param [in,out] Communication_p Communication module context.
 * @param [in]     UniqueKey       Unique key used for identification of packet
 *                                 for retransmission.
 *
 * @return none.
 */
ErrorCode_e A2_Network_CancelRetransmission(const Communication_t *const Communication_p, uint32 UniqueKey);

/**
 * Handler for received packets in A2 protocl family.
 *
 * This callback function handles the received packets.
 *
 * @param [in] Data_p  Pointer to the received data.
 * @param [in] Length  Length of the received data.
 * @param [in] Param_p Parameters;
 *
 * @return none.
 */
void A2_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);

/**
 * Handler function that is called after successful transmission
 * of a packet.
 *
 * If new packet is ready for transmitting it starts
 * the transmission of the packet.
 *
 * @param [in] Data_p  Pointer to the data for transmitting.
 * @param [in] Length  Length of the received data.
 * @param [in] Param_p Parameters.
 *
 * @return none.
 */
void A2_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);

/**
 * Handler for receiving new data.
 *
 * This function checks if new data has been received.
 *
 * @param [in,out] Communication_p Communication module context.
 *
 * @retval E_SUCCESS                    After successful execution.
 * @retval E_FAILED_TO_FIND_COMM_BUFFER Fail to allocate the communication buffer.
 */
ErrorCode_e A2_Network_ReceiverHandler(Communication_t *Communication_p);

/**
 * Handler for transmitting available packets.
 *
 * This function transmits packet from outgoing queue.
 *
 * @param [in,out] Communication_p Communication module context.
 *
 * @retval E_SUCCESS                    After successful execution.
 * @retval E_RETRANSMITION_FAILED       If packet sending fails.
 */
ErrorCode_e A2_Network_TransmiterHandler(Communication_t *Communication_p);

/**
 * Network packet allocation in A2 protocol family.
 *
 * @param [in,out] Communication_p Communication module context.
 * @param [in]     BufferSize      Size of buffer used for network packet.
 *
 * @retval Pointer Pointer to allocated packet meta info.
 * @retval NULL    if allocation fail.
 */
A2_PacketMeta_t *A2_Network_PacketAllocate(const Communication_t *const Communication_p, int BufferSize);

/**
 * Network packet release in A2 protocol family.
 *
 * @param [in,out] Communication_p Communication module context.
 * @param [in]     Meta_p          Meta info for used network packet.
 *
 * @retval E_SUCCESS                   Successful network packet release.
 * @retval E_INVALID_INPUT_PARAMETERS  Invalid input parameter.
 */
ErrorCode_e A2_Network_PacketRelease(const Communication_t *const Communication_p, A2_PacketMeta_t *Meta_p);

/** @} */
/** @} */
/** @} */
#endif /*_R_A2_NETWORK_H_*/