main.c
1.2 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
#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 "eConais"
#define NETWORK_KEY "!oTp0wer"
void initLibwismart()
{
wismart_hwif_t hwif = libwismart_GetDefaultHWIF();
libwismart_Init(hwif);
}
int main(void)
{
initLibwismart();
libwismart_PowerSave_Enable();
libwismart_PowerSave_HigherProfile(TRUE);
libwismart_WiFiInit();
//falta definir les variables de la xarxa
libwismart_WiFiConnect(NETWORK_SSID, NETWORK_KEY , clientMode_wifiConnectedCb);
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");
}
tcpClient_init();
tcpClient_establishConnectionL(SERVER_IP, SERVER_PORT);
printf("Hello, World!\n");
for(;;)
{
chThdSleepMilliseconds(500);
}
}