Arduino Forum

Using Arduino => Programming Questions => Topic started by: wieb on Dec 02, 2018, 04:39 pm

Title: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: wieb on Dec 02, 2018, 04:39 pm
Example code from here: https://www.arduino.cc/en/Reference/WiFiBSSID (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?
Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: UKHeliBob on Dec 02, 2018, 04:45 pm
It compiles OK for me

Board : Nano
IDE : 1.8.5
OS : Win 10
Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: wieb on Dec 02, 2018, 04:48 pm
Can't compile on me.

Board: ESP32
IDE: 1.8.7
OS: Win 10
Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: johnwasser on Dec 02, 2018, 05:06 pm
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
Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: cattledog on Dec 02, 2018, 05:15 pm
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
Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: mr_confusion on Apr 23, 2019, 11:21 am
Any update on this error.

No error for Uno but getting this error on ESP8266

Title: Re: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned c
Post by: vlc0617 on Apr 23, 2019, 01:11 pm
Here is the documentation for ESP8266 Wifi Scan Class

https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/scan-class.html
 (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
 ....
}