Skip to content

Commit

Permalink
Merge pull request #9 from jaketeater/master
Browse files Browse the repository at this point in the history
Firmware: V1.0.0-beta.4
  • Loading branch information
jaketeater authored Mar 22, 2024
2 parents b488570 + 0c50d53 commit 2847948
Show file tree
Hide file tree
Showing 26 changed files with 386,842 additions and 28 deletions.
14 changes: 9 additions & 5 deletions firmware/Radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct RadioConfig {
// Intervals
int debug_status_update_interval_ms = 5000;
int status_check_interval_ms = 50;
int wifi_disconnect_timeout_ms = 900000;

// Remote Config
bool remote_config = false;
Expand All @@ -114,6 +115,7 @@ class Radio {
unsigned long m_last_status_check_ = 0;
unsigned long m_last_remote_config_retrieved_ = 0;
unsigned long m_last_reconnection_attempt = 0;
unsigned long m_last_wifi_connected = 0;

/*
Expand Down Expand Up @@ -588,15 +590,17 @@ Try

if (WiFi.isConnected()) {
m_led_status.clear_status(RADIO_STATUS_400_WIFI_CONNECTION_LOST);
m_last_wifi_connected = millis();
} else {
if (m_debug_mode) Serial.println("Reconnecting to WiFi...");
m_led_status.set_status(RADIO_STATUS_400_WIFI_CONNECTION_LOST);
WiFi.disconnect();
WiFi.reconnect();

// Sleep to allow it to reconnect before triggering another disconnect.
delay(10000);

// If it's been more than wifi_disconnect_timeout_ms since it's been connected to wifi, restart the esp.
if (millis() > m_last_wifi_connected + m_radio_config->wifi_disconnect_timeout_ms) {
ESP.restart();
return;
}
WiFi.reconnect();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion firmware/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ States:
- Red (blinking) LED_STATUS_ERROR_BLINKING error (blinking)
*/
#define FIRMWARE_VERSION "v1.0.0-beta.3"
#define FIRMWARE_VERSION "v1.0.0-beta.4"

#include <WiFiManager.h>
#include "Audio.h"
Expand Down
9 changes: 6 additions & 3 deletions radio-programmer/qr_code_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def extract_uuid(s):
def detect_and_decode_qr():
# Initialize the webcam
# Adding cv2.CAP_DSHOW increased the init speed
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
print("Connecting to camera: 0")
# cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
cap = cv2.VideoCapture(0)
print("Connected")
cap.set(3, 1920)
cap.set(4, 1080)

Expand Down Expand Up @@ -44,8 +47,8 @@ def detect_and_decode_qr():
uuid = extract_uuid(data)
print(f"Found: {uuid}, {data}")
return uuid, data
except:
pass
except Exception as e:
print("Trying again: ", e, flush=True)
finally:
# When everything done, release the capture
cap.release()
Expand Down
Binary file added radio-programmer/v1.0.0-beta.2/firmware.ino.bin
Binary file not shown.
Binary file not shown.
Binary file added radio-programmer/v1.0.0-beta.2/firmware.ino.elf
Binary file not shown.
130,497 changes: 130,497 additions & 0 deletions radio-programmer/v1.0.0-beta.2/firmware.ino.map

Large diffs are not rendered by default.

Binary file not shown.
Binary file added radio-programmer/v1.0.0-beta.3/firmware.ino.bin
Binary file not shown.
Binary file not shown.
Binary file added radio-programmer/v1.0.0-beta.3/firmware.ino.elf
Binary file not shown.
128,090 changes: 128,090 additions & 0 deletions radio-programmer/v1.0.0-beta.3/firmware.ino.map

Large diffs are not rendered by default.

Binary file not shown.
Binary file added radio-programmer/v1.0.0-beta.4/firmware.ino.bin
Binary file not shown.
Binary file not shown.
Binary file added radio-programmer/v1.0.0-beta.4/firmware.ino.elf
Binary file not shown.
128,088 changes: 128,088 additions & 0 deletions radio-programmer/v1.0.0-beta.4/firmware.ino.map

Large diffs are not rendered by default.

Binary file not shown.
20 changes: 20 additions & 0 deletions station-configuration-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://vuejs.org/v2/cookbook/dockerize-vuejs-app.html

# build stage
FROM node:17 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage

COPY --from=build-stage /app/dist /usr/share/nginx/html/

COPY default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
15 changes: 15 additions & 0 deletions station-configuration-client/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2 changes: 2 additions & 0 deletions station-configuration-client/docker-build-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build . -t jaketeater/super-simple-radio-configuration-client:latest
docker push jaketeater/super-simple-radio-configuration-client:latest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
- host: {{ .Values.api.host }}
http:
paths:
- path: /
- path: {{ .Values.api.path }}
pathType: Prefix

# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/#IngressBackend
Expand Down
42 changes: 42 additions & 0 deletions station-configuration-helm-chart/templates/client/Deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.client.name }}-deployment
labels:
app: {{ .Values.client.name }}-label

# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/#DeploymentSpec
spec:
replicas: {{ .Values.client.replicas }}
selector:
matchLabels:
app: {{ .Values.client.name }}-label

# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-template-v1/#PodTemplateSpec
template:
metadata:
labels:
app: {{ .Values.client.name }}-label

# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec
spec:

# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container
containers:
- name: {{ .Values.client.name }}-container
image: {{ .Values.client.image }}:{{ .Values.client.imageTag }}

imagePullPolicy: Always

ports:
- containerPort: {{ .Values.client.containerPort }}

# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
livenessProbe:
httpGet:
path: /
port: {{ .Values.client.containerPort }}
initialDelaySeconds: 7
periodSeconds: 3
timeoutSeconds: 2
23 changes: 23 additions & 0 deletions station-configuration-helm-chart/templates/client/Ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.client.name }}-ingress

# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/#IngressSpec
spec:
rules:

# can be host or path - https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource
- host: {{ .Values.client.host }}
http:
paths:
- path: {{ .Values.client.path }}
pathType: Prefix

# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/#IngressBackend
backend:
service:
name: {{ .Values.client.name }}-service
port:
number: {{ .Values.client.ingressPort }}
18 changes: 18 additions & 0 deletions station-configuration-helm-chart/templates/client/Service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.client.name }}-service

# https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceSpec
spec:
selector:
app: {{ .Values.client.name }}-label

ports:
- protocol: TCP
port: {{ .Values.client.servicePort }}
targetPort: {{ .Values.client.containerPort }}

# https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
type: NodePort
48 changes: 30 additions & 18 deletions station-configuration-helm-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
api:
name: ssr-config-api
replicas: 1
image: jaketeater/super-simple-radio-station-config-api
imageTag: latest
containerPort: 80
servicePort: 80
ingressPort: 80
host: config.acc-radio.raiotech.com

# <add to a secrets.yaml file>
# api:
# FLASK_SECRET_KEY: <insert your value>
# WEBSITE_DB_HOST: <insert your value>
# WEBSITE_DB_USER: <insert your value>
# WEBSITE_DB_PASS: <insert your value>
# WEBSITE_DB_DATABASE: <insert your value>
# PASSWORD_SALT: <insert your value>
api:
name: ssr-config-api
replicas: 1
path: /api/
image: jaketeater/super-simple-radio-station-config-api
imageTag: latest
containerPort: 80
servicePort: 80
ingressPort: 80
host: config.acc-radio.raiotech.com

client:
name: ssr-client
replicas: 1
path: /
image: jaketeater/super-simple-radio-configuration-client
imageTag: latest
containerPort: 80
servicePort: 80
ingressPort: 80
host: config.acc-radio.raiotech.com

# <add to a secrets.yaml file>
# api:
# FLASK_SECRET_KEY: <insert your value>
# WEBSITE_DB_HOST: <insert your value>
# WEBSITE_DB_USER: <insert your value>
# WEBSITE_DB_PASS: <insert your value>
# WEBSITE_DB_DATABASE: <insert your value>
# PASSWORD_SALT: <insert your value>

0 comments on commit 2847948

Please sign in to comment.