2016-05-14 74 views
-1

錯誤爲'invalid conversion from 'char*' to 'uint8_t {aka unsigned char}' [-fpermissive]'。我正在嘗試使用ssid從網絡獲取rssi,而無需直接連接到它。wifi.Rssi - 從char *轉換爲uint8_t

char ssid[]="GreenNET"; 
void updateRSSI(){ 
    rssi = WiFi.RSSI(ssid); 
    Serial.print(rssi); 
    Serial.print(" dBm"); 
    Serial.println(); 
} 

https://www.arduino.cc/en/Reference/WiFiRSSI

+0

那麼,有什麼問題嗎? –

+0

@SouravGhosh如何將char *轉換爲uint8_t – hig

+0

[讓我谷歌爲你](https://www.google.com/search?q=how+to+convert+char*+to+uint8_t&oq=how+to + convert + char * + to + uint8_t&aqs = chrome..69i57&sourceid = chrome&ie = UTF-8) –

回答

1

WiFi.RSSI需要網絡指標,而不是一個SSID字符串:

char ssid[] = "GreenNET" 
uint8_t available_networks = WiFi.scanNetworks(); 
for (uint8_t net = 0; net < available_networks; ++net) 
{ 
    if (strcmp(WiFi.SSID(net), ssid) == 0) 
    { 
    rssi = WiFi.RSSI(net); 
    Serial.print(rssi); 
    Serial.print(" dBm"); 
    Serial.println(); 
    break; 
} 
} 
+0

除了應該有rssi = WiFi.SSID(net);但它的作品謝謝你! – hig

+0

@hig:'rssi = WiFi.SSID(net);' - 你確定?我沒有關注。 – isedev