esp_prov: Removed features used in legacy provisioning examples

This commit is contained in:
Laukik Hase 2022-01-13 14:20:51 +05:30
parent e284eb070f
commit 583b984837
5 changed files with 22 additions and 132 deletions

View File

@ -2721,29 +2721,6 @@ examples/protocols/sockets/udp_server/main/udp_server.c
examples/protocols/static_ip/main/static_ip_example_main.c
examples/protocols/websocket/example_test.py
examples/protocols/websocket/main/websocket_example.c
examples/provisioning/legacy/ble_prov/ble_prov_test.py
examples/provisioning/legacy/ble_prov/main/app_main.c
examples/provisioning/legacy/ble_prov/main/app_prov.c
examples/provisioning/legacy/ble_prov/main/app_prov.h
examples/provisioning/legacy/ble_prov/main/app_prov_handlers.c
examples/provisioning/legacy/console_prov/main/app_main.c
examples/provisioning/legacy/console_prov/main/app_prov.c
examples/provisioning/legacy/console_prov/main/app_prov.h
examples/provisioning/legacy/console_prov/main/app_prov_handlers.c
examples/provisioning/legacy/custom_config/components/custom_provisioning/include/custom_provisioning/custom_config.h
examples/provisioning/legacy/custom_config/components/custom_provisioning/proto-c/custom_config.pb-c.c
examples/provisioning/legacy/custom_config/components/custom_provisioning/proto-c/custom_config.pb-c.h
examples/provisioning/legacy/custom_config/components/custom_provisioning/python/custom_config_pb2.py
examples/provisioning/legacy/custom_config/components/custom_provisioning/src/custom_config.c
examples/provisioning/legacy/custom_config/main/app_main.c
examples/provisioning/legacy/custom_config/main/app_prov.c
examples/provisioning/legacy/custom_config/main/app_prov.h
examples/provisioning/legacy/custom_config/main/app_prov_handlers.c
examples/provisioning/legacy/softap_prov/main/app_main.c
examples/provisioning/legacy/softap_prov/main/app_prov.c
examples/provisioning/legacy/softap_prov/main/app_prov.h
examples/provisioning/legacy/softap_prov/main/app_prov_handlers.c
examples/provisioning/legacy/softap_prov/softap_prov_test.py
examples/provisioning/wifi_prov_mgr/main/app_main.c
examples/provisioning/wifi_prov_mgr/wifi_prov_mgr_test.py
examples/security/flash_encryption/example_test.py
@ -2947,10 +2924,7 @@ tools/esp_app_trace/logtrace_proc.py
tools/esp_app_trace/sysviewtrace_proc.py
tools/esp_app_trace/test/sysview/blink.c
tools/esp_prov/__init__.py
tools/esp_prov/esp_prov.py
tools/esp_prov/proto/__init__.py
tools/esp_prov/prov/__init__.py
tools/esp_prov/prov/custom_prov.py
tools/esp_prov/prov/wifi_prov.py
tools/esp_prov/prov/wifi_scan.py
tools/esp_prov/security/__init__.py

View File

