Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RP2: Pico 2 W Not connecting with thread running #16779

Closed
@coencoensmeets

Description

@coencoensmeets

Port, board and/or hardware

RP2 - Pico 2 W

MicroPython version

MicroPython v1.25.0-preview.229.g0d46e45a1 on 2025-01-27; Raspberry Pi Pico 2 W with RP2350

Reproduction

import timeimport _threadimport urequestsSSID = ""password = ""def connect_normal():    wlan = network.WLAN(network.STA_IF)    wlan.active(True)    wlan.connect(SSID, password)    print("Connecting to network")    start_time = time.time()    while not wlan.isconnected() and time.time() - start_time < 20:        print("Waiting for connection...")        time.sleep(2)    if wlan.isconnected():        print("Connected to network")    else:        print("Failed to connect to network")    print("Sleep for 2 seconds")    time.sleep(2)    wlan.disconnect()    def main_thread():    connect_normal()def second_thread():    for (i) in range(10):        print("Second thread")        time.sleep(2)_thread.start_new_thread(second_thread, ())main_thread()

Other things tested but not working:

  • Extending the 20-second time limit.
  • Puttingwlan = network.WLAN(network.STA_IF),wlan.active(True), andwlan.connect(SSID, password) before starting a thread.
  • Switching the functionsconnection_normal andsecond_thread to run in the other thread. So the connection is made on the newly opened thread.
  • Building firmware with the latest Pico SDK develop
  • Addingrp2.country("NL") andnetwork.country(country).

Expected behaviour

Expected to connect to the network and printConnected to network.

Observed behaviour

No connection is established after the set time of 20 seconds. (Time is irrelevant as it never seems to connect). When the line_thread.start_new_thread(second_thread, ()) is commented out, a connection is found almost every single time.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp