wifly/socket interface for wifly modules

Dependents:   WiFi neurGAI_WIFI thingspeak thingspeak2

Committer:
samux
Date:
Wed Aug 22 16:22:32 2012 +0000
Revision:
3:10b3866f0ea2
Parent:
0:6ffb0aeb3972
Child:
10:81445de1fe27
switched off dbg/can join ssid containing whitespace

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 3:10b3866f0ea2 1 /* Copyright (C) 2012 mbed.org, MIT License
samux 3:10b3866f0ea2 2 *
samux 3:10b3866f0ea2 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
samux 3:10b3866f0ea2 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
samux 3:10b3866f0ea2 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
samux 3:10b3866f0ea2 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
samux 3:10b3866f0ea2 7 * furnished to do so, subject to the following conditions:
samux 3:10b3866f0ea2 8 *
samux 3:10b3866f0ea2 9 * The above copyright notice and this permission notice shall be included in all copies or
samux 3:10b3866f0ea2 10 * substantial portions of the Software.
samux 3:10b3866f0ea2 11 *
samux 3:10b3866f0ea2 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
samux 3:10b3866f0ea2 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
samux 3:10b3866f0ea2 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
samux 3:10b3866f0ea2 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
samux 3:10b3866f0ea2 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
samux 3:10b3866f0ea2 17 */
samux 3:10b3866f0ea2 18 #include "Socket/Socket.h"
samux 3:10b3866f0ea2 19 #include "Socket/Endpoint.h"
samux 3:10b3866f0ea2 20 #include <cstring>
samux 3:10b3866f0ea2 21
samux 3:10b3866f0ea2 22 using std::memset;
samux 3:10b3866f0ea2 23
samux 3:10b3866f0ea2 24 Endpoint::Endpoint() {
samux 3:10b3866f0ea2 25 wifly = Wifly::getInstance();
samux 3:10b3866f0ea2 26 reset_address();
samux 3:10b3866f0ea2 27 }
samux 3:10b3866f0ea2 28 Endpoint::~Endpoint() {}
samux 3:10b3866f0ea2 29
samux 3:10b3866f0ea2 30 void Endpoint::reset_address(void) {
samux 3:10b3866f0ea2 31 _ipAddress[0] = '\0';
samux 3:10b3866f0ea2 32 _port = 0;
samux 3:10b3866f0ea2 33 }
samux 3:10b3866f0ea2 34
samux 3:10b3866f0ea2 35 int Endpoint::set_address(const char* host, const int port) {
samux 3:10b3866f0ea2 36 //Resolve DNS address or populate hard-coded IP address
samux 3:10b3866f0ea2 37 wifly->dnsLookup(host, _ipAddress);
samux 3:10b3866f0ea2 38 _port = port;
samux 3:10b3866f0ea2 39 return 0;
samux 3:10b3866f0ea2 40 }
samux 3:10b3866f0ea2 41
samux 3:10b3866f0ea2 42 char* Endpoint::get_address() {
samux 3:10b3866f0ea2 43 return _ipAddress;
samux 3:10b3866f0ea2 44 }
samux 3:10b3866f0ea2 45
samux 3:10b3866f0ea2 46 int Endpoint::get_port() {
samux 3:10b3866f0ea2 47 return _port;
samux 3:10b3866f0ea2 48 }