Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of WiflyInterface by
WiflyInterface.cpp
00001 #include "WiflyInterface.h" 00002 00003 WiflyInterface::WiflyInterface( PinName tx, PinName rx, PinName reset, PinName tcp_status, 00004 const char * ssid, const char * phrase, Security sec) : 00005 Wifly(tx, rx, reset, tcp_status, ssid, phrase, sec) 00006 { 00007 ip_set = false; 00008 } 00009 00010 int WiflyInterface::init() 00011 { 00012 state.dhcp = true; 00013 reset(); 00014 return 0; 00015 } 00016 00017 int WiflyInterface::init(const char* ip, const char* mask, const char* gateway) 00018 { 00019 state.dhcp = false; 00020 this->ip = ip; 00021 strcpy(ip_string, ip); 00022 ip_set = true; 00023 this->netmask = mask; 00024 this->gateway = gateway; 00025 reset(); 00026 00027 return 0; 00028 } 00029 00030 int WiflyInterface::connect() 00031 { 00032 return join(); 00033 } 00034 00035 bool WiflyInterface::is_associated() 00036 { 00037 return Wifly::is_associated(); 00038 } 00039 00040 int WiflyInterface::disconnect() 00041 { 00042 return Wifly::disconnect(); 00043 } 00044 00045 char * WiflyInterface::getIPAddress() 00046 { 00047 char * match = 0; 00048 if (!ip_set) { 00049 if (!sendCommand("get ip a\r", NULL, ip_string)) 00050 return NULL; 00051 exit(); 00052 flush(); 00053 match = strstr(ip_string, "<"); 00054 if (match != NULL) { 00055 *match = '\0'; 00056 } 00057 if (strlen(ip_string) < 6) { 00058 match = strstr(ip_string, ">"); 00059 if (match != NULL) { 00060 int len = strlen(match + 1); 00061 memcpy(ip_string, match + 1, len); 00062 } 00063 } 00064 ip_set = true; 00065 } 00066 return ip_string; 00067 }
Generated on Wed Jul 13 2022 07:41:28 by
