1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Merge pull request #325 from Links2004/esp8266

add 2 compiler options from last SDK, __attribute__ format to Print::printf,  link to arduinoWebSockets
This commit is contained in:
Ivan Grokhotkov
2015-05-29 19:44:32 +03:00
21 changed files with 187 additions and 54 deletions

View File

@ -203,12 +203,32 @@ uint8_t* ESP8266WiFiClass::macAddress(uint8_t* mac)
return mac;
}
String ESP8266WiFiClass::macAddress(void)
{
uint8_t mac[6];
char macStr[18] = {0};
wifi_get_macaddr(STATION_IF, mac);
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr);
}
uint8_t* ESP8266WiFiClass::softAPmacAddress(uint8_t* mac)
{
wifi_get_macaddr(SOFTAP_IF, mac);
return mac;
}
String ESP8266WiFiClass::softAPmacAddress(void)
{
uint8_t mac[6];
char macStr[18] = {0};
wifi_get_macaddr(SOFTAP_IF, mac);
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr);
}
IPAddress ESP8266WiFiClass::localIP()
{
struct ip_info ip;
@ -251,10 +271,25 @@ uint8_t* ESP8266WiFiClass::BSSID(void)
return reinterpret_cast<uint8_t*>(conf.bssid);
}
String ESP8266WiFiClass::BSSIDstr(void)
{
static struct station_config conf;
char mac[18] = {0};
wifi_station_get_config(&conf);
sprintf(mac,"%02X:%02X:%02X:%02X:%02X:%02X", conf.bssid[0], conf.bssid[1], conf.bssid[2], conf.bssid[3], conf.bssid[4], conf.bssid[5]);
return String(mac);
}
int32_t ESP8266WiFiClass::channel(void) {
return wifi_get_channel();
}
int32_t ESP8266WiFiClass::RSSI(void) {
return wifi_station_get_rssi();
}
extern "C"
{
typedef STAILQ_HEAD(, bss_info) bss_info_head_t;
@ -353,6 +388,17 @@ uint8_t * ESP8266WiFiClass::BSSID(uint8_t i)
return it->bssid;
}
String ESP8266WiFiClass::BSSIDstr(uint8_t i)
{
char mac[18] = {0};
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
if (!it)
return String("");
sprintf(mac,"%02X:%02X:%02X:%02X:%02X:%02X", it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]);
return String(mac);
}
int32_t ESP8266WiFiClass::channel(uint8_t i)
{
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));

View File

@ -103,15 +103,19 @@ public:
* Get the station interface MAC address.
*
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
* return: String
*/
uint8_t* macAddress(uint8_t* mac);
String macAddress(void);
/*
* Get the softAP interface MAC address.
*
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
* return: String
*/
uint8_t* softAPmacAddress(uint8_t* mac);
String softAPmacAddress(void);
/*
* Get the station interface IP address.
@ -151,10 +155,17 @@ public:
/*
* Return the current bssid / mac associated with the network if configured
*
* return: bssid string
* return: bssid uint8_t *
*/
uint8_t * BSSID(void);
/*
* Return the current bssid / mac associated with the network if configured
*
* return: bssid string
*/
String BSSIDstr(void);
/*
* Return the current channel associated with the network
*
@ -163,13 +174,12 @@ public:
int32_t channel(void);
/*
* Return the current network RSSI. Note: this is just a stub, there is no way to
* get the RSSI in the Espressif SDK yet.
* Return the current network RSSI.
*
* return: RSSI value (currently 0)
* return: RSSI value
*/
int32_t RSSI() { return 0; }
int32_t RSSI();
/*
* Start scan WiFi networks available
@ -209,10 +219,17 @@ public:
/**
* return MAC / BSSID of scanned wifi
* @param networkItem specify from which network item want to get the information
* @return uint8_t * to MAC / BSSID of scanned wifi
* @return uint8_t * MAC / BSSID of scanned wifi
*/
uint8_t * BSSID(uint8_t networkItem);
/**
* return MAC / BSSID of scanned wifi
* @param networkItem specify from which network item want to get the information
* @return String MAC / BSSID of scanned wifi
*/
String BSSIDstr(uint8_t networkItem);
/**
* return channel of scanned wifi
* @param networkItem specify from which network item want to get the information

View File

@ -47,6 +47,10 @@ wl_status_t ESP8266WiFiMulti::run(void) {
uint8 bestBSSID[6];
int32_t bestChannel;
DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n");
WiFi.disconnect();
DEBUG_WIFI_MULTI("[WIFI] start scan\n");
// WiFi.scanNetworks will return the number of networks found
int8_t n = WiFi.scanNetworks();
@ -93,7 +97,7 @@ wl_status_t ESP8266WiFiMulti::run(void) {
DEBUG_WIFI_MULTI(" ");
}
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan, rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*');
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*');
delay(0);
}
}

View File

@ -32,7 +32,7 @@
#undef max
#include <vector>
//#define DEBUG_WIFI_MULTI(...) os_printf( __VA_ARGS__ )
//#define DEBUG_WIFI_MULTI(...) Serial1.printf( __VA_ARGS__ )
#ifndef DEBUG_WIFI_MULTI
#define DEBUG_WIFI_MULTI(...)