WiFi.selectAntenna() fails on P2

I am trying to change the antenna configuration on a P2 in the setup() function and it will always return the error code -120. Does this value correspond to the system error NOT_SUPPORTED? Is it still work in progress? According to the documentation, it should already be functional: selectAntenna() [antenna] - WiFi | Reference | Particle

The issue can be reproduced with the following minimal example. It does not matter if you pick the internal or the external antenna. In case you wonder, I am not using the STARTUP() macro for this because I want to be able to select the WiFi antenna using Bluetooth.

SYSTEM_MODE(AUTOMATIC);

void setup() {
   Serial.begin(115200);
   delay(5000);
   int32_t status = WiFi.selectAntenna(ANT_INTERNAL);
   Serial.printf("%ld", status);
}

void loop() {
   
}

Thanks in advance for your help,

Jaime

That function does not currently work on the P2 and Photon 2.

Use BLE.selectAntenna() instead. The same antenna is used for BLE and Wi-Fi, and the BLE function should set the setting in the DCT correctly.

2 Likes