Network Services API  2.80.00.17
slnetconn.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*****************************************************************************/
34 /* Include files */
35 /*****************************************************************************/
36 
37 #ifndef __SL_NET_CONN_H__
38 #define __SL_NET_CONN_H__
39 
40 #include <stdint.h>
41 #include <stdbool.h>
42 
43 #include <ti/net/slnetsock.h>
44 #include <ti/net/slnetutils.h>
45 #include <ti/net/slneterr.h>
46 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
66 /*****************************************************************************/
67 /* Macro declarations */
68 /*****************************************************************************/
69 
72 /* Maximum number of NetIf supported */
73 #define SLNETCONN_NETWORK_INTERFACES_NUM 2
74 
75 /* Maximum number of Users supported */
76 #define SLNETCONN_USERS_NUM 8
77 
78 /* Enable/Disable Module's Logs
79  * Registration of a debug print callback will be required when enable
80  *
81  * \sa - SlNetConn_registerDebugCallback */
82 #define SLNETCONN_DEBUG_ENABLE (0)
83 
86 /*****************************************************************************/
87 /* Structure/Enum declarations */
88 /*****************************************************************************/
89 
90 typedef enum
91 {
96 
97 /* Note: SLNETCONN_STATUS_CONNECTED serves as a baseline for the CONNECTED statuses.
98  * It is equal to SLNETCONN_STATUS_CONNECTED_MAC (as SLNETCONN_SERVICE_LVL_MAC = 0).
99  * Note: Internet Connection is not maintained - it will be checked only upon the first
100  * connection, but the system will not identify if the access-point loses the Internet access.
101  * Users may check the connection periodically using SlNetConn_getStatus() (with
102  * bCheckInternetConnection set to true).
103  * User can also use socket error indication as the trigger for Internet access check.
104  */
105 typedef enum
106 {
114 
115 
116 
125 typedef void (*SlNetConn_AppEvent_f)(uint32_t ifID, SlNetConnStatus_e netStatus, void* data);
126 
136 typedef struct SlNetConn_config_t
137 {
138  uint32_t ifBitmap;
150  uint16_t serverAddrFamily;
155 
156 
165 typedef void (*SlNetConn_Debug_f)(const char * _format, ...);
166 
169 /*****************************************************************************/
170 /* Function prototypes */
171 /*****************************************************************************/
172 
189 int32_t SlNetConn_init(int32_t flags);
190 
206 
207 
249 int32_t SlNetConn_start(SlNetConnServiceLevel_e targetServiceLevel, SlNetConn_AppEvent_f fAppEventHdl,
250  uint32_t timeout, uint32_t flags);
251 
252 
270 int32_t SlNetConn_stop(SlNetConn_AppEvent_f fAppEventHdl);
271 
272 
296 int32_t SlNetConn_waitForConnection(SlNetConnServiceLevel_e targetServiceLevel, uint32_t timeout);
297 
312 int32_t SlNetConn_getStatus(bool bCheckInternetConnection, SlNetConnStatus_e *pStatus);
313 
326 void *SlNetConn_process(void* pvParameters);
327 
329 #if SLNETCONN_DEBUG_ENABLE
330 
338 void SlNetConn_registerDebugCallback(SlNetConn_Debug_f fDebugPrint);
339 #endif
340 
350 #ifdef __cplusplus
351 }
352 #endif /* __cplusplus */
353 
354 #endif /* __NET_CONN_H__ */
Definition: slnetconn.h:107
Definition: slnetconn.h:109
int32_t SlNetConn_waitForConnection(SlNetConnServiceLevel_e targetServiceLevel, uint32_t timeout)
Wait for connection (of specific target level) to be establish.
Definition: slnetconn.h:93
uint16_t serverAddrFamily
Definition: slnetconn.h:150
void(* SlNetConn_AppEvent_f)(uint32_t ifID, SlNetConnStatus_e netStatus, void *data)
Definition: slnetconn.h:125
void * SlNetConn_process(void *pvParameters)
SlNetConn_process callback - Connection manager thread, handles all connection requests.
uint32_t ifBitmap
Definition: slnetconn.h:138
Definition: slnetconn.h:108
struct SlNetConn_config_t SlNetConn_config_t
Global parameters and attributes used to establish connections.
Definition: slnetconn.h:110
Definition: slnetconn.h:92
int32_t SlNetConn_init(int32_t flags)
Initialize the SlNetConn module.
Definition: slnetconn.h:94
Definition: slnetconn.h:112
Definition: slnetconn.h:111
int32_t SlNetConn_stop(SlNetConn_AppEvent_f fAppEventHdl)
Remove user&#39;s connection request.
int32_t SlNetConn_getStatus(bool bCheckInternetConnection, SlNetConnStatus_e *pStatus)
Retrieve the current connection status.
int32_t SlNetConn_start(SlNetConnServiceLevel_e targetServiceLevel, SlNetConn_AppEvent_f fAppEventHdl, uint32_t timeout, uint32_t flags)
Request a connection (of specific target level) to be establish.
Global parameters and attributes used to establish connections.
Definition: slnetconn.h:136
char * pServerAddress
Definition: slnetconn.h:145
SlNetConnStatus_e
Definition: slnetconn.h:105
SlNetConnServiceLevel_e
Definition: slnetconn.h:90
int32_t SlNetConn_setConfiguration(SlNetConn_config_t *pConf)
Sets the SlNetConn global configuration parameters.
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale