private fork
Fork of GSwifiInterface by
Diff: GSwifi/GSwifi.h
- Revision:
- 11:71d67fea5ace
- Parent:
- 10:7d8134e7df01
- Child:
- 12:057089026a20
--- a/GSwifi/GSwifi.h Thu Oct 31 08:34:45 2013 +0000 +++ b/GSwifi/GSwifi.h Fri Nov 15 04:20:14 2013 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 mbed.org, MIT License +/* Copyright (C) 2013 gsfan, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -21,9 +21,6 @@ * * http://www.gainspan.com/modules */ -/* Copyright (C) 2013 gsfan, MIT License - * port to the GainSpan Wi-FI module GS1011 - */ /** @file * @brief Gainspan wi-fi module library for mbed * GS1011MIC, GS1011MIP, GainSpan WiFi Breakout, etc. @@ -32,35 +29,19 @@ #ifndef GSwifi_H #define GSwifi_H +#include "GSwifi_conf.h" + #include "mbed.h" -#include "rtos.h" #include "RawSerial.h" #include "CBuffer.h" #include <ctype.h> #include <stdlib.h> #include <string.h> -//#define DEBUG - -#define DEFAULT_WAIT_RESP_TIMEOUT 500 -#define CFG_TIMEOUT 30000 // ms -#define CFG_CMD_SIZE 100 -#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) -#define CFG_DATA_SIZE 1024 -#elif defined(TARGET_LPC11U24) -#define CFG_DATA_SIZE 128 -#elif defined(TARGET_LPC4088) -#define CFG_DATA_SIZE 4096 +#ifdef CFG_ENABLE_RTOS +#include "rtos.h" #endif - -//#define CFG_UART_DIRECT -#define CFG_UART_BAUD 9600 -#define CFG_WREGDOMAIN 2 // 0:FCC, 1:ETSI, 2:TELEC -#define CFG_DHCPNAME "mbed-gswifi" -#define CFG_DNSNAME "setup.local" -#define MAX_TRY_JOIN 3 - #define MSG_TABLE_NUM 15 #define RES_TABLE_NUM 10 @@ -176,7 +157,7 @@ * @param phrase WEP or WPA key * @return 0 if connected, -1 otherwise */ - int join (Security sec, const char *ssid, const char *phrase); + int join (); /** Connect the wifi module to the adhock in the constructor. * @param sec Security type (NONE, WEP_128 or WPA) @@ -184,7 +165,7 @@ * @param phrase WEP or WPA key * @return 0 if connected, -1 otherwise */ - int adhock (Security sec, const char *ssid, const char *phrase); + int adhock (); /** Connect the wifi module to the limited AP in the constructor. * @param sec Security type (NONE, WEP_128 or WPA) @@ -192,7 +173,7 @@ * @param phrase WEP or WPA key * @return 0 if connected, -1 otherwise */ - int limitedap (Security sec, const char *ssid, const char *phrase); + int limitedap (); /** Disconnect the wifi module from the access point * @returns 0 if successful @@ -204,9 +185,12 @@ */ bool isConnected(); - int setSsid (Security sec, const char *ssid, const char *phrase); + void poll (); - void poll (); + int setAddress (const char *name = NULL); + int setAddress (const char *ip, const char *netmask, const char *gateway, const char *name = NULL); + int getAddress (char *ip, char *netmask, char *gateway); + int setSsid (Security sec, const char *ssid, const char *phrase); static GSwifi * getInstance() { return _inst; @@ -348,13 +332,13 @@ * @param cmd * @returns 0 if successful */ - int sendData(const char * data, int len, int timeout = DEFAULT_WAIT_RESP_TIMEOUT, const char * cmd = NULL); + int sendData(const char * data, int len, int timeout = CFG_TIMEOUT, const char * cmd = NULL); protected: static GSwifi * _inst; -#ifdef RTOS_H +#ifdef CFG_ENABLE_RTOS Thread *_threadPoll; Mutex _mutexUart; #endif @@ -389,13 +373,14 @@ bool dhcp; time_t time; + bool initialized; bool associated; volatile Mode mode; volatile Status status; bool escape; volatile bool ok, failure; volatile Response res; - int cid, acid; + int cid; int n; CircBuffer<char> *buf; } _state; @@ -414,7 +399,7 @@ // ----- GSwifi.cpp ----- -#ifdef RTOS_H +#ifdef CFG_ENABLE_RTOS static void threadPoll (void const *args); #endif