georgerobotics / cyw43-driver

Other
79 stars 42 forks source link

Docs: cyw43_wifi_scan() requires that the opts object is set to all zero #34

Open slimhazard opened 2 years ago

slimhazard commented 2 years ago

The documentation for cyw43_wifi_scan() (as I see it in then Pico SDK docs) says of the opts parameter (whose type is cyw43_wifi_scan_options_t): "Values in here are currently ignored." But evidently it's necessary to set the object to all zero, i.e. zero out all bytes in the size of the cyw43_wifi_scan_options_t object.

I was passing in a pointer to an uninitialized local variable, and was puzzled when the wifi scan wouldn't work. Then I was pointed to an Arduino IDE example of a Wifi scan for the PicoW, which uses memset to zero the object, and the example in pico-examples, which uses the struct = {0} idiom. I did that in my own setup and it worked.

That's fine, but I suggest that the documentation makes this detail explicit. I took "values ignored" as meaning that the contents of the opts object don't matter at all.

Thread in the Raspberry Pi Pico forum

peterharperuk commented 2 years ago

"Values in here are currently ignored" this is incorrect, the ssid parameter IS used, so you can restrict the results that are returned based on the ssid name. Presumably if you don't initialise the parameters it tries to filter on random data. Should be an easy fix to the in source documentation.