File tree 2 files changed +13
-6
lines changed
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -1273,27 +1273,34 @@ int32_t WiFiGenericClass::channel(void)
1273
1273
* Set the WiFi channel configuration
1274
1274
* @param primary primary channel. Depending on the region, not all channels may be available.
1275
1275
* @param secondary secondary channel (WIFI_SECOND_CHAN_NONE, WIFI_SECOND_CHAN_ABOVE, WIFI_SECOND_CHAN_BELOW)
1276
+ * @return 0 on success, otherwise error
1276
1277
*/
1277
- void WiFiGenericClass::setChannel (uint8_t primary, wifi_second_chan_t secondary)
1278
+ int WiFiGenericClass::setChannel (uint8_t primary, wifi_second_chan_t secondary)
1278
1279
{
1279
1280
wifi_country_t country;
1281
+ esp_err_t ret;
1280
1282
1281
- if (esp_wifi_get_country (&country) != ESP_OK) {
1283
+ ret = esp_wifi_get_country (&country);
1284
+ if (ret != ESP_OK) {
1282
1285
log_e (" Failed to get country info" );
1283
- return ;
1286
+ return ret ;
1284
1287
}
1285
1288
1286
1289
uint8_t min_chan = country.schan ;
1287
1290
uint8_t max_chan = min_chan + country.nchan - 1 ;
1288
1291
1289
1292
if (primary < min_chan || primary > max_chan){
1290
1293
log_e (" Invalid primary channel: %d" , primary);
1291
- return ;
1294
+ return ESP_ERR_INVALID_ARG ;
1292
1295
}
1293
1296
1294
- if (esp_wifi_set_channel (primary, secondary)) {
1297
+ ret = esp_wifi_set_channel (primary, secondary);
1298
+ if (ret != ESP_OK) {
1295
1299
log_e (" Failed to set channel" );
1300
+ return ret;
1296
1301
}
1302
+
1303
+ return ESP_OK;
1297
1304
}
1298
1305
1299
1306
/* *
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ class WiFiGenericClass
183
183
static int waitStatusBits (int bits, uint32_t timeout_ms);
184
184
185
185
int32_t channel (void );
186
- void setChannel (uint8_t primary, wifi_second_chan_t secondary=WIFI_SECOND_CHAN_NONE);
186
+ int setChannel (uint8_t primary, wifi_second_chan_t secondary=WIFI_SECOND_CHAN_NONE);
187
187
188
188
void persistent (bool persistent);
189
189
void enableLongRange (bool enable);
You can’t perform that action at this time.
0 commit comments