Example program for the C027Interface
Dependencies: C027Interface NetworkSocketAPI mbed
main.cpp
- Committer:
- sarahmarshy
- Date:
- 2015-07-27
- Revision:
- 21:979b1db5d7da
- Parent:
- 19:03f1da306347
- Child:
- 42:d8ea089e5606
File content as of revision 21:979b1db5d7da:
/* NetworkSocketAPI Example Program * Copyright (c) 2015 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "mbed.h" #include "ESP8266Interface.h" DigitalOut myled(LED1); ESP8266Interface wifi(D1, D0); int main() { printf("NetworkSocketAPI Example\r\n"); wifi.init(); wifi.connect("Buffalo-G-1280", "13808136"); char* ip; ip = wifi.getIPAddress(); if(ip!=NULL) printf("\nIP Address is: %s\n",ip); else printf("No IP"); char ip_goog[20]; wifi.getHostByName("google.com", ip_goog); printf("Got %s\n",ip_goog); /* SocketInterface* mySocket = wifi.allocateSocket(SOCK_TCP); mySocket->setAddressPort("192.168.13.5", 7); mySocket->open(); mySocket->send("hello",5,10000); char recieved[6]; recieved[5] = 0; int recv_amnt = mySocket->recv(recieved, 5, 10000); printf("Recieved: %d, %s\n",recv_amnt,recieved); mySocket->close(); */ wifi.disconnect(); while(1) { myled = !myled; } }