main.c 1.2 KB
#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);
	}
}