aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/compiledb-full-path-mingw.sh2
-rw-r--r--scripts/db-init.sql20
-rw-r--r--scripts/db-privileges.sql1
-rwxr-xr-xscripts/dummy-server.py48
4 files changed, 61 insertions, 10 deletions
diff --git a/scripts/compiledb-full-path-mingw.sh b/scripts/compiledb-full-path-mingw.sh
index 8f95756..be45ca7 100755
--- a/scripts/compiledb-full-path-mingw.sh
+++ b/scripts/compiledb-full-path-mingw.sh
@@ -10,4 +10,4 @@ fixpath () {
fixpath arm-none-eabi-gcc
fixpath arm-none-eabi-objcopy
-sed "s#\"/c/#\"C:/#g" -i "$COMPILEDB_FILE"
+sed 's#"/\(.\)/#"\U\1:/#g' -i "$COMPILEDB_FILE" \ No newline at end of file
diff --git a/scripts/db-init.sql b/scripts/db-init.sql
index 4c4c4d4..2b0581c 100644
--- a/scripts/db-init.sql
+++ b/scripts/db-init.sql
@@ -1,9 +1,11 @@
-CREATE SCHEMA `WSdb`;
-CREATE TABLE `DAB1Pract1`.`tblMain` (
- `ID` INT GENERATED ALWAYS AS (),
- `temperature` DECIMAL(5,2) NULL,
- `humidity` DECIMAL(5,2) NULL,
- `pressure` DECIMAL(5,2) NULL,
- `time` DATETIME NULL,
- PRIMARY KEY (`ID`),
- UNIQUE INDEX `ID_UNIQUE` (`ID` ASC) VISIBLE);
+drop schema if exists `WSdb`;
+create schema if not exists `WSdb`;
+drop table if exists `WSdb`.`tblMain`;
+create table if not exists `WSdb`.`tblMain` (
+ id int unsigned not null auto_increment,
+ temperature decimal(5,2) null,
+ humidity decimal(5,2) null,
+ pressure decimal(5,2) null,
+ time datetime null,
+ primary key (id)
+);
diff --git a/scripts/db-privileges.sql b/scripts/db-privileges.sql
new file mode 100644
index 0000000..75f8fcc
--- /dev/null
+++ b/scripts/db-privileges.sql
@@ -0,0 +1 @@
+grant all privileges on WSdb.* to 'user'@'localhost';
diff --git a/scripts/dummy-server.py b/scripts/dummy-server.py
new file mode 100755
index 0000000..9350cab
--- /dev/null
+++ b/scripts/dummy-server.py
@@ -0,0 +1,48 @@
+#!/bin/python3
+
+"""
+this is a garbage python script that opens a tcp socket on localhost:33 for
+connecting with the qt client
+"""
+
+import socketserver
+from random import randint
+
+def hexpad(n, pad):
+ return hex(n)[2:].zfill(pad)
+
+def bs(str):
+ return bytes(str, 'utf-8')
+
+def r(max):
+ return randint(0, max)
+
+class DummyServer(socketserver.BaseRequestHandler):
+ def error(self):
+ self.request.sendall(bs("error\n"))
+
+ def ok(self, rows):
+ response = "id,temperature,humidity,atmospheric_pressure\n"
+ line_len = len("xxxx,xx,xx,xx\n")
+ retstr = f"ok,{hex(len(response) + rows * line_len)[2:]}\n"
+ retstr += response
+ for row in range(rows):
+ retstr += f"{hexpad(row, 4)},{hexpad(r(0xff), 2)},{hexpad(r(0xff), 2)},{hexpad(r(0xff), 2)}\n"
+ self.request.sendall(bs(retstr))
+
+ def handle(self):
+ self.data = self.request.recv(1024).strip()
+ if len(self.data) > 40: return self.error()
+ if not self.data.startswith(bs('last-records')): return self.error()
+ self.data = self.data.replace(bs('last-records'), bs(''))
+ try:
+ self.ok(int(self.data))
+ except ValueError:
+ self.error()
+
+if __name__ == "__main__":
+ socketserver.TCPServer.allow_reuse_address = True
+ with socketserver.TCPServer(("localhost", 33), DummyServer) as server:
+ server.serve_forever()
+
+