Comments (7)
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.
@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.
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.
@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.
Thank you for your response! My question is about the esp-idf provisioning library, not the mobile app
from esp-idf-provisioning-android.
@carlosamtech, yes, I understand, and even my response is regarding the wifi_provisioning component of esp-idf :)
from esp-idf-provisioning-android.
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)
- Issues on CAT S41 HOT 3
- Do you support to get IPwifi in kotlin ?
- Intermitent issue when try to provision device
- Intermitent issue when try to provisioning device HOT 11
- How to I get wireless network IP4 address (of ESP with Wifi, not phone with Wifi) after successful provision in Android HOT 6
- Error protobuf when in release HOT 2
- Provision Issue - java.lang.RuntimeException: Characteristic is not available for given path. HOT 2
- Jitpack Dependency Unavailable HOT 10
- Android Espblufi app have a issue with Chinese Wifi SSID HOT 4
- Unable to call ProvisionListener in Kotlin Android HOT 6
- How to disable the automatic disconnection of BLE when device provisioning success? HOT 3
- How to test sending custom data from this app
- AES encryption for profile Security1 HOT 2
- Qrcode is not valid
- 'IllegalArgumentException' error regarding ble, uuid
- Espdevice.provision
- EspDevice.provision, debug app no problem, but release app callback with createSessionFailed HOT 7
- EventBus SDK warning HOT 2
- Incorrectly reports provisioning failure
- Unterminated string at character 600
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-idf-provisioning-android.