Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32/modsmartconfig: Add smartconfig module. #13658

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Walkline80
Copy link

@Walkline80 Walkline80 commented Feb 13, 2024

Here is the test code which shown all methods and constants belong to smartconfig module, I was compiled firmware with micropython master (synced yesterday) and esp-idf v5.0.4, separately tested on esp32 and esp32c3 develop board.

import network
import time
import smartconfig

import esp
esp.osdebug(0)


TYPES = {
    smartconfig.TYPE_ESPTOUCH: 'ESPTOUCH',
    smartconfig.TYPE_AIRKISS: 'AIRKISS',
    smartconfig.TYPE_ESPTOUCH_AIRKISS: 'ESPTOUCH_AIRKISS',
    smartconfig.TYPE_ESPTOUCH_V2: 'ESPTOUCH_V2'
}

TIMEOUT = 120_000 # ms

def run_test():
    sta = network.WLAN(network.STA_IF)
    _ = sta.active(True)

    smartconfig.type(smartconfig.TYPE_ESPTOUCH_AIRKISS)
    print(f'smartconfig type: {TYPES[smartconfig.type()]}')

    smartconfig.start()

    start_ms = time.ticks_ms()

    while not smartconfig.done():
        if time.ticks_ms() - start_ms > TIMEOUT:
            print('smartconfig timeout')
            smartconfig.stop()
            return

        time.sleep_ms(100)

    print('smartconfig done, ', end='')

    if sta.status() == network.STAT_GOT_IP:
        print('and connected to ap')
        print(f'smartconfig info: {smartconfig.info()}')
        print(f'  - ssid: "{smartconfig.ssid()}"')
        print(f'  - password: "{smartconfig.password()}"')
        print(f'  - bssid: {smartconfig.bssid()}')
        print(f'  - type: {smartconfig.type()}({TYPES[smartconfig.type()]})')

        if smartconfig.rvd_data():
            print(f'  - rvd_data: {smartconfig.rvd_data()}') # EspTouch V2 custom data
    else:
        # maybe wrong password or other situations
        print('but failed connect to ap')

    smartconfig.stop()


if __name__ == '__main__':
    run_test()

@Walkline80
Copy link
Author

You can go with MicroMsg or EspTouch App for smartconfig tests.

@Walkline80
Copy link
Author

In the present, because of 2.4G-5G mixed WiFi and WiFi6 routers, AirKiss protocol is no longer easy to use, even unusable, and using EspTouch and EspTouch V2 protocol requires additional installation of app, I'm afraid that many people don't like to use smartconfig now, but I think there should still be such a function, and it only takes up about 40K of firmware space :)

@Walkline80 Walkline80 force-pushed the smartconfig branch 2 times, most recently from 817af5c to 47fd1a1 Compare February 13, 2024 17:10
@Walkline80 Walkline80 changed the title Add smartconfig module to esp32 port esp32/modsmartconfig: Add smartconfig module. Feb 14, 2024
@Walkline80 Walkline80 force-pushed the smartconfig branch 3 times, most recently from a698696 to de7eb99 Compare February 16, 2024 14:36
@Walkline80
Copy link
Author

Rebase all commits to single one, and append document for smartconfig.

Signed-off-by: Walkline Wang <walkline@gmail.com>
@Walkline80
Copy link
Author

Hi @projectgus, I didn't keep working on #4404 , because the ESP32 port requires ESP-IDF v5, which is a lot different than before, so I chose to start over.

Signed-off-by: Walkine Wang <walkline@gmail.com>
@Walkline80
Copy link
Author

According to PR #13763 removed all STATIC macro in source files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants