provisioning: Add httpd transport (alias of softAP, netif agnostic)

The script works the same way with httpd and softap mode, but it's a bit
confusing to provision the device over Ethernet or USB and call the
transport "softap". That's why we introduce an alias called httpd which
uses the same idea (http server with service name), but that service
runs on any interface (where the specified service is available)
This commit is contained in:
David Cermak 2023-05-30 21:59:51 +02:00
parent c603e2d956
commit 08c5e6e07c
2 changed files with 8 additions and 7 deletions

View File

@ -40,10 +40,11 @@ python esp_prov.py --transport < mode of provisioning : softap \ ble \ console >
* `console` - for debugging via console-based provisioning
* The client->device commands are printed to STDOUT and device->client messages are accepted via STDIN.
* This is to be used when the device is accepting provisioning commands on UART console.
* `httpd` - the script works the same as for `softap`. This could be used on any other network interface than WiFi soft AP, e.g. Ethernet or USB.
* `--service_name <name>` (Optional)
- When transport mode is `ble`, this specifies the BLE device name to which connection is to be established for provisioned. If not provided, BLE scanning is initiated and a list of nearby devices, as seen by the host, is displayed, of which the target device can be chosen.
- When transport mode is `softap`, this specifies the HTTP server hostname / IP which is running the provisioning service, on the SoftAP network of the device which is to be provisioned. This defaults to `192.168.4.1:80` if not specified
- When transport mode is `softap` or `httpd`, this specifies the HTTP server hostname / IP which is running the provisioning service, on the SoftAP network (or any other interface for `httpd` mode) of the device which is to be provisioned. This defaults to `192.168.4.1:80` if not specified
* `--ssid <AP SSID>` (Optional)
- For specifying the SSID of the Wi-Fi AP to which the device is to connect after provisioning.

View File

@ -51,7 +51,7 @@ def get_security(secver, username, password, pop='', verbose=False):
async def get_transport(sel_transport, service_name):
try:
tp = None
if (sel_transport == 'softap'):
if (sel_transport in ['softap', 'httpd']):
if service_name is None:
service_name = '192.168.4.1:80'
tp = transport.Transport_HTTP(service_name)
@ -188,8 +188,8 @@ async def scan_wifi_APs(sel_transport, tp, sec):
APs = []
group_channels = 0
readlen = 100
if sel_transport == 'softap':
# In case of softAP we must perform the scan on individual channels, one by one,
if sel_transport in ['softap', 'httpd']:
# In case of softAP/httpd we must perform the scan on individual channels, one by one,
# so that the Wi-Fi controller gets ample time to send out beacons (necessary to
# maintain connectivity with authenticated stations. As scanning one channel at a
# time will be slow, we can group more than one channels to be scanned in quick
@ -329,14 +329,14 @@ async def main():
parser.add_argument('--transport', required=True, dest='mode', type=str,
help=desc_format(
'Mode of transport over which provisioning is to be performed.',
'This should be one of "softap", "ble" or "console"'))
'This should be one of "softap", "ble", "console" (or "httpd" which is an alias of softap)'))
parser.add_argument('--service_name', dest='name', type=str,
help=desc_format(
'This specifies the name of the provisioning service to connect to, '
'depending upon the mode of transport :',
'\t- transport "ble" : The BLE Device Name',
'\t- transport "softap" : HTTP Server hostname or IP',
'\t- transport "ble" : The BLE Device Name',
'\t- transport "softap/httpd" : HTTP Server hostname or IP',
'\t (default "192.168.4.1:80")'))
parser.add_argument('--proto_ver', dest='version', type=str, default='',