esp_prov custom_data错误

xuetao8687
Posts: 6
Joined: Thu Sep 03, 2020 6:00 am

esp_prov custom_data错误

Postby xuetao8687 » Wed Nov 11, 2020 3:33 am

示例:esp-idf\examples\provisioning\wifi_prov_mgr

Code: Select all

D:\Project\UJ\esp\esp-idf\tools\esp_prov>python esp_prov.py --transport softap --ssid ble --passphrase 1357924680 --sec_ver 1 --pop abcd1234 --custom_data 12345678
Connecting to 192.168.4.1:80

==== Starting Session ====
==== Session Established ====

==== Sending Custom data to esp32 ====
Traceback (most recent call last):
  File "esp_prov.py", line 440, in <module>
    if not custom_data(obj_transport, obj_security, args.custom_data):
  File "esp_prov.py", line 191, in custom_data
    message = prov.custom_data_request(sec, custom_data)
  File "D:\Project\UJ\esp\esp-idf\tools\esp_prov\prov\custom_prov.py", line 51, in custom_data_request
    enc_cmd = security_ctx.encrypt_data(data)
  File "D:\Project\UJ\esp\esp-idf\tools\esp_prov\security\security1.py", line 170, in encrypt_data
    return self.cipher.update(data)
  File "C:\Users\xuetao\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\primitives\ciphers\base.py", line 154, in update
    return self._ctx.update(data)
  File "C:\Users\xuetao\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\backends\openssl\ciphers.py", line 124, in update
    n = self.update_into(data, buf)
  File "C:\Users\xuetao\AppData\Local\Programs\Python\Python37\lib\site-packages\cryptography\hazmat\backends\openssl\ciphers.py", line 139, in update_into
    baseinbuf = self._backend._ffi.from_buffer(data)
TypeError: from_buffer() cannot return the address of a unicode object
模块端输出

Code: Select all

I (2750327) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
W (2750877) wifi:<ba-add>idx:4 (ifx:1, 98:3b:8f:0e:b9:7e), tid:0, ssn:61, winSize:64
I (2763807) protocomm_httpd: Creating new session: 57
W (2764837) protocomm_httpd: Closing session as socket 57 was closed
1、请这个问题怎么解决呢?
2、app "espsoftap"如何使用自定义数据。
3、想知道,模块端,esp_prov.py,app关于自定数据如何使用。

xuetao8687
Posts: 6
Joined: Thu Sep 03, 2020 6:00 am

Re: esp_prov custom_data错误

Postby xuetao8687 » Thu Nov 12, 2020 8:56 am

都挂了两天了,官方的人都不回答一下吗?

xuetao8687
Posts: 6
Joined: Thu Sep 03, 2020 6:00 am

Re: esp_prov custom_data错误

Postby xuetao8687 » Wed Nov 25, 2020 8:01 am

我对查esp_prov源码,tools\esp_prov\prov\custom_prov.py中,在使用custom_config,和custom_data,custom_config 并非报该错误。
奈何我不会python.
我把这两个方法,贴出来,哪个大神帮忙解决一下呢。
custom_config

Code: Select all

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
custom_data

Code: Select all

def custom_data_request(security_ctx, data):
    # Encrypt the custom data
    enc_cmd = security_ctx.encrypt_data(data)
    print_verbose(security_ctx, "Client -> Device (CustomData cmd) " + utils.str_to_hexstr(enc_cmd))
    return enc_cmd
我想咨询一下,在custom_data方法中,中的data,是否有什么特殊要求。custom_config,输入却不报错误,custim_data却要报错呢?

Code: Select all

enc_cmd = security_ctx.encrypt_data(data)

xuetao8687
Posts: 6
Joined: Thu Sep 03, 2020 6:00 am

Re: esp_prov custom_data错误

Postby xuetao8687 » Wed Nov 25, 2020 9:09 am

与此同时 esp_prov.py -h中关于custom_data指令使用方法,提到的一个示例,在idf 4.1中也没有该示例。

Code: Select all

  --custom_data CUSTOM_DATA
                        This is an optional parameter, only intended for use with
                        "examples/provisioning/wifi_prov_mgr_custom_data"

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: esp_prov custom_data错误

Postby ESP_YJM » Fri Feb 26, 2021 10:33 am

请使用最新的 idf esp_prov脚本和对应的examples/provisioning/wifi_prov_mgr测试custom_data,我测试了 ok。

Who is online

Users browsing this forum: No registered users and 71 guests