File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1269,6 +1269,27 @@ int32_t WiFiGenericClass::channel(void)
1269
1269
return primaryChan;
1270
1270
}
1271
1271
1272
+ /* *
1273
+ * Set the WiFi channel configuration
1274
+ * @param primaryChan primary channel. Depending on the region, not all channels may be available.
1275
+ * @param secondChan secondary channel (WIFI_SECOND_CHAN_NONE, WIFI_SECOND_CHAN_ABOVE, WIFI_SECOND_CHAN_BELOW)
1276
+ */
1277
+ void WiFiGenericClass::channel (uint8_t primary, wifi_second_chan_t secondary)
1278
+ {
1279
+ wifi_country_t country;
1280
+ esp_wifi_get_country (&country);
1281
+
1282
+ uint8_t min_chan = country.schan ;
1283
+ uint8_t max_chan = min_chan + country.nchan - 1 ;
1284
+
1285
+ if (primary < min_chan || primary > max_chan){
1286
+ log_e (" Invalid primary channel: %d" , primary);
1287
+ return ;
1288
+ }
1289
+
1290
+ esp_wifi_set_channel (primary, secondary);
1291
+ }
1292
+
1272
1293
/* *
1273
1294
* store WiFi config in SDK flash area
1274
1295
* @param persistent
Original file line number Diff line number Diff line change @@ -183,6 +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 channel (uint8_t primary, wifi_second_chan_t secondary=WIFI_SECOND_CHAN_NONE);
186
187
187
188
void persistent (bool persistent);
188
189
void enableLongRange (bool enable);
You can’t perform that action at this time.
0 commit comments