wifi.Rssi - 从char *到uint8_t的转换

时间:2016-05-14 13:04:41

标签: c++ arduino wifi rssi

错误为'invalid conversion from 'char*' to 'uint8_t {aka unsigned char}' [-fpermissive]'。我试图使用ssid从网络获取rssi而不直接连接到它。

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

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

1 个答案:

答案 0 :(得分: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;
 }
}