Skip to content

wlan wrong example #51

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 33 additions & 36 deletions examples/system/wlan_sta/wlan_sta_cores3_example.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
#
# SPDX-License-Identifier: MIT

import os, sys, io
import M5
from M5 import *
from image_plus import ImagePlus
import network



title0 = None
image_plus0 = None
label0 = None
label1 = None
label2 = None
wlan = None


def setup():
global title0, image_plus0
global title0, label0, label1, label2, wlan

M5.begin()
Widgets.fillScreen(0x222222)
title0 = Widgets.Title("Image+ CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18)
image_plus0 = ImagePlus(
"https://static-cdn.m5stack.com/resource/public/assets/aboutus/m5logo2022.png",
43,
51,
True,
3000,
default_img="res/img/default.png",
)
M5.begin()
Widgets.fillScreen(0x222222)
title0 = Widgets.Title("WLAN STA CoreS3 Example", 3, 0xffffff, 0x0000FF, Widgets.FONTS.DejaVu18)
label0 = Widgets.Label("label0", 2, 81, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label1 = Widgets.Label("label1", 2, 114, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label2 = Widgets.Label("label2", 2, 143, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)

image_plus0.setVisible(True)
image_plus0.set_update_period(5000)
image_plus0.set_update_enable(True)
wlan = network.WLAN(network.STA_IF)
wlan.config(reconnects=3)
wlan.connect('M5-R&D', 'echo"password">/dev/null')


def loop():
global title0, image_plus0
M5.update()


if __name__ == "__main__":
global title0, label0, label1, label2, wlan
M5.update()
label0.setText(str((str('Connected?:') + str((wlan.isconnected())))))
label1.setText(str((str('RSSI:') + str((wlan.status('rssi'))))))
label2.setText(str((str('IP:') + str((wlan.ifconfig()[0])))))


if __name__ == '__main__':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg

print_error_msg(e)
except ImportError:
print("please update to latest firmware")
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")