Skip to content

Commit

Permalink
change the default values of WebUI fields
Browse files Browse the repository at this point in the history
minor refactoring on web server global variable reading
  • Loading branch information
ftylitak committed Sep 29, 2021
1 parent 3ab50c1 commit 141f10e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions insighioNode/apps/demo_console/templ/lora_config_templ.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
_MAX_CONNECTION_ATTEMPT_TIME_SEC = 60

""" LoRa-related configuration options """
_DEV_EUI = '<lora-dev-eui>'
_APP_EUI = '<lora-app-eui>'
_APP_KEY = '<lora-app-key>'
_DEV_EUI = "<lora-dev-eui>"
_APP_EUI = "<lora-app-eui>"
_APP_KEY = "<lora-app-key>"

from network import LoRa
_LORA_REGION = LoRa.<lora-region>
Expand Down
2 changes: 1 addition & 1 deletion insighioNode/lib/device_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _try_get_lora_mac_bytes(force_init_region=False):
def get_lora_mac():
""" Returns a device id based on lora mac in readable format and in raw format """
# valid only for lora compatible devices
if sys.platform in _LORA_COMPATIBLE_PLATFORMS:
if not is_esp32() and sys.platform in _LORA_COMPATIBLE_PLATFORMS:
mac = _try_get_lora_mac_bytes()

if mac is None:
Expand Down
2 changes: 0 additions & 2 deletions insighioNode/lib/gpio_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def get_input_voltage(pin, voltage_divider=1, attn=ADC.ATTN_11DB, measurement_cy
return round((tmp / measurement_cycles) * voltage_divider)
# typical voltage_divider levels: 3.054 --> Exp Board 2.0, 2 --> Exp Board 3, 11 --> in-house implementation

# should we use round function since the following division returns millivolt?


def get_vin(pin='P16'):
""" A simple wrapper to take Vin for pycom modules (relevant only when an expansion board is used) """
Expand Down
18 changes: 10 additions & 8 deletions insighioNode/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import utils
import machine
import logging
import ure


class WebServer:
Expand Down Expand Up @@ -51,11 +52,12 @@ def __init__(self):
device_info.set_defaults()

def saveGlobalVarIfFoundInLine(self, line, strToSearch, globalVarName, delimiter):
if line.startswith(strToSearch):
if ure.match(strToSearch, line):
#if line.startswith(strToSearch):
elems = line.split(delimiter)
logging.info(strToSearch + ": " + str(elems))
if len(elems) > 1 and elems[1] != "":
self.pyhtmlMod.SetGlobalVar(globalVarName, elems[1])
logging.debug("var '{}' = {}".format(globalVarName, elems[1]))
return True
return False

Expand All @@ -71,10 +73,10 @@ def extractInsighioIds(self):
self.pyhtmlMod.SetGlobalVar("insighioDeviceToken", "")

while i < linesCount:
if (self.saveGlobalVarIfFoundInLine(projectConfig[i], ' protocol_config.message_channel_id', "insighioChannelId", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], ' protocol_config.control_channel_id', "insighioControlChannel", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], ' protocol_config.thing_id', "insighioDeviceId", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], ' protocol_config.thing_token', "insighioDeviceToken", '"')):
if (self.saveGlobalVarIfFoundInLine(projectConfig[i], r'^(\s*\w+\.)?message_channel_id', "insighioChannelId", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], r'^(\s*\w+\.)?control_channel_id', "insighioControlChannel", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], r'^(\s*\w+\.)?thing_id', "insighioDeviceId", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], r'^(\s*\w+\.)?thing_token', "insighioDeviceToken", '"')):
euisFilled = euisFilled + 1

if euisFilled == 4:
Expand All @@ -101,8 +103,8 @@ def extractLoRaUIDS(self):
self.pyhtmlMod.SetGlobalVar("loraAppKey", "")

while i < linesCount:
if (self.saveGlobalVarIfFoundInLine(projectConfig[i], '_APP_EUI', "loraAppEUI", "'") or
self.saveGlobalVarIfFoundInLine(projectConfig[i], '_APP_KEY', "loraAppKey", "'")):
if (self.saveGlobalVarIfFoundInLine(projectConfig[i], '_APP_EUI', "loraAppEUI", '"') or
self.saveGlobalVarIfFoundInLine(projectConfig[i], '_APP_KEY', "loraAppKey", '"')):
euisFilled = euisFilled + 1

if euisFilled == 3:
Expand Down
4 changes: 2 additions & 2 deletions insighioNode/www/step-3-config-cellular.pyhtml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<label class="form-label" for="input-example-cellular">APN</label>
</div>
<div class="col-9 col-sm-12">
<input class="form-input constr-field" type="text" id="input-apn" placeholder="" />
<input class="form-input constr-field" type="text" id="input-apn" placeholder="" value="iot.1nce.net"/>
</div>
<br />
<br />
Expand All @@ -79,9 +79,9 @@
<div class="col-9 col-sm-12">
<div class="form-group">
<select class="form-select" id="input-cell-tech">
<option>auto</option>
<option>GSM</option>
<option>NBIoT</option>
<option>auto</option>
</select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion insighioNode/www/step-5-measurements.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<div class="col-8 col-sm-12">
<div class="form-group">
<label class="form-switch">
<input type="checkbox" id="input-ota" />
<input type="checkbox" id="input-ota" checked />
<i class="form-icon"></i>
</label>
</div>
Expand Down
6 changes: 3 additions & 3 deletions insighioNode/www/step-6-timing.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<label class="form-label" for="input-example-cellular">Sleep Period (seconds)</label>
</div>
<div class="col-3 col-sm-12">
<input class="form-input constr-field" type="number" id="input-period" value=600 />
<input class="form-input constr-field" type="number" id="input-period" value=300 />
</div>
<div class="column col-3 col-mr-auto"></div>
</div>
Expand All @@ -95,7 +95,7 @@
<div class="col-8 col-sm-12">
<div class="form-group">
<label class="form-switch">
<input type="checkbox" id="input-ins-batch-upload-enable" onclick="sensorStatusChanged('ins-batch-upload')" />
<input type="checkbox" id="input-ins-batch-upload-enable" onclick="sensorStatusChanged('ins-batch-upload')" checked/>
<i class="form-icon"></i>
</label>
</div>
Expand All @@ -111,7 +111,7 @@
</label>
</div>
<div class="col-3 col-sm-12">
<input class="form-input constr-field" type="number" id="input-message-buffer-size" value=50 />
<input class="form-input constr-field" type="number" id="input-message-buffer-size" value=144 />
</div>
<div class="column col-5 col-mr-auto"></div>
</div>
Expand Down

0 comments on commit 141f10e

Please sign in to comment.