Skip to content

Commit 3a17f09

Browse files
authored
Merge pull request #163 from lucidcode/feature/export-settings
Add command to export config file
2 parents f5d2ebd + fda3636 commit 3a17f09

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

release/firmware.bin

256 Bytes
Binary file not shown.

software/ble.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ def send_config(self, directory, config):
120120
self.chunks_sent = 0
121121
self.sending_file = True
122122

123+
def send_file(self, config):
124+
if self.sending_file:
125+
return
126+
if self.sending_image:
127+
return
128+
129+
gc.collect()
130+
131+
self.cframe = bytearray(len(config))
132+
self.cframe[:] = config
133+
134+
self.chunks_sent = 0
135+
self.sending_file = True
136+
123137
def process_file(self):
124138
if self.wait > 0:
125139
self.wait -= 1

software/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ujson
22
import os
3+
import binascii
34

45
class inspec_config:
56
def __init__(self):
@@ -87,6 +88,11 @@ def get(self, setting):
8788

8889
return ""
8990

91+
def get_config_file(self):
92+
with open('config.txt', mode='rb') as file:
93+
content = bytearray(file.read())
94+
return content
95+
9096
def set(self, setting, value):
9197
string_settings = ["PixelFormat", "FrameSize", "LEDs", "Researcher", "Algorithm", "Mode", "AccessPointName", "AccessPointPassword", "WiFiNetworkName", "WiFiKey"]
9298
if setting in string_settings:

software/inspec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ def ble_message_received(self, message):
163163
if message == "request.errors":
164164
self.comms.send_errors = True
165165

166+
if message == "request.settings":
167+
config = self.config.get_config_file()
168+
self.comms.send_file(config)
169+
166170
if message.startswith("update.setting."):
167171
message = message.replace("update.setting.", "")
168172
setting, value = message.split(':')

0 commit comments

Comments
 (0)