esp-idf/tools/esp_prov/prov/custom_prov.py

30 wiersze
870 B
Python
Czysty Zwykły widok Historia

# 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 utils
from future.utils import tobytes
2018-12-04 12:46:48 +00:00
def print_verbose(security_ctx, data):
if (security_ctx.verbose):
print('++++ ' + data + ' ++++')
2018-12-04 12:46:48 +00:00
def custom_data_request(security_ctx, data):
# Encrypt the custom data
2020-11-11 03:31:17 +00:00
enc_cmd = security_ctx.encrypt_data(tobytes(data))
print_verbose(security_ctx, 'Client -> Device (CustomData cmd) ' + utils.str_to_hexstr(enc_cmd))
return enc_cmd
def custom_data_response(security_ctx, response_data):
# Decrypt response packet
decrypt = security_ctx.decrypt_data(tobytes(response_data))
print('CustomData response: ' + str(decrypt))
return 0