@ -13,13 +13,13 @@ python esp_prov.py --transport < mode of provisioning : softap \ ble \ console >
Usage of `esp-prov` assumes that the provisioning app has specific protocomm endpoints active. These endpoints are active in the provisioning examples and accept specific protobuf data structures:
| Endpoint Name | URI (HTTP server on ip:port) | Description |
|---------------|------------------------------|-----------------------------------------------------------|
| prov-session | http://ip:port/prov-session | Security endpoint used for session establishment |
| prov-config | http://ip:port/prov-config | Endpoint used for configuring Wi-Fi credentials on device |
| proto-ver | http://ip:port/proto-ver | Version endpoint for checking protocol compatibility |
| prov-scan | http://ip:port/prov-scan | Endpoint used for scanning Wi-Fi APs |
| custom-config | http://ip:port/custom-config | Optional endpoint for configuring custom credentials |
| Endpoint Name | URI (HTTP server on ip:port) | Description |
|---------------|------------------------------|------------------------------------------------------------------------------------------|
| prov-session | http://ip:port/prov-session | Security endpoint used for session establishment |
| prov-config | http://ip:port/prov-config | Endpoint used for configuring Wi-Fi credentials on device |
| proto-ver | http://ip:port/proto-ver | Version endpoint for checking protocol compatibility |
| prov-scan | http://ip:port/prov-scan | Endpoint used for scanning Wi-Fi APs |
| custom-data | http://ip:port/custom-data | Optional endpoint for sending custom data (refer `wifi_prov_mgr` example) |
# PARAMETERS
@ -53,18 +53,13 @@ Usage of `esp-prov` assumes that the provisioning app has specific protocomm end
* `--pop <Proof of possession string>` (Optional)
For specifying optional Proof of Possession string to use for protocomm endpoint security version 1. This option is ignored when security version 0 is in use
* `--service_name <name> (Optional)
* `--service_name <name>` (Optional)
When transport mode is ble, this specifies the BLE device name to which connection is to be established for provisioned.
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
* `--custom_config` (Optional)
This flag assumes the provisioning app has an endpoint called `custom-config`. Use `--custom_info` and `--custom_ver` options to specify the fields accepted by this endpoint
* `--custom_info <some string>` (Optional) (Only use along with `--custom_config`)
For specifying an information string to be sent to the `custom-config` endpoint during provisioning
* `--custom_ver <some integer>` (Optional) (Only use along with `--custom_config`)
For specifying a version number (int) to be sent to the `custom-config` endpoint during provisioning
* `--custom_data <some string>` (Optional)
An information string can be sent to the `custom-data` endpoint during provisioning using this argument.
(Assumes the provisioning app has an endpoint called `custom-data` - see [provisioning/wifi_prov_mgr](https://github.com/espressif/esp-idf/tree/master/examples/provisioning/wifi_prov_mgr) example for implementation details).
# AVAILABILITY

View File

@ -1,18 +1,7 @@
#!/usr/bin/env python
#
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
from __future__ import print_function
@ -368,18 +357,7 @@ if __name__ == '__main__':
parser.add_argument('--custom_data', dest='custom_data', type=str, default='',
help=desc_format(
'This is an optional parameter, only intended for use with '
'"examples/provisioning/wifi_prov_mgr_custom_data"'))
parser.add_argument('--custom_config', action='store_true',
help=desc_format(
'This is an optional parameter, only intended for use with '
'"examples/provisioning/custom_config"'))
parser.add_argument('--custom_info', dest='custom_info', type=str, default='<some custom info string>',
help=desc_format(
'Custom Config Info String. "--custom_config" must be specified for using this'))
parser.add_argument('--custom_ver', dest='custom_ver', type=int, default=2,
help=desc_format(
'Custom Config Version Number. "--custom_config" must be specified for using this'))
'"examples/provisioning/wifi_prov_mgr"'))
parser.add_argument('-v','--verbose', help='Increase output verbosity', action='store_true')
@ -429,13 +407,6 @@ if __name__ == '__main__':
exit(4)
print('==== Session Established ====')
if args.custom_config:
print('\n==== Sending Custom config to esp32 ====')
if not custom_config(obj_transport, obj_security, args.custom_info, args.custom_ver):
print('---- Error in custom config ----')
exit(5)
print('==== Custom config sent successfully ====')
if args.custom_data != '':
print('\n==== Sending Custom data to esp32 ====')
if not custom_data(obj_transport, obj_security, args.custom_data):

View File

@ -1,29 +1,14 @@
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import os
from types import ModuleType
def _load_source(name, path):
try:
from importlib.machinery import SourceFileLoader
return SourceFileLoader(name, path).load_module()
except ImportError:
# importlib.machinery doesn't exists in Python 2 so we will use imp (deprecated in Python 3)
import imp
return imp.load_source(name, path)
def _load_source(name, path): # type: (str, str) -> ModuleType
from importlib.machinery import SourceFileLoader
return SourceFileLoader(name, path).load_module(name)
idf_path = os.environ['IDF_PATH']
@ -38,7 +23,3 @@ session_pb2 = _load_source('session_pb2', idf_path + '/components/protocomm/
wifi_constants_pb2 = _load_source('wifi_constants_pb2', idf_path + '/components/wifi_provisioning/python/wifi_constants_pb2.py')
wifi_config_pb2 = _load_source('wifi_config_pb2', idf_path + '/components/wifi_provisioning/python/wifi_config_pb2.py')
wifi_scan_pb2 = _load_source('wifi_scan_pb2', idf_path + '/components/wifi_provisioning/python/wifi_scan_pb2.py')
# custom_provisioning component related python files generated from .proto files
custom_config_pb2 = _load_source('custom_config_pb2', idf_path +
'/examples/provisioning/legacy/custom_config/components/custom_provisioning/python/custom_config_pb2.py')

View File

@ -1,23 +1,11 @@
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# APIs for interpreting and creating protobuf packets for `custom-config` protocomm endpoint
from __future__ import print_function
import proto
import utils
from future.utils import tobytes
@ -27,25 +15,6 @@ def print_verbose(security_ctx, data):
print('++++ ' + data + ' ++++')
def custom_config_request(security_ctx, info, version):
# Form protobuf request packet from custom-config data
cmd = proto.custom_config_pb2.CustomConfigRequest()
cmd.info = tobytes(info)
cmd.version = version
enc_cmd = security_ctx.encrypt_data(cmd.SerializeToString()).decode('latin-1')
print_verbose(security_ctx, 'Client -> Device (CustomConfig cmd) ' + utils.str_to_hexstr(enc_cmd))
return enc_cmd
def custom_config_response(security_ctx, response_data):
# Interpret protobuf response packet
decrypt = security_ctx.decrypt_data(tobytes(response_data))
cmd_resp = proto.custom_config_pb2.CustomConfigResponse()
cmd_resp.ParseFromString(decrypt)
print_verbose(security_ctx, 'CustomConfig status ' + str(cmd_resp.status))
return cmd_resp.status
def custom_data_request(security_ctx, data):
# Encrypt the custom data
enc_cmd = security_ctx.encrypt_data(tobytes(data))