ESP8266 test with W7500. You can monitor UART Tx/RX of ESP8266.
Dependencies: ESP8266Interface
Fork of ESP8266_Test by
I tested ESD-01(ESP8266 module) with WIZwiki-W7500 platform as below.
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
Diff: main.cpp
- Revision:
- 0:6a891da014a3
- Child:
- 1:f61c1001ee60
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 24 19:02:13 2014 +0000 @@ -0,0 +1,149 @@ +#include "mbed.h" +#include "ESP8266Interface.h" +#include "nsdl_support.h" +#include "dbg.h" +#include "UDPSocket.h" +#include "Endpoint.h" + +// Include resources +#include "light.h" + +Serial pc(USBTX, USBRX); // tx, rx + +// **************************************************************************** +// Configuration section + + +// Ethernet configuration +/* Define this to enable DHCP, otherwise manual address configuration is used */ +#define DHCP + +/* Manual IP configurations, if DHCP not defined */ +#define IP "10.0.0.199" +#define MASK "255.255.255.0" +#define GW "10.0.0.1" + + +// NSP configuration +/* Change this IP address to that of your NanoService Platform installation */ +//static const char* NSP_ADDRESS = "191.239.5.150"; // barista2.cloudapp.net +static const char* NSP_ADDRESS = "108.201.184.41"; // smartobjectservice.com +//static const char* NSP_ADDRESS = "192.168.1.200"; // local mDS server +static const int NSP_PORT = 5683; +char endpoint_name[24] = "mbedDEMO-"; +uint8_t ep_type[] = {"DEMO"}; +uint8_t lifetime_ptr[] = {"60"}; + +// **************************************************************************** +// Ethernet initialization + + +ESP8266Interface wifi(PA_15,PB_7,PA_14,"demo","ARMDEMO1"); + + +static void ethernet_init() +{ + pc.printf("init\r\n"); + wifi.init(); // initialize the interface, reset the module + + pc.printf("join\r\n"); + wifi.join(); // join AP and get DHCP settings +} + +// **************************************************************************** +// NSP initialization + +UDPSocket server; +Endpoint nsp; +bool UDP_blocking = false; +unsigned int UDP_timeout = 100; + +uint8_t macbytes[6] = {0}; +char MAC[20] = "776655443322"; + +static void nsp_init() +{ + //pc.printf("socket init\r\n"); + server.init(); + //pc.printf("socket bind\r\n"); + server.bind(0); + pc.printf("set blocking option\r\n"); + server.set_blocking(UDP_blocking, UDP_timeout); + + pc.printf("set ep address\r\n"); + nsp.set_address(NSP_ADDRESS, NSP_PORT); + + strncat(endpoint_name, MAC, 12); + + NSDL_DEBUG("name: %s", endpoint_name); + NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT); + +} + +// **************************************************************************** +// Resource creation + +static int create_resources() +{ + sn_nsdl_resource_info_s *resource_ptr = NULL; + sn_nsdl_ep_parameters_s *endpoint_ptr = NULL; + + NSDL_DEBUG("Creating resources"); + + /* Create resources */ + resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s)); + if(!resource_ptr) + return 0; + memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s)); + + resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s)); + if(!resource_ptr->resource_parameters_ptr) + { + nsdl_free(resource_ptr); + return 0; + } + memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s)); + + // Static resources + nsdl_create_static_resource(resource_ptr, sizeof("3/0/0")-1, (uint8_t*) "3/0/0", 0, 0, (uint8_t*) "mbedDEMO", sizeof("mbedDEMO")-1); + nsdl_create_static_resource(resource_ptr, sizeof("3/0/1")-1, (uint8_t*) "3/0/1", 0, 0, (uint8_t*) "DEMO", sizeof("DEMO")-1); + + // Dynamic resources + create_light_resource(resource_ptr); + + /* Register with NSP */ + endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr); + if(sn_nsdl_register_endpoint(endpoint_ptr) != 0) + pc.printf("NSP registering failed\r\n"); + else + pc.printf("NSP registering OK\r\n"); + nsdl_clean_register_endpoint(&endpoint_ptr); + + nsdl_free(resource_ptr->resource_parameters_ptr); + nsdl_free(resource_ptr); + return 1; +} + +// **************************************************************************** +// Program entry point + +int main() +{ + pc.printf("SystemCoreClock=: %d\r\n", SystemCoreClock / 1000000) ; + NSDL_DEBUG("Hello mDS Demo Endpoint Application\n"); + + // Initialize Ethernet interface first + ethernet_init(); + + // Initialize NSP node + nsp_init(); + + // Initialize NSDL stack + nsdl_init(); + + // Create NSDL resources + create_resources(); + + // Run the NSDL event loop (never returns) + nsdl_event_loop(); +}