Coder Social home page Coder Social logo

Comments (7)

KhushbuShah25 avatar KhushbuShah25 commented on August 13, 2024

To send data to your endpoint , you can call "sendConfigData" method on BLE transport instance with your endpoint name in first argument (path).
For example,
Send data to "prov-scan" endpoint

from esp-idf-provisioning-android.

shahpiyushv avatar shahpiyushv commented on August 13, 2024

@humansthatmake , as an alternative, just for testing, you can even check the esp_prov python tool in ESP IDF (https://github.com/espressif/esp-idf/tree/master/tools/esp_prov). This patch can be applied on top of it if you want to send some abstract non-protobuf data.

diff --git a/tools/esp_prov/esp_prov.py b/tools/esp_prov/esp_prov.py
index 52fb394f26..8ecae3b0dd 100644
--- a/tools/esp_prov/esp_prov.py
+++ b/tools/esp_prov/esp_prov.py
@@ -186,6 +186,16 @@ def custom_config(tp, sec, custom_info, custom_ver):
         return None
 
 
+def custom_data(tp, sec, custom_data):
+    try:
+        message = prov.custom_data_request(sec, custom_data)
+        response = tp.send_data('custom-data', message)
+        return (prov.custom_data_response(sec, response) == 0)
+    except RuntimeError as e:
+        on_except(e)
+        return None
+
+
 def scan_wifi_APs(sel_transport, tp, sec):
     APs = []
     group_channels = 0
@@ -328,6 +338,11 @@ if __name__ == '__main__':
                             'If Wi-Fi scanning is supported by the provisioning service, this need not '
                             'be specified'))
 
+    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 '
@@ -394,6 +409,13 @@ if __name__ == '__main__':
             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):
+            print("---- Error in custom data ----")
+            exit(5)
+        print("==== Custom data sent successfully ====")
+
     if args.ssid == '':
         if not has_capability(obj_transport, 'wifi_scan'):
             print("---- Wi-Fi Scan List is not supported by provisioning service ----")
diff --git a/tools/esp_prov/prov/custom_prov.py b/tools/esp_prov/prov/custom_prov.py
index fe611dbe92..06ec1ca717 100644
--- a/tools/esp_prov/prov/custom_prov.py
+++ b/tools/esp_prov/prov/custom_prov.py
@@ -44,3 +44,17 @@ def custom_config_response(security_ctx, response_data):
     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(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

from esp-idf-provisioning-android.

carlosamtech avatar carlosamtech commented on August 13, 2024

When we create a custom field using the wifi_prov_mgr_endpoint_create and _register, does the Protocomm layer take care of persisting the value of the custom field? If the answer is yes how can we access the custom field value at startup time?

from esp-idf-provisioning-android.

shahpiyushv avatar shahpiyushv commented on August 13, 2024

@carlosamtech , I am not sure if I understand the question correctly. The APIs wifi_prov_mgr_endpoint_create/register just register the appropriate BLE/HTTP custom endpoints. The actual "custom data" will be received from your client (phone app) which will then be passed to your handler as is. So, there is no real question of "persisting the value".

Do let me know if I haven't understood your question correctly.

from esp-idf-provisioning-android.

carlosamtech avatar carlosamtech commented on August 13, 2024

Thank you for your response! My question is about the esp-idf provisioning library, not the mobile app

from esp-idf-provisioning-android.

shahpiyushv avatar shahpiyushv commented on August 13, 2024

@carlosamtech, yes, I understand, and even my response is regarding the wifi_provisioning component of esp-idf :)

from esp-idf-provisioning-android.

shahpiyushv avatar shahpiyushv commented on August 13, 2024

Closing this issue as it has been answered. @humansthatmake the new library has even cleaner APIs for this. Please let us know if you still need some help on that. @carlosamtech , I hope I have answered your query as well. If you have any more queries regarding the esp-idf provisioning library, please file an issue on esp-idf

from esp-idf-provisioning-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.