private fork
Fork of GSwifiInterface by
GSwifiInterface.cpp@8:64184a968e3b, 2013-10-31 (annotated)
- Committer:
- gsfan
- Date:
- Thu Oct 31 06:41:45 2013 +0000
- Revision:
- 8:64184a968e3b
- Parent:
- 5:78943b3945b5
- Child:
- 11:71d67fea5ace
supported mbed RTOS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gsfan | 5:78943b3945b5 | 1 | /* Copyright (C) 2013 gsfan, MIT License |
gsfan | 5:78943b3945b5 | 2 | * port to the GainSpan Wi-FI module GS1011 |
gsfan | 5:78943b3945b5 | 3 | */ |
gsfan | 5:78943b3945b5 | 4 | |
gsfan | 5:78943b3945b5 | 5 | #include "GSwifiInterface.h" |
gsfan | 5:78943b3945b5 | 6 | |
gsfan | 8:64184a968e3b | 7 | GSwifiInterface::GSwifiInterface( PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud) : |
gsfan | 8:64184a968e3b | 8 | GSwifi(tx, rx, cts, rts, reset, alarm, baud) |
gsfan | 5:78943b3945b5 | 9 | { |
gsfan | 5:78943b3945b5 | 10 | } |
gsfan | 5:78943b3945b5 | 11 | |
gsfan | 8:64184a968e3b | 12 | int GSwifiInterface::init(const char* name) |
gsfan | 5:78943b3945b5 | 13 | { |
gsfan | 5:78943b3945b5 | 14 | _state.dhcp = true; |
gsfan | 8:64184a968e3b | 15 | strncpy(_state.name, name, sizeof(_state.name)); |
gsfan | 5:78943b3945b5 | 16 | |
gsfan | 5:78943b3945b5 | 17 | return 0; |
gsfan | 5:78943b3945b5 | 18 | } |
gsfan | 5:78943b3945b5 | 19 | |
gsfan | 8:64184a968e3b | 20 | int GSwifiInterface::init(const char* ip, const char* mask, const char* gateway, const char* name) |
gsfan | 5:78943b3945b5 | 21 | { |
gsfan | 8:64184a968e3b | 22 | _state.dhcp = false; |
gsfan | 8:64184a968e3b | 23 | strncpy(_state.ip, ip, sizeof(_state.ip)); |
gsfan | 8:64184a968e3b | 24 | strncpy(_state.netmask, mask, sizeof(_state.netmask)); |
gsfan | 8:64184a968e3b | 25 | strncpy(_state.gateway, gateway, sizeof(_state.gateway)); |
gsfan | 8:64184a968e3b | 26 | strncpy(_state.name, name, sizeof(_state.name)); |
gsfan | 8:64184a968e3b | 27 | |
gsfan | 8:64184a968e3b | 28 | return 0; |
gsfan | 8:64184a968e3b | 29 | } |
gsfan | 8:64184a968e3b | 30 | |
gsfan | 8:64184a968e3b | 31 | int GSwifiInterface::connect(Security sec, const char* ssid, const char* phrase, WiFiMode mode) |
gsfan | 8:64184a968e3b | 32 | { |
gsfan | 8:64184a968e3b | 33 | switch (mode) { |
gsfan | 8:64184a968e3b | 34 | case WM_INFRASTRUCTURE: |
gsfan | 8:64184a968e3b | 35 | return join(sec, ssid, phrase); |
gsfan | 8:64184a968e3b | 36 | case WM_ADHOCK: |
gsfan | 8:64184a968e3b | 37 | return adhock(sec, ssid, phrase); |
gsfan | 8:64184a968e3b | 38 | case WM_LIMITEDAP: |
gsfan | 8:64184a968e3b | 39 | return limitedap(sec, ssid, phrase); |
gsfan | 8:64184a968e3b | 40 | } |
gsfan | 8:64184a968e3b | 41 | return -1; |
gsfan | 5:78943b3945b5 | 42 | } |
gsfan | 5:78943b3945b5 | 43 | |
gsfan | 5:78943b3945b5 | 44 | int GSwifiInterface::disconnect() |
gsfan | 5:78943b3945b5 | 45 | { |
gsfan | 5:78943b3945b5 | 46 | return GSwifi::disconnect(); |
gsfan | 5:78943b3945b5 | 47 | } |
gsfan | 5:78943b3945b5 | 48 | |
gsfan | 8:64184a968e3b | 49 | char * GSwifiInterface::getMACAddress() |
gsfan | 8:64184a968e3b | 50 | { |
gsfan | 8:64184a968e3b | 51 | return _state.mac; |
gsfan | 8:64184a968e3b | 52 | } |
gsfan | 8:64184a968e3b | 53 | |
gsfan | 5:78943b3945b5 | 54 | char * GSwifiInterface::getIPAddress() |
gsfan | 5:78943b3945b5 | 55 | { |
gsfan | 8:64184a968e3b | 56 | return _state.ip; |
gsfan | 8:64184a968e3b | 57 | } |
gsfan | 5:78943b3945b5 | 58 | |
gsfan | 8:64184a968e3b | 59 | char * GSwifiInterface::getGateway() |
gsfan | 8:64184a968e3b | 60 | { |
gsfan | 8:64184a968e3b | 61 | return _state.gateway; |
gsfan | 8:64184a968e3b | 62 | } |
gsfan | 8:64184a968e3b | 63 | |
gsfan | 8:64184a968e3b | 64 | char * GSwifiInterface::getNetworkMask() |
gsfan | 8:64184a968e3b | 65 | { |
gsfan | 8:64184a968e3b | 66 | return _state.netmask; |
gsfan | 8:64184a968e3b | 67 | } |