Skip to content

Commit

Permalink
Adding missing WifiChannel selector to ESPNow controller
Browse files Browse the repository at this point in the history
  • Loading branch information
enesbcs committed Sep 21, 2019
1 parent ef61195 commit 44c134d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions _C022_ESPNow.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,23 @@ def controller_init(self,enablecontroller=None):
self.bgproc = threading.Thread(target=self.bgreceiver)
self.bgproc.daemon = True
self.bgproc.start()
time.sleep(1)
time.sleep(2)
mode = self.changemode(0)
if mode!=0:
mode = self.changemode(0)
if mode!=0:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Serial ESPNow GW adapter is not compatible!")
self.initialized = False
self.connected = False
self.disconnect()

if self.connected:
if int(self.controllerport)>0:
self.serialcommand("unit,"+str(self.controllerport))
time.sleep(0.2)
self.serialcommand("espnow,dest,"+str(self.defaultunit))
time.sleep(0.2)
self.serialcommand("espnow,chan,"+str(self.wchan))
time.sleep(0.2)
misc.addLog(rpieGlobals.LOG_LEVEL_INFO,"Serial ESPNow GW initialized")
self.serialcommand("settings")
time.sleep(0.5)
Expand Down Expand Up @@ -194,6 +197,13 @@ def webform_load(self):
webserver.addFormNumericBox("Default destination node index","defaultnode",self.defaultunit,0,255)
webserver.addFormNote("Default node index for data sending")
webserver.addFormNote("Detected gateway MAC address "+str(self.mac))
options = []
optionvalues = []
for i in range(1,14):
options.append(str(i))
optionvalues.append(i)
webserver.addFormSelector("Wifi channel","wchannel",len(options),options,optionvalues,None,self.wchan)
webserver.addFormNote("Set the same wifi channel at all nodes!")
webserver.addWideButton("espnow","ESPNow endpoint management","")
else:
webserver.addFormNote("No serial ports found")
Expand All @@ -206,6 +216,7 @@ def webform_save(self,params):
try:
self.port = str(webserver.arg("ser_addr",params))
self.baud = int(webserver.arg("ser_spd",params))
self.wchan = int(webserver.arg("wchannel",params))
self.defaultunit = int(webserver.arg("defaultnode",params))
# self.enablesend = (webserver.arg("sender",params)=="on")
except Exception as e:
Expand Down

0 comments on commit 44c134d

Please sign in to comment.