#include "libwismart.h" #include "libwismart_irqs.h" /* implement irq handlers */ #include "lwip/inet.h" #include "globals.h" #include "httpClient.h" #include "callbacks.h" #include "buffer.h" #define WIFI_MODE WIFI_MODE_CLIENT #define NETWORK_SSID "linksys" #define NETWORK_KEY "" #define WPA_USER "smartcities" #define WPA_PASS "superpass" void initLibwismart(void) { wismart_hwif_t hwif = libwismart_GetDefaultHWIF(); libwismart_Init(hwif); } int main(void) { //WPA (RADIUS) /* struct wpa_param wpa; wpa.eap_method = WISMART_EAP_METHOD_TTLS; wpa.u.ttls.identity=WPA_USER; wpa.u.ttls.password=WPA_PASS; wpa.u.ttls.ca_cert=NULL; */ //NO SECURITY (HOTSPOT) /**/ /*GET / HTTP/1.1 Host: www.upc.edu*/ struct httpHeaders head200 = { get, "/", 1, "www.upc.edu", 11 }; /*GET / HTTP/1.1 Host: upc.edu*/ struct httpHeaders head301 = { get, "/", 1, "upc.edu", 7 }; /*GET /errorerror HTTP/1.1 Host: www.upc.edu*/ struct httpHeaders head404 = { get, "/errorerrorerror", 15, "www.upc.edu", 11 }; initLibwismart(); libwismart_PowerSave_Enable(); libwismart_PowerSave_HigherProfile(TRUE); printf("\r\n\r\n,------------------.\r\n"); printf("| GRUP ARM DE PAET |\r\n"); printf("`------------------'\r\n"); libwismart_RegisterDhcpCB(dhcp_connect_result_cb); libwismart_WiFiInit(); //falta definir les variables de la xarxa /* // WPA (RADIUS) libwismart_WiFiConnectEnterprise(NETWORK_SSID, &wpa, wifi_connect_result_cb); */ // NO Security (hotspot) libwismart_WiFiConnect("ARMwifi",NULL, wifi_connect_result_cb); libwismart_EnableBsdSocketAPI(); //chThdSleepMilliseconds(5000); DBG("HTTP Request expected to receive code 200 OK"); httpRequest(head200, NULL, 0); DBG("HTTP Request expected to receive code 301 OK"); httpRequest(head301, NULL, 0); DBG("HTTP Request expected to receive code 404 OK"); httpRequest(head404, NULL, 0); /* for(;;) { // i2c get info= data char* data=NULL; put_message(data, buffer ,&ind); int res=check_memory(); if(res==SOFT_REACHED){ int ok=send(buffer, ind, "", ""); if(ok==JSON_COMM_ERROR) { printf("wismart is not connected\r\n"); } else if( ok==JSON_OTHER_ERROR){ printf("some error ocurred\r\n"); } else if(ok ==JSON_POST_OK){ printf(" send OK \r\n"); } } else if(res==HARD_REACHED){ destroy(buffer); } chThdSleepMilliseconds(500); }*/ return 0; } /* # # WiSmart Applications Makefile # # Copyright 2012 eConais S.A # # Set the sdk root folder SDK_ROOT = ../../ PROJECT_OUT = smartcities USER_SRC = main.c httpClient.c callbacks.c module.c sensors.c json.c i2c.c buffer.c USER_INCDIR = include/ # if you need to add build Defines options add to USER_DEFS define #USER_DEFS += -D # select SDK's version: SDK_VERSION = SDK_REV_9_2 # select the MCU type e.g. STM32F1, STM32F4 PLAT = STM32F1 # select the MCU flash/ram size e.g. MCU_386K_64K, MCU_768K_96K, MCU_1M_96K MCU_SIZE = MCU_768K_96K USER_DEFS += -D$(SDK_VERSION) # this must be the last include include $(SDK_ROOT)/applications/rules.mk */