HoYa's MBED (Nucleo-F401RE)
Dependencies: NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed
main.cpp
- Committer:
- HoYa
- Date:
- 2017-07-20
- Revision:
- 1:b2b7580e09d7
- Parent:
- 0:63d30ec829b6
- Child:
- 2:d7647babe160
File content as of revision 1:b2b7580e09d7:
#include "mbed.h" #include "SpwfInterface.h" #include "TCPSocket.h" Serial pc(USBTX, USBRX, 115200); DigitalOut led(LED1); SpwfSAInterface spwf(D8, D2, false); int main() { pc.printf("\r\n"); pc.printf("Start Application\r\n"); pc.printf("\r\n"); pc.printf("Connecting to AP...\r\n"); if (spwf.connect("hRPi3-AP", "rlawjdgh", NSAPI_SECURITY_WPA2)) { // if (spwf.connect("RP_RND_A", "radio1106", NSAPI_SECURITY_WPA2)) { pc.printf("=> Success.\r\n"); } else { pc.printf("=> Failed to connect.\r\n"); return -1; } const char* ip = spwf.get_ip_address(); pc.printf("=> IP Address is: %s\r\n", (ip) ? ip : "No IP"); const char* mac = spwf.get_mac_address(); pc.printf("=> MAC Address is: %s\r\n", (mac) ? mac : "No MAC"); pc.printf("\r\n"); pc.printf("DNS Testing...\r\n"); SocketAddress addr(&spwf, "st.com"); pc.printf("<st.com> is resolved to: %s\r\n", addr.get_ip_address()); while (1) { led = !led; wait(0.5); } }