Socket interface for ESP8266. Implements the NetworkSocketAPI. Requires device to use the Espressif Firmware.

Dependencies:   ESP8266

Dependents:   ESP8266InterfaceTests HelloESP8266Interface

Fork of ESP8266Interface by NetworkSocketAPI

Note

This library assumes your ESP8266 is running the Espressif Firmware. For instructions on how to update your ESP8266 to use the correct firmware see the Firmware Update Wiki Page.

Currently the ESP8266Interface LIbrary has the following Abilities:

Working

  • TCP Client
  • UDP Client
  • Transparent mode (single connection of 1 type at a time)
  • Station Mode (connects to AP)

To be implimented

  • TCP Server
  • UDP Server
  • Multi Connection Mode (able to have up to 5 sockets at a time)
  • AP Mode (Make ESP Chip act like access point)
  • DNS Support (currently websites must be looked up by IP)
  • Error Recovery

Nice but not necessary

  • colorized text for ESP AT Commands in Command line (easier to differentiate from other text)
Committer:
sam_grove
Date:
Wed Jun 17 23:38:01 2015 +0000
Revision:
13:0186e9e35a24
Parent:
12:8db9b116cf76
Child:
15:d29439d50306
add socket implementations

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 12:8db9b116cf76 1 /* WiFiRadioInterface Example
sam_grove 11:288c15b80a26 2 * Copyright (c) 2015 ARM Limited
sam_grove 11:288c15b80a26 3 *
sam_grove 11:288c15b80a26 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 11:288c15b80a26 5 * you may not use this file except in compliance with the License.
sam_grove 11:288c15b80a26 6 * You may obtain a copy of the License at
sam_grove 11:288c15b80a26 7 *
sam_grove 11:288c15b80a26 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 11:288c15b80a26 9 *
sam_grove 11:288c15b80a26 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 11:288c15b80a26 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 11:288c15b80a26 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 11:288c15b80a26 13 * See the License for the specific language governing permissions and
sam_grove 11:288c15b80a26 14 * limitations under the License.
sam_grove 11:288c15b80a26 15 */
sam_grove 11:288c15b80a26 16
sam_grove 11:288c15b80a26 17 #include "WiFiRadioInterface.h"
sam_grove 11:288c15b80a26 18
sam_grove 11:288c15b80a26 19 WiFiRadioInterface::WiFiRadioInterface()
sam_grove 11:288c15b80a26 20 {
sam_grove 11:288c15b80a26 21
sam_grove 11:288c15b80a26 22 }
sam_grove 11:288c15b80a26 23
sam_grove 11:288c15b80a26 24 WiFiRadioInterface::WiFiRadioInterface(const char *ap, const char *pass_phrase, wifi_security_t security, uint32_t timeout_ms)
sam_grove 11:288c15b80a26 25 {
sam_grove 11:288c15b80a26 26
sam_grove 11:288c15b80a26 27 }
sam_grove 11:288c15b80a26 28
sam_grove 11:288c15b80a26 29 int32_t WiFiRadioInterface::init(void) const
sam_grove 11:288c15b80a26 30 {
sam_grove 11:288c15b80a26 31 return -1;
sam_grove 11:288c15b80a26 32 }
sam_grove 11:288c15b80a26 33
sam_grove 11:288c15b80a26 34 int32_t WiFiRadioInterface::init(const char *ip, const char *mask, const char *gateway) const
sam_grove 11:288c15b80a26 35 {
sam_grove 11:288c15b80a26 36 return -1;
sam_grove 11:288c15b80a26 37 }
sam_grove 11:288c15b80a26 38
sam_grove 11:288c15b80a26 39 int32_t WiFiRadioInterface::connect(uint32_t timeout_ms) const
sam_grove 11:288c15b80a26 40 {
sam_grove 11:288c15b80a26 41 return -1;
sam_grove 11:288c15b80a26 42 }
sam_grove 11:288c15b80a26 43
sam_grove 11:288c15b80a26 44 int32_t WiFiRadioInterface::connect(const char *ap, const char *pass_phrase, wifi_security_t security, uint32_t timeout_ms) const
sam_grove 11:288c15b80a26 45 {
sam_grove 11:288c15b80a26 46 return -1;
sam_grove 11:288c15b80a26 47 }
sam_grove 11:288c15b80a26 48
sam_grove 11:288c15b80a26 49 int32_t WiFiRadioInterface::disconnect(void) const
sam_grove 11:288c15b80a26 50 {
sam_grove 11:288c15b80a26 51 return -1;
sam_grove 11:288c15b80a26 52 }
sam_grove 11:288c15b80a26 53
sam_grove 11:288c15b80a26 54 char *WiFiRadioInterface::getIPAddress(void) const
sam_grove 11:288c15b80a26 55 {
sam_grove 11:288c15b80a26 56 return 0;
sam_grove 11:288c15b80a26 57 }
sam_grove 11:288c15b80a26 58
sam_grove 11:288c15b80a26 59 char *WiFiRadioInterface::getGateway(void) const
sam_grove 11:288c15b80a26 60 {
sam_grove 11:288c15b80a26 61 return 0;
sam_grove 11:288c15b80a26 62 }
sam_grove 11:288c15b80a26 63
sam_grove 11:288c15b80a26 64 char *WiFiRadioInterface::getNetworkMask(void) const
sam_grove 11:288c15b80a26 65 {
sam_grove 11:288c15b80a26 66 return 0;
sam_grove 11:288c15b80a26 67 }
sam_grove 11:288c15b80a26 68
sam_grove 11:288c15b80a26 69 char *WiFiRadioInterface::getMACAddress(void) const
sam_grove 11:288c15b80a26 70 {
sam_grove 11:288c15b80a26 71 return 0;
sam_grove 11:288c15b80a26 72 }
sam_grove 11:288c15b80a26 73
sam_grove 11:288c15b80a26 74 int32_t WiFiRadioInterface::isConnected(void) const
sam_grove 11:288c15b80a26 75 {
sam_grove 11:288c15b80a26 76 return -1;
sam_grove 11:288c15b80a26 77 }
sam_grove 13:0186e9e35a24 78
sam_grove 13:0186e9e35a24 79 const char *WiFiRadioInterface::get_host_by_name(const char *name) const
sam_grove 13:0186e9e35a24 80 {
sam_grove 13:0186e9e35a24 81 return 0;
sam_grove 13:0186e9e35a24 82 }
sam_grove 13:0186e9e35a24 83
sam_grove 13:0186e9e35a24 84 int32_t WiFiRadioInterface::set_address(const char* addr) const
sam_grove 13:0186e9e35a24 85 {
sam_grove 13:0186e9e35a24 86 return -1;
sam_grove 13:0186e9e35a24 87 }
sam_grove 13:0186e9e35a24 88
sam_grove 13:0186e9e35a24 89 int32_t WiFiRadioInterface::set_port(uint16_t port) const
sam_grove 13:0186e9e35a24 90 {
sam_grove 13:0186e9e35a24 91 return -1;
sam_grove 13:0186e9e35a24 92 }
sam_grove 13:0186e9e35a24 93
sam_grove 13:0186e9e35a24 94 int32_t WiFiRadioInterface::set_address_port(const char* addr, uint16_t port) const
sam_grove 13:0186e9e35a24 95 {
sam_grove 13:0186e9e35a24 96 return -1;
sam_grove 13:0186e9e35a24 97 }
sam_grove 13:0186e9e35a24 98
sam_grove 13:0186e9e35a24 99 const char *WiFiRadioInterface::get_address(void) const
sam_grove 13:0186e9e35a24 100 {
sam_grove 13:0186e9e35a24 101 return 0;
sam_grove 13:0186e9e35a24 102 }
sam_grove 13:0186e9e35a24 103
sam_grove 13:0186e9e35a24 104 uint16_t WiFiRadioInterface::get_port(void) const
sam_grove 13:0186e9e35a24 105 {
sam_grove 13:0186e9e35a24 106 return 0;
sam_grove 13:0186e9e35a24 107 }
sam_grove 13:0186e9e35a24 108
sam_grove 13:0186e9e35a24 109 int32_t WiFiRadioInterface::bind(uint16_t port) const
sam_grove 13:0186e9e35a24 110 {
sam_grove 13:0186e9e35a24 111 return -1;
sam_grove 13:0186e9e35a24 112 }
sam_grove 13:0186e9e35a24 113
sam_grove 13:0186e9e35a24 114 int32_t WiFiRadioInterface::listen(void) const
sam_grove 13:0186e9e35a24 115 {
sam_grove 13:0186e9e35a24 116 return -1;
sam_grove 13:0186e9e35a24 117 }
sam_grove 13:0186e9e35a24 118
sam_grove 13:0186e9e35a24 119 int32_t WiFiRadioInterface::accept(const Endpoint &endpoint) const
sam_grove 13:0186e9e35a24 120 {
sam_grove 13:0186e9e35a24 121 return -1;
sam_grove 13:0186e9e35a24 122 }
sam_grove 13:0186e9e35a24 123
sam_grove 13:0186e9e35a24 124 int32_t WiFiRadioInterface::connect(const Endpoint &endpoint) const
sam_grove 13:0186e9e35a24 125 {
sam_grove 13:0186e9e35a24 126 return -1;
sam_grove 13:0186e9e35a24 127 }
sam_grove 13:0186e9e35a24 128
sam_grove 13:0186e9e35a24 129 int32_t WiFiRadioInterface::send(const void *data, uint32_t amount, uint32_t timeout_ms) const
sam_grove 13:0186e9e35a24 130 {
sam_grove 13:0186e9e35a24 131 return -1;
sam_grove 13:0186e9e35a24 132 }
sam_grove 13:0186e9e35a24 133
sam_grove 13:0186e9e35a24 134 uint32_t WiFiRadioInterface::recv(const void *data, uint32_t amount, uint32_t timeout_ms) const
sam_grove 13:0186e9e35a24 135 {
sam_grove 13:0186e9e35a24 136 return 0;
sam_grove 13:0186e9e35a24 137 }
sam_grove 13:0186e9e35a24 138
sam_grove 13:0186e9e35a24 139 int32_t WiFiRadioInterface::close(const Endpoint &endpoint) const
sam_grove 13:0186e9e35a24 140 {
sam_grove 13:0186e9e35a24 141 return -1;
sam_grove 13:0186e9e35a24 142 }