2 Commits

Author SHA1 Message Date
Cynopolis
6781c05a3c Finished deployment script 2025-04-02 11:52:01 -04:00
Cynopolis
7aeb6b8aad Added an installer script 2025-04-02 11:47:04 -04:00
26 changed files with 89 additions and 15004 deletions

89
app.py Normal file
View File

@@ -0,0 +1,89 @@
from flask import Flask, render_template, request, jsonify
import meshtastic
from MeshtasticLogger import MeshtasticLogger
import os
messages = []
app = Flask(__name__)
interface = meshtastic.serial_interface.SerialInterface()
log_path = "logs/mesh_logs.log"
try:
with open(log_path, 'r') as file:
for line in file:
messages.append(line)
except FileNotFoundError:
# make the log directory if it isn't already there
with open(log_path, "w") as file:
file.write("Begin logs")
def web_print(message: str):
with app.app_context():
print(message)
messages.append(message)
get_messages()
def callback(message: str):
web_print(message)
def help_response():
help_message: str = "Commands:\nhelp - show this message\clear - clear the text log\nsend <text> - sends text to all channels\nchannel <number> - sets the current channel (0-7)\n"
web_print(help_message)
logger = MeshtasticLogger(interface, "logs/mesh_logs.log", channel=1, message_received_callback=callback)
def channel_response(args: list[str]):
if(len(args) < 2):
web_print(f"Current channel number: {logger.channel}")
return
channel: int = int(args[1])
if channel > 7 or channel < 0:
web_print("Channel must be between 0 and 7")
else:
try:
logger.channel = channel
except Exception as e:
web_print(e)
else:
web_print(f"Channel set to {channel}")
def send_response(args: list[str], command: str):
if len(args) < 2:
web_print("Please provide text to send")
else:
logger.send(command[5:])
web_print(f"Sent: {command[5:]}")
def parse_command(command):
args = command.split(" ")
if len(args) < 1:
return True
if args[0] == "clear":
messages.clear()
elif args[0] == "help":
help_response()
elif args[0] == "channel":
channel_response(args)
elif args[0] == "send":
send_response(args, command)
else:
web_print("Command not recognized. Type \'help\' for a list of commands.")
@app.route('/')
def index():
return render_template('index.html')
@app.route('/send', methods=['POST'])
def send():
data = request.json
message = data.get("message", "")
parse_command(message)
return jsonify({"messages": messages})
@app.route('/messages', methods=['GET'])
def get_messages():
return jsonify({"messages": messages})
if __name__ == '__main__':
app.run(host="0.0.0.0", port=80, debug=True)

View File

@@ -1,18 +0,0 @@
class CommandHandler:
def __init__(self, print_method):
self.commands: dict = {}
self.print = print_method
def register_callback(self, key: str, callback):
self.commands[key.lower()] = callback
def parse_command(self, command : str):
args :list[str] = command.split(" ")
if args[0].lower() in self.commands:
return_message = self.commands[args[0].lower()](args[1:])
if not (return_message is None):
self.print(return_message)
else:
self.print("Command not recognized. Type 'help' for a list of commands.")

View File

@@ -1,94 +0,0 @@
from flask import Flask, render_template, request, jsonify
import meshtastic
from MeshtasticLogger import MeshtasticLogger
from CommandHandler import CommandHandler
import os
# -------------------------------
# Initialize data and objects
# -------------------------------
messages = []
app = Flask(__name__)
interface = meshtastic.serial_interface.SerialInterface()
log_path = "logs/mesh_logs.log"
try:
with open(log_path, 'r') as file:
for line in file:
messages.append(line)
except FileNotFoundError:
# make the log directory if it isn't already there
with open(log_path, "w") as file:
file.write("Begin logs")
def web_print(message: str):
with app.app_context():
print(message)
messages.append(message)
get_messages()
command_handler: CommandHandler = CommandHandler(web_print)
logger = MeshtasticLogger(interface, "logs/mesh_logs.log", channel=1, message_received_callback=web_print)
# -------------------------
# Command Callback Handlers
# -------------------------
def help_response(args: list[str]):
return "Commands:\nhelp - show this message\clear - clear the text log\nsend <text> - sends text to all channels\nchannel <number> - sets the current channel (0-7)\n"
def channel_response(args: list[str]):
if len(args) < 1:
return f"Current channel number: {logger.channel}"
channel: int = int(args[0])
if channel > 7 or channel < 0:
return "Channel must be between 0 and 7"
try:
logger.channel = channel
except Exception as e:
return e
return f"Channel set to {channel}"
def send_response(args: list[str]):
if len(args) == 0:
return "Please provide text to send"
command = ""
for arg in args:
command += arg + " "
command = command[:-1] # remove the trailing space
logger.send(command)
return_message = f"Sent: {command}"
return return_message
def clear_response(args):
messages.clear()
return None
# register callbacks
command_handler.register_callback("clear", clear_response)
command_handler.register_callback("help", help_response)
command_handler.register_callback("channel", channel_response)
command_handler.register_callback("send", send_response)
# -----------------------
# Flask Callback Handlers
# -----------------------
@app.route('/')
def index():
return render_template('index.html')
@app.route('/send', methods=['POST'])
def send():
data = request.json
message = data.get("message", "")
command_handler.parse_command(message)
return jsonify({"messages": messages})
@app.route('/messages', methods=['GET'])
def get_messages():
return jsonify({"messages": messages})

View File

@@ -1,17 +0,0 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false
[*.md]
max_line_length = off
trim_trailing_whitespace = false

42
frontend/.gitignore vendored
View File

@@ -1,42 +0,0 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

View File

@@ -1,59 +0,0 @@
# Frontend
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.6.
## Development server
To start a local development server, run:
```bash
ng serve
```
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
## Code scaffolding
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
```bash
ng generate component component-name
```
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
```bash
ng generate --help
```
## Building
To build the project run:
```bash
ng build
```
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
## Running unit tests
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
```bash
ng test
```
## Running end-to-end tests
For end-to-end (e2e) testing, run:
```bash
ng e2e
```
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
## Additional Resources
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.

View File

@@ -1,98 +0,0 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/frontend",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "frontend:build:production"
},
"development": {
"buildTarget": "frontend:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.css"
],
"scripts": []
}
}
}
}
}
}

14472
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,39 +0,0 @@
{
"name": "frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/cdk": "^19.2.8",
"@angular/common": "^19.2.0",
"@angular/compiler": "^19.2.0",
"@angular/core": "^19.2.0",
"@angular/forms": "^19.2.0",
"@angular/material": "^19.2.8",
"@angular/platform-browser": "^19.2.0",
"@angular/platform-browser-dynamic": "^19.2.0",
"@angular/router": "^19.2.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.2.6",
"@angular/cli": "^19.2.6",
"@angular/compiler-cli": "^19.2.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.7.2"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,7 +0,0 @@
<head>
<title>My Angular App</title>
</head>
<body>
<h1>Welcome to my Angular app!</h1>
</body>

View File

@@ -1,29 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have the 'frontend' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('frontend');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, frontend');
});
});

View File

@@ -1,12 +0,0 @@
import { Component } from '@angular/core';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
@Component({
selector: 'app-root',
imports: [MatSlideToggleModule],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'frontend';
}

View File

@@ -1,8 +0,0 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
};

View File

@@ -1,3 +0,0 @@
import { Routes } from '@angular/router';
export const routes: Routes = [];

View File

@@ -1,12 +0,0 @@
import { Component } from '@angular/core';
import { MatTabsModule } from '@angular/material/tabs';
/**
* @title Basic use of the tab group
*/
@Component({
selector: 'tab-group-test',
templateUrl: 'tab-group.html',
imports: [MatTabsModule],
})
export class TabGroup { }

View File

@@ -1,23 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic use of the tab group</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography mat-app-background">
<tab-group-test>
<mat-tab label="Chat"> Content 1 </mat-tab>
<mat-tab label="Settings"> Content 2 </mat-tab>
<mat-tab label="Nodes"> Content 3 </mat-tab>
</tab-group-test>
<div style="margin-top: 24px">Current build: 19.2.8</div>
</body>
</html>

View File

@@ -1,10 +0,0 @@
import { importProvidersFrom } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimations } from '@angular/platform-browser/animations';
import { VERSION as MAT_VERSION, provideNativeDateAdapter } from '@angular/material/core';
import { TabGroup } from './app/tab-group/tab-group';
bootstrapApplication(TabGroup, {
providers: [provideAnimations(), provideHttpClient(), provideNativeDateAdapter()],
}).catch(err => console.error(err));

View File

@@ -1,4 +0,0 @@
/* You can add global styles to this file, and also import other style files */
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

View File

@@ -1,15 +0,0 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

View File

@@ -1,27 +0,0 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"isolatedModules": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022"
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

View File

@@ -1,15 +0,0 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}