ESP8266 test with W7500. You can monitor UART Tx/RX of ESP8266.

Dependencies:   ESP8266Interface

Fork of ESP8266_Test by ESP8266

I tested ESD-01(ESP8266 module) with WIZwiki-W7500 platform as below. /media/uploads/SteveKim/esd01.jpg

You can see the all log of this test as below. And with this ESP8266Interface class, you can monitor Tx/Rx of ESP8266 module UART.

WIZwiki-W7500 with ESP8266 Test. 
AT

OK
AT+RST

OK

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 612, room 16 
tail 4
chksum 0x12
load 0x3ffe8000, len 788, room 4 
tail 0
chksum 0x50
load 0x3ffe8314, len 264, room 8 
tail 0
chksum 0x4a
csum 0x4a

2nd boot version : 1.1
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size : 4Mbit
jump to run user1

s
ready
AT+CWDHCP=1,1

OK
AT+CWMODE=1

OK
AT+CWJAP="WizFiDemoAP","12345678"

OK
AT+CIPSTART="TCP","192.168.3.64",8000
CONNECT

OK
AT+CIPMODE=1

OK
AT+CIPSEND

>AT+CIPCLOSE
CLOSED

OK
Committer:
michaeljkoster
Date:
Wed Dec 24 19:02:13 2014 +0000
Revision:
0:6a891da014a3
Child:
1:f61c1001ee60
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
michaeljkoster 0:6a891da014a3 1 #include "mbed.h"
michaeljkoster 0:6a891da014a3 2 #include "ESP8266Interface.h"
michaeljkoster 0:6a891da014a3 3 #include "nsdl_support.h"
michaeljkoster 0:6a891da014a3 4 #include "dbg.h"
michaeljkoster 0:6a891da014a3 5 #include "UDPSocket.h"
michaeljkoster 0:6a891da014a3 6 #include "Endpoint.h"
michaeljkoster 0:6a891da014a3 7
michaeljkoster 0:6a891da014a3 8 // Include resources
michaeljkoster 0:6a891da014a3 9 #include "light.h"
michaeljkoster 0:6a891da014a3 10
michaeljkoster 0:6a891da014a3 11 Serial pc(USBTX, USBRX); // tx, rx
michaeljkoster 0:6a891da014a3 12
michaeljkoster 0:6a891da014a3 13 // ****************************************************************************
michaeljkoster 0:6a891da014a3 14 // Configuration section
michaeljkoster 0:6a891da014a3 15
michaeljkoster 0:6a891da014a3 16
michaeljkoster 0:6a891da014a3 17 // Ethernet configuration
michaeljkoster 0:6a891da014a3 18 /* Define this to enable DHCP, otherwise manual address configuration is used */
michaeljkoster 0:6a891da014a3 19 #define DHCP
michaeljkoster 0:6a891da014a3 20
michaeljkoster 0:6a891da014a3 21 /* Manual IP configurations, if DHCP not defined */
michaeljkoster 0:6a891da014a3 22 #define IP "10.0.0.199"
michaeljkoster 0:6a891da014a3 23 #define MASK "255.255.255.0"
michaeljkoster 0:6a891da014a3 24 #define GW "10.0.0.1"
michaeljkoster 0:6a891da014a3 25
michaeljkoster 0:6a891da014a3 26
michaeljkoster 0:6a891da014a3 27 // NSP configuration
michaeljkoster 0:6a891da014a3 28 /* Change this IP address to that of your NanoService Platform installation */
michaeljkoster 0:6a891da014a3 29 //static const char* NSP_ADDRESS = "191.239.5.150"; // barista2.cloudapp.net
michaeljkoster 0:6a891da014a3 30 static const char* NSP_ADDRESS = "108.201.184.41"; // smartobjectservice.com
michaeljkoster 0:6a891da014a3 31 //static const char* NSP_ADDRESS = "192.168.1.200"; // local mDS server
michaeljkoster 0:6a891da014a3 32 static const int NSP_PORT = 5683;
michaeljkoster 0:6a891da014a3 33 char endpoint_name[24] = "mbedDEMO-";
michaeljkoster 0:6a891da014a3 34 uint8_t ep_type[] = {"DEMO"};
michaeljkoster 0:6a891da014a3 35 uint8_t lifetime_ptr[] = {"60"};
michaeljkoster 0:6a891da014a3 36
michaeljkoster 0:6a891da014a3 37 // ****************************************************************************
michaeljkoster 0:6a891da014a3 38 // Ethernet initialization
michaeljkoster 0:6a891da014a3 39
michaeljkoster 0:6a891da014a3 40
michaeljkoster 0:6a891da014a3 41 ESP8266Interface wifi(PA_15,PB_7,PA_14,"demo","ARMDEMO1");
michaeljkoster 0:6a891da014a3 42
michaeljkoster 0:6a891da014a3 43
michaeljkoster 0:6a891da014a3 44 static void ethernet_init()
michaeljkoster 0:6a891da014a3 45 {
michaeljkoster 0:6a891da014a3 46 pc.printf("init\r\n");
michaeljkoster 0:6a891da014a3 47 wifi.init(); // initialize the interface, reset the module
michaeljkoster 0:6a891da014a3 48
michaeljkoster 0:6a891da014a3 49 pc.printf("join\r\n");
michaeljkoster 0:6a891da014a3 50 wifi.join(); // join AP and get DHCP settings
michaeljkoster 0:6a891da014a3 51 }
michaeljkoster 0:6a891da014a3 52
michaeljkoster 0:6a891da014a3 53 // ****************************************************************************
michaeljkoster 0:6a891da014a3 54 // NSP initialization
michaeljkoster 0:6a891da014a3 55
michaeljkoster 0:6a891da014a3 56 UDPSocket server;
michaeljkoster 0:6a891da014a3 57 Endpoint nsp;
michaeljkoster 0:6a891da014a3 58 bool UDP_blocking = false;
michaeljkoster 0:6a891da014a3 59 unsigned int UDP_timeout = 100;
michaeljkoster 0:6a891da014a3 60
michaeljkoster 0:6a891da014a3 61 uint8_t macbytes[6] = {0};
michaeljkoster 0:6a891da014a3 62 char MAC[20] = "776655443322";
michaeljkoster 0:6a891da014a3 63
michaeljkoster 0:6a891da014a3 64 static void nsp_init()
michaeljkoster 0:6a891da014a3 65 {
michaeljkoster 0:6a891da014a3 66 //pc.printf("socket init\r\n");
michaeljkoster 0:6a891da014a3 67 server.init();
michaeljkoster 0:6a891da014a3 68 //pc.printf("socket bind\r\n");
michaeljkoster 0:6a891da014a3 69 server.bind(0);
michaeljkoster 0:6a891da014a3 70 pc.printf("set blocking option\r\n");
michaeljkoster 0:6a891da014a3 71 server.set_blocking(UDP_blocking, UDP_timeout);
michaeljkoster 0:6a891da014a3 72
michaeljkoster 0:6a891da014a3 73 pc.printf("set ep address\r\n");
michaeljkoster 0:6a891da014a3 74 nsp.set_address(NSP_ADDRESS, NSP_PORT);
michaeljkoster 0:6a891da014a3 75
michaeljkoster 0:6a891da014a3 76 strncat(endpoint_name, MAC, 12);
michaeljkoster 0:6a891da014a3 77
michaeljkoster 0:6a891da014a3 78 NSDL_DEBUG("name: %s", endpoint_name);
michaeljkoster 0:6a891da014a3 79 NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
michaeljkoster 0:6a891da014a3 80
michaeljkoster 0:6a891da014a3 81 }
michaeljkoster 0:6a891da014a3 82
michaeljkoster 0:6a891da014a3 83 // ****************************************************************************
michaeljkoster 0:6a891da014a3 84 // Resource creation
michaeljkoster 0:6a891da014a3 85
michaeljkoster 0:6a891da014a3 86 static int create_resources()
michaeljkoster 0:6a891da014a3 87 {
michaeljkoster 0:6a891da014a3 88 sn_nsdl_resource_info_s *resource_ptr = NULL;
michaeljkoster 0:6a891da014a3 89 sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
michaeljkoster 0:6a891da014a3 90
michaeljkoster 0:6a891da014a3 91 NSDL_DEBUG("Creating resources");
michaeljkoster 0:6a891da014a3 92
michaeljkoster 0:6a891da014a3 93 /* Create resources */
michaeljkoster 0:6a891da014a3 94 resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
michaeljkoster 0:6a891da014a3 95 if(!resource_ptr)
michaeljkoster 0:6a891da014a3 96 return 0;
michaeljkoster 0:6a891da014a3 97 memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
michaeljkoster 0:6a891da014a3 98
michaeljkoster 0:6a891da014a3 99 resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
michaeljkoster 0:6a891da014a3 100 if(!resource_ptr->resource_parameters_ptr)
michaeljkoster 0:6a891da014a3 101 {
michaeljkoster 0:6a891da014a3 102 nsdl_free(resource_ptr);
michaeljkoster 0:6a891da014a3 103 return 0;
michaeljkoster 0:6a891da014a3 104 }
michaeljkoster 0:6a891da014a3 105 memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
michaeljkoster 0:6a891da014a3 106
michaeljkoster 0:6a891da014a3 107 // Static resources
michaeljkoster 0:6a891da014a3 108 nsdl_create_static_resource(resource_ptr, sizeof("3/0/0")-1, (uint8_t*) "3/0/0", 0, 0, (uint8_t*) "mbedDEMO", sizeof("mbedDEMO")-1);
michaeljkoster 0:6a891da014a3 109 nsdl_create_static_resource(resource_ptr, sizeof("3/0/1")-1, (uint8_t*) "3/0/1", 0, 0, (uint8_t*) "DEMO", sizeof("DEMO")-1);
michaeljkoster 0:6a891da014a3 110
michaeljkoster 0:6a891da014a3 111 // Dynamic resources
michaeljkoster 0:6a891da014a3 112 create_light_resource(resource_ptr);
michaeljkoster 0:6a891da014a3 113
michaeljkoster 0:6a891da014a3 114 /* Register with NSP */
michaeljkoster 0:6a891da014a3 115 endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
michaeljkoster 0:6a891da014a3 116 if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
michaeljkoster 0:6a891da014a3 117 pc.printf("NSP registering failed\r\n");
michaeljkoster 0:6a891da014a3 118 else
michaeljkoster 0:6a891da014a3 119 pc.printf("NSP registering OK\r\n");
michaeljkoster 0:6a891da014a3 120 nsdl_clean_register_endpoint(&endpoint_ptr);
michaeljkoster 0:6a891da014a3 121
michaeljkoster 0:6a891da014a3 122 nsdl_free(resource_ptr->resource_parameters_ptr);
michaeljkoster 0:6a891da014a3 123 nsdl_free(resource_ptr);
michaeljkoster 0:6a891da014a3 124 return 1;
michaeljkoster 0:6a891da014a3 125 }
michaeljkoster 0:6a891da014a3 126
michaeljkoster 0:6a891da014a3 127 // ****************************************************************************
michaeljkoster 0:6a891da014a3 128 // Program entry point
michaeljkoster 0:6a891da014a3 129
michaeljkoster 0:6a891da014a3 130 int main()
michaeljkoster 0:6a891da014a3 131 {
michaeljkoster 0:6a891da014a3 132 pc.printf("SystemCoreClock=: %d\r\n", SystemCoreClock / 1000000) ;
michaeljkoster 0:6a891da014a3 133 NSDL_DEBUG("Hello mDS Demo Endpoint Application\n");
michaeljkoster 0:6a891da014a3 134
michaeljkoster 0:6a891da014a3 135 // Initialize Ethernet interface first
michaeljkoster 0:6a891da014a3 136 ethernet_init();
michaeljkoster 0:6a891da014a3 137
michaeljkoster 0:6a891da014a3 138 // Initialize NSP node
michaeljkoster 0:6a891da014a3 139 nsp_init();
michaeljkoster 0:6a891da014a3 140
michaeljkoster 0:6a891da014a3 141 // Initialize NSDL stack
michaeljkoster 0:6a891da014a3 142 nsdl_init();
michaeljkoster 0:6a891da014a3 143
michaeljkoster 0:6a891da014a3 144 // Create NSDL resources
michaeljkoster 0:6a891da014a3 145 create_resources();
michaeljkoster 0:6a891da014a3 146
michaeljkoster 0:6a891da014a3 147 // Run the NSDL event loop (never returns)
michaeljkoster 0:6a891da014a3 148 nsdl_event_loop();
michaeljkoster 0:6a891da014a3 149 }