abobija / esp-smartconfig-dart

EspTouch and EspTouchV2 implementations of SmartConfig provisioning protocols. Plain Dart. All platforms.
https://pub.dev/packages/esp_smartconfig
MIT License
46 stars 11 forks source link

difference between protocols #7

Closed mralperem closed 1 year ago

mralperem commented 1 year ago

Hello,

What is the difference between EspTouch vs EspTouch V2? Which one should i use and why? Could you please explain this

abobija commented 1 year ago

Hi @mralperem

TL;DR: V2 is more secure than V1.

In V1, data is transmitted in plain mode, so if anyone in network intercept your data (ssid/password), he will be able to read it. In the other hand, EspTouch V2, uses key to encrypt data. When you initialize V2 protocol you need to provide key in format of string. ESP device needs to have the same key in order to decrypt received data.

mralperem commented 1 year ago

thank you for your response. When i looked at your code i understand the difference but when i looked at the code for esp8266 provided from espressif system both protocol use the same code and there is no decrypt method. Could you provide a link for the esp8266 code you have used for esp touch v2. I might be looking at the wrong code.

abobija commented 1 year ago

Use esp_smartconfig_set_type function, and set type to SC_TYPE_ESPTOUCH_V2. Then, before calling esp_smartconfig_start function, provide crypt key into smartconfig_start_config_t configuration struct.

Your code for setting SmartConfig to use EspTouchV2 with encryption key should look something like this:

...
esp_smartconfig_set_type(SC_TYPE_ESPTOUCH_V2);

smartconfig_start_config_t start_config = {
  .esp_touch_v2_enable_crypt = true,
  .esp_touch_v2_key = "SecretKeyHere123",
};

esp_smartconfig_start(&start_config);
...

Rest of the code should be the same as in your example.

mralperem commented 1 year ago

thank you for the answer. I was able to find understand it. But do you know if does it support esp8266 or only esp32?

abobija commented 1 year ago

You'r welcome. It supports 8266 as well. Here is SmartConfig docs for 8266 RTOS SDK.