Willkommen Darstellung von Beispiel Texten mit Sphinx!¶
Sphinx (/lu’make/) Sphinx ist ein Software-Dokumentationswerkzeug, welches reStructuredText in HTML-Seiten sowie viele weitere Formate wie PDF, EPUB und Manpages umwandelt. It pulls data from the Open Food Facts database and offers a simple and intuitive API.
Note
This project is under active development.
1# version 0.4
2# last update 12/15/22
3def wifi(_debug=False):
4 '''
5 WIFI main modul
6 need a enviroment file is where you keep secret settings, passwords, and tokens!
7 '''
8 #from secrets import secrets
9 from enviroment import enviroment
10 import network
11 import time
12 import ubinascii
13 sta_if = network.WLAN(network.STA_IF)
14 ap_if = network.WLAN(network.AP_IF)
15 try:
16 sta_if.config(hostname=enviroment['hostname'])
17 sta_if.config(dhcp_hostname=enviroment['hostname']) # set hostname
18 except:
19 pass
20 # Access Point
21 #ap_if.active(True)
22 #ap_if.active(False)
23 if ap_if.active():
24 print('AP connected: {}'.format(ap_if.isconnected()))
25 print('AP:',(ubinascii.hexlify(ap_if.config('mac'),':').decode()))
26 print('Network configuration AP: ', ap_if.ifconfig())
27 # client
28 sta_if.active(True)
29 # Client
30 i=0
31 while (False == sta_if.isconnected()):
32 try:
33 #sta_if = network.WLAN(network.STA_IF)
34 print(sta_if.isconnected())
35 sta_if.connect(enviroment["ssid"],enviroment['password'])
36 if _debug:
37 print('WIFI try counter: {}'.format(i))
38 i=i+1
39 if i == 2:
40 #print('sta reset')
41 #sta_if.active(False)
42 print('WIFI disconnect')
43 sta_if.disconnect()
44 time.sleep_ms(1000)
45 #sta_if.active(True)
46 sta_if.connect(enviroment["ssid"],enviroment['password'])
47 print('Try WIFI connect')
48 time.sleep_ms(1000)
49 i=0
50 except:
51 pass
52 time.sleep_ms(500)
53
54
55
56
57 print('CL:',(ubinascii.hexlify(sta_if.config('mac'),':').decode()))
58 print('Network configuration CL . . :', sta_if.ifconfig())
59 try:
60 print('Hostname . . . . . . . . . . : {}'.format(sta_if.config('hostname')))
61 print('DHCP-Hostname . . . . . . . : {}'.format(sta_if.config('dhcp_hostname')))
62 except:
63 pass
64 #sta_if.active(False)
65
66
67 #return sta_if.isconnected()
68 return sta_if.ifconfig()
# version 0.4
# last update 12/15/22
def wifi(_debug=False):
'''
WIFI main modul
need a enviroment file is where you keep secret settings, passwords, and tokens!
'''
#from secrets import secrets
from enviroment import enviroment
import network
import time
import ubinascii
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)
try:
sta_if.config(hostname=enviroment['hostname'])
sta_if.config(dhcp_hostname=enviroment['hostname']) # set hostname
except:
pass
# Access Point
#ap_if.active(True)
#ap_if.active(False)
if ap_if.active():
print('AP connected: {}'.format(ap_if.isconnected()))
print('AP:',(ubinascii.hexlify(ap_if.config('mac'),':').decode()))
print('Network configuration AP: ', ap_if.ifconfig())
# client
sta_if.active(True)
# Client
i=0
while (False == sta_if.isconnected()):
try:
#sta_if = network.WLAN(network.STA_IF)
print(sta_if.isconnected())
sta_if.connect(enviroment["ssid"],enviroment['password'])
if _debug:
print('WIFI try counter: {}'.format(i))
i=i+1
if i == 2:
#print('sta reset')
#sta_if.active(False)
print('WIFI disconnect')
sta_if.disconnect()
time.sleep_ms(1000)
#sta_if.active(True)
sta_if.connect(enviroment["ssid"],enviroment['password'])
print('Try WIFI connect')
time.sleep_ms(1000)
i=0
except:
pass
time.sleep_ms(500)
print('CL:',(ubinascii.hexlify(sta_if.config('mac'),':').decode()))
print('Network configuration CL . . :', sta_if.ifconfig())
try:
print('Hostname . . . . . . . . . . : {}'.format(sta_if.config('hostname')))
print('DHCP-Hostname . . . . . . . : {}'.format(sta_if.config('dhcp_hostname')))
except:
pass
#sta_if.active(False)
#return sta_if.isconnected()
return sta_if.ifconfig()
secrets¶
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'your-ssid-here',
'password' : 'your-password-here',
'openweather_token' : 'your-openweather-token-here',
'aio_username' : "your-aio-username-here",
'aio_key' : 'your-aio-key-here',
'location' : 'New York, US'
}