Particle Photon: wlan_scan_aps() undefined reference


I have followed the instructions in [1] to build the firmware for a Particle Photon and everything works correctly. I am then trying to write an application that uses the internal function wlan_scan_aps() to scan for networks. However, attempting to build this application throws a linker error:

undefined reference to `wlan_scan_aps(void (*)(void*, unsigned char const*, unsigned int, int), void*)'

Inspection of the compiled hal library shows that there is no wlan_scan_aps symbol being exported:

$ nm -gC firmware/build/target/hal-dynalib/platform-6-m/libhal-dynalib.a  | grep wlan_scan_aps

[empty output]

On the other hand, if I build the application by passing PLATFORM=dev-photon instead of PLATFORM=photon to make, then the program compiles correctly (wlan_scan_aps is properly linked), but then the program does not seem to work when loaded onto the photon - the LED blinks with a very dim magenta light and the device appears to be unusable.

I have been looking at the hal code for the Photon, firmware/hal/src/photon/wlan_hal.cpp to be specific, and the module does use the wlan_scan_aps() function internally, so I wouldn’t know why I am not able to use it from the application code.

Could anyone shed some light into this? Is it possible to use wlan_scan_aps() from the application code and how?




Try adding #include "spark_wiring_wifi.h"

The include is there, I am basing my code on the wifitester code that ships with the firmware. The error is a linker error not a compiler error, so to me it seems it’s a problem on how the hal module is built but I do not fully understand what is going on.

Only functions present in hal/inc/hal_dynalib_wlan.h are exported. If you’re building locally you could add this temporarily (add to the end of the list), and then add a extern void wlan_scan_aps(void (*)(void*, unsigned char const*, unsigned int, int), void*); but bear in mind that this change will be reverted once new system firmware is flashed to your device from the cloud.

We will be adding wifi scanning functionality in a future release.