Go Down

Topic: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c (Read 671 times) previous topic - next topic

wieb

Example code from here: https://www.arduino.cc/en/Reference/WiFiBSSID


Code: [Select]

#include <WiFi.h>

//SSID of your network
char ssid[] = "yourNetwork";
//password of your WPA Network
char pass[] = "secretPassword";

int status = WL_IDLE_STATUS;     // the Wifi radio's status

void setup()
{
 WiFi.begin(ssid, pass);

  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }
  // if you are connected, print out info about the connection:
  else {
  // print the MAC address of the router you're attached to:
  byte bssid[6];
  WiFi.BSSID(bssid);
  Serial.print("BSSID: ");
  Serial.print(bssid[5],HEX);
  Serial.print(":");
  Serial.print(bssid[4],HEX);
  Serial.print(":");
  Serial.print(bssid[3],HEX);
  Serial.print(":");
  Serial.print(bssid[2],HEX);
  Serial.print(":");
  Serial.print(bssid[1],HEX);
  Serial.print(":");
  Serial.println(bssid[0],HEX);
  }
}

void loop () {}


It won't compiled, error in WiFi.BSSID(bssid).

The error message: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned char}' [-fpermissive]

How to fix it?

UKHeliBob

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

wieb


johnwasser

Sounds like a problem in the ESP32 Core.  Figure out who maintains that and ask them to fix it.
Can't compile on me.

Board: ESP32
IDE: 1.8.7
OS: Win 10
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

cattledog

It compiles OK for me with the Arduino esp8266 core.

Board : Wemos D1 esp8266
IDE : 1.8.5
OS : Win 10

More confirmation for
@johnwasser
Quote
Sounds like a problem in the ESP32 Core

mr_confusion

Any update on this error.

No error for Uno but getting this error on ESP8266


vlc0617

Here is the documentation for ESP8266 Wifi Scan Class

https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/scan-class.html


The method BSSID takes an uint8_t parameter (networkItem) that is the zero based index of networks discovered during the scan, and return a uint8_t (aka byte) pointer to the BSSID

So, for example, if your network has index 0, you can read the BSSID this way

Code: [Select]
uint8_t *ptrBSSID = Wifi.BSSID(0);
uint8_t bssid[6];

if (ptrBSSID == NULL)
{
 // error, no network with this index
}

else
{
 // copy the BSSID to your local array
 memcpy(bssid,ptrBSSID,6);
 
 // do something with the bssid
 ....
}

Go Up