main.c
1.59 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
#include "libwismart.h"
#include "libwismart_irqs.h" /* implement irq handlers */
#include "lwip/inet.h"
#include "networkCallbacks.h"
#include "tcpClient.h"
#define WIFI_MODE WIFI_MODE_CLIENT
#define NETWORK_SSID "linksys"
#define NETWORK_KEY ""
#define SERVER_IP "192.168.1.11"
#define SERVER_PORT (55000)
void initLibwismart()
{
wismart_hwif_t hwif = libwismart_GetDefaultHWIF();
libwismart_Init(hwif);
}
static void wifi_connect_result_cb(int result)
{
DEBUG("WiFi Connect indication: %s\r\n", (result == WISMART_WIFI_CONNECTED) ? "Connected": "Failed");
}
int main(void)
{
wpa_param *wpa;
wpa->eap_method = WISMART_EAP_METHOD_PEAP;
wpa->peap.identity="smarcities";
wpa->peap.password="superpass";
initLibwismart();
libwismart_PowerSave_Enable();
libwismart_PowerSave_HigherProfile(TRUE);
libwismart_WiFiInit();
//falta definir les variables de la xarxa
libwismart_WiFiConnectEnterprise(NETWORK_SSID, wpa, wifi_connect_result_cb);
if(libwismart_IsConnected() == WISMART_NOT_CONNECTED)
{
printf("WiFi is not connected yet\n");
}
else if(libwismart_IsConnected() == WISMART_NOT_CONNECTED)
{
printf("WiFi connected, no IP connectivity yet\n");
}
else if(libwismart_IsConnected() == WISMART_CONNECT)
{
printf("WiFi connected, IP connection completed\n");
}
printWifiInfo(WIFI_MODE_CLIENT);
tcpClient_init();
tcpClient_establishConnectionL(SERVER_IP, SERVER_PORT);
printf("Hello, World!\n");
for(;;)
{
chThdSleepMilliseconds(500);
}
}