main.c 1.55 KB


#include "libwismart.h"
#include "libwismart_irqs.h" /* implement irq handlers */
#include "lwip/inet.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(void)
{
	wismart_hwif_t hwif = libwismart_GetDefaultHWIF();
	libwismart_Init(hwif);
}

static void wifi_connect_result_cb(int result)
{
    printf("WiFi Connect indication: %s\r\n", (result == WISMART_WIFI_CONNECTED) ? "Connected": "Failed");


}

int main(void)
{
	struct wpa_param *wpa;
	wpa->eap_method = WISMART_EAP_METHOD_PEAP;
	wpa->u.ttls.identity="smarcities";
	wpa->u.ttls.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_CONNECTED)
	{
		printf("WiFi connected, IP connection completed\n");
	}

	

	//tcpClient_init();

	//tcpClient_establishConnectionL(SERVER_IP, SERVER_PORT);

	printf("Hello, World!\n");

	for(;;)
	{
		chThdSleepMilliseconds(500);
	}
}