Repository navigation
Expand file tree
/
Copy pathnetwork_if.h
More file actions
176 lines (149 loc) · 7.15 KB
/
Copy pathnetwork_if.h
File metadata and controls
176 lines (149 loc) · 7.15 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//*****************************************************************************
// network_if.h
//
// Networking interface macro and function prototypes for CC32xx device
//
//*****************************************************************************
#ifndef __NETWORK_IF__H__
#define __NETWORK_IF__H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
/* Simplelink includes */
#include <ti/drivers/net/wifi/simplelink.h>
/* Values for below macros shall be modified as per access-point(AP) */
/* properties SimpleLink device will connect to following AP when application */
/* is executed. */
/* AP SSID */
#define SSID_NAME "embedded"//"WINTERMUTE" //your wifi name
/* Security type (OPEN or WEP or WPA) */
#define SECURITY_TYPE SL_WLAN_SEC_TYPE_WPA_WPA2
/* Password of the secured AP */
#define SECURITY_KEY "rover123"//"compelledcalculating" //your wifi password
#define SSID_AP_MODE "embedded"//"WINTERMUTE" //your wifi name
#define SEC_TYPE_AP_MODE SL_WLAN_SEC_TYPE_WPA_WPA2
#define PASSWORD_AP_MODE "rover123"//"compelledcalculating" //your wifi password
/* Loop forever, user can change it as per application's requirement */
#define LOOP_FOREVER() \
{ \
while(1) {; } \
}
/* check the error code and handle it */
#define ASSERT_ON_ERROR(error_code) \
{ \
if(error_code < 0) \
{ \
ERR_PRINT(error_code); \
return error_code; \
} \
}
#define SL_STOP_TIMEOUT 200
/* Status bits - used to set/reset the corresponding bits in given a variable */
typedef enum
{
/* If this bit is set: Network Processor is powered up */
STATUS_BIT_NWP_INIT = 0,
/* If this bit is set: the device is connected to the AP or client is */
/* connected to device (AP) */
STATUS_BIT_CONNECTION,
/* If this bit is set: the device has leased IP to any connected client. */
STATUS_BIT_IP_LEASED,
/* If this bit is set: the device has acquired an IP */
STATUS_BIT_IP_ACQUIRED,
/* If this bit is set: the SmartConfiguration process is started from */
/* SmartConfig app */
STATUS_BIT_SMARTCONFIG_START,
/* If this bit is set: the device (P2P mode) found any p2p-device in scan */
STATUS_BIT_P2P_DEV_FOUND,
/* If this bit is set: the device (P2P mode) found any p2p-negotiation */
/* request */
STATUS_BIT_P2P_REQ_RECEIVED,
/* If this bit is set: the device(P2P mode) connection to client (or */
/* reverse way) is failed */
STATUS_BIT_CONNECTION_FAILED,
/* If this bit is set: the device has completed the ping operation */
STATUS_BIT_PING_DONE,
/* If this bit is set: the device has acquired an IPv6 address. */
STATUS_BIT_IPV6L_ACQUIRED,
/* If this bit is set: the device has acquired an IPv6 address. */
STATUS_BIT_IPV6G_ACQUIRED,
STATUS_BIT_AUTHENTICATION_FAILED,
STATUS_BIT_RESET_REQUIRED,
}e_StatusBits;
#define CLR_STATUS_BIT_ALL(status_variable) (status_variable = 0)
#define SET_STATUS_BIT(status_variable, bit) (status_variable |= (1 << (bit)))
#define CLR_STATUS_BIT(status_variable, bit) (status_variable &= ~(1 << (bit)))
#define CLR_STATUS_BIT_ALL(status_variable) (status_variable = 0)
#define GET_STATUS_BIT(status_variable, bit) (0 != \
(status_variable & (1 << (bit))))
#define IS_CONNECTED(status_variable) GET_STATUS_BIT( \
status_variable, \
STATUS_BIT_CONNECTION)
#define IS_IP_ACQUIRED(status_variable) GET_STATUS_BIT( \
status_variable, \
STATUS_BIT_IP_ACQUIRED)
//*****************************************************************************
// APIs
//*****************************************************************************
long Network_IF_InitDriver(uint32_t uiMode);
long Network_IF_DeInitDriver(void);
long Network_IF_ConnectAP(char * pcSsid,
SlWlanSecParams_t SecurityParams);
long Network_IF_DisconnectFromAP();
long Network_IF_IpConfigGet(unsigned long *aucIP,
unsigned long *aucSubnetMask,
unsigned long *aucDefaultGateway,
unsigned long *aucDNSServer);
long Network_IF_GetHostIP(char* pcHostName,
unsigned long * pDestinationIP);
unsigned long Network_IF_CurrentMCUState(void);
void Network_IF_UnsetMCUMachineState(char stat);
void Network_IF_SetMCUMachineState(char stat);
void Network_IF_ResetMCUStateMachine(void);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __NETWORK_IF__H__