1
0
mirror of https://github.com/daniviga/bite.git synced 2024-11-25 06:16:13 +01:00

Compare commits

..

No commits in common. "cc93c5ae7596f1553f78d4e35bcff7f643844396" and "f120fac87804a1bdeb3c2a06b93eb1d1fd4dfcc0" have entirely different histories.

9 changed files with 32 additions and 61 deletions

View File

@ -35,21 +35,6 @@ but it is advised to directly use a minimal Linux VM instead
`podman`, with `podman-docker` is the recommended way to run BITE, in rootless mode. `podman`, with `podman-docker` is the recommended way to run BITE, in rootless mode.
Requirements are:
- `podman`
- `podman-docker`
- `catatonit`
- `docker-compose`
On Fedora 33+:
```bash
sudo dnf install -y podman podman-docker catatonit docker-compose
```
To setup `podman` run:
```bash ```bash
systemctl start --user podman.socket systemctl start --user podman.socket
export DOCKER_HOST=unix://run/user/$UID/podman/podman.sock export DOCKER_HOST=unix://run/user/$UID/podman/podman.sock

View File

@ -30,10 +30,8 @@ const byte mac[] = {
const char serial[] = SERIAL; const char serial[] = SERIAL;
struct netConfig { struct netConfig {
IPAddress iot_address = IOT_IP; IPAddress address = REMOTE_IP;
unsigned int iot_port = IOT_PORT; unsigned int port = REMOTE_PORT;
IPAddress ntp_address = NTP_IP;
unsigned int ntp_port = NTP_PORT;
} config; } config;
void setup() { void setup() {

View File

@ -19,7 +19,5 @@
*/ */
#define SERIAL "uno_1" #define SERIAL "uno_1"
#define IOT_IP {192, 168, 10, 1} #define REMOTE_IP {192, 168, 0, 1}
#define IOT_PORT 80 #define REMOTE_PORT 80
#define NTP_IP {192, 168, 10, 1}
#define NTP_PORT 123

View File

@ -31,6 +31,8 @@
#define TELEMETRY_DELAY 10 // second between telemetry samples #define TELEMETRY_DELAY 10 // second between telemetry samples
#define AREF_VOLTAGE 3.3 // set aref voltage to 3.3v instead of default 5v #define AREF_VOLTAGE 3.3 // set aref voltage to 3.3v instead of default 5v
char serial[9];
// const String serverName = "sensor.server.domain"; // const String serverName = "sensor.server.domain";
const size_t capacity = 2 * JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(2) + 20; const size_t capacity = 2 * JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(2) + 20;
@ -48,13 +50,11 @@ EthernetClient ethClient;
PubSubClient clientMQTT(ethClient); PubSubClient clientMQTT(ethClient);
struct netConfig { struct netConfig {
IPAddress iot_address; IPAddress address;
unsigned int iot_port; unsigned int port;
IPAddress ntp_address; };
unsigned int ntp_port; // not used netConfig config;
} config;
char serial[9];
const String apiURL = "/api/device/subscribe/"; const String apiURL = "/api/device/subscribe/";
const String telemetryURL = "/telemetry/"; const String telemetryURL = "/telemetry/";
@ -89,17 +89,15 @@ void setup(void) {
Serial.println(Ethernet.localIP()); Serial.println(Ethernet.localIP());
Serial.println(); Serial.println();
Serial.print("Connecting to: "); Serial.print("Connecting to: ");
Serial.print(config.iot_address); Serial.print(config.address);
Serial.print(":"); Serial.print(":");
Serial.print(config.iot_port); Serial.print(config.port);
Serial.print(" every "); Serial.print(" every ");
Serial.print(TELEMETRY_DELAY); Serial.print(TELEMETRY_DELAY);
Serial.println("s"); Serial.println("s");
#if USE_INTERNAL_NTP #if USE_INTERNAL_NTP
Serial.print("Using NTP: "); timeClient.setPoolServerIP(config.address);
Serial.println(config.ntp_address);
timeClient.setPoolServerIP(config.ntp_address);
#endif #endif
timeClient.begin(); timeClient.begin();
if (timeClient.update()) { if (timeClient.update()) {
@ -117,7 +115,7 @@ void setup(void) {
// payload["id"] = serverName; // payload["id"] = serverName;
#if USE_MQTT #if USE_MQTT
clientMQTT.setServer(config.iot_address, 1883); clientMQTT.setServer(config.address, 1883);
#endif #endif
} }
@ -177,14 +175,14 @@ void publishData(const netConfig &mqtt, const DynamicJsonDocument &json) {
#endif #endif
void postData(const netConfig &postAPI, const String &URL, const DynamicJsonDocument &json) { void postData(const netConfig &postAPI, const String &URL, const DynamicJsonDocument &json) {
if (ethClient.connect(postAPI.iot_address, postAPI.iot_port)) { if (ethClient.connect(postAPI.address, postAPI.port)) {
ethClient.print("POST "); ethClient.print("POST ");
ethClient.print(URL); ethClient.print(URL);
ethClient.println(" HTTP/1.1"); ethClient.println(" HTTP/1.1");
ethClient.print("Host: "); ethClient.print("Host: ");
ethClient.print(postAPI.iot_address); ethClient.print(postAPI.address);
ethClient.print(":"); ethClient.print(":");
ethClient.println(postAPI.iot_port); ethClient.println(postAPI.port);
ethClient.println("Content-Type: application/json"); ethClient.println("Content-Type: application/json");
ethClient.print("Content-Length: "); ethClient.print("Content-Length: ");
ethClient.println(measureJson(json)); ethClient.println(measureJson(json));

View File

@ -43,7 +43,7 @@ services:
timescale: timescale:
<<: *service_default <<: *service_default
image: timescale/timescaledb:latest-pg14 image: timescale/timescaledb:latest-pg12
environment: environment:
POSTGRES_USER: "bite" POSTGRES_USER: "bite"
POSTGRES_PASSWORD: "password" POSTGRES_PASSWORD: "password"

View File

@ -24,7 +24,7 @@ services:
image: docker:dind image: docker:dind
privileged: true privileged: true
environment: environment:
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR:
networks: networks:
- net - net
ports: ports:

View File

@ -31,10 +31,8 @@ const char* ssid = SECRET_SSID;
const char* password = SECRET_PASSWORD; const char* password = SECRET_PASSWORD;
struct netConfig { struct netConfig {
IPAddress iot_address = IOT_IP; IPAddress address = REMOTE_IP;
unsigned int iot_port = IOT_PORT; unsigned int port = REMOTE_PORT;
IPAddress ntp_address = NTP_IP;
unsigned int ntp_port = NTP_PORT;
} config; } config;
void setup() { void setup() {

View File

@ -19,9 +19,7 @@
*/ */
#define SERIAL "<fillme>" #define SERIAL "<fillme>"
#define IOT_IP {192, 168, 10, 1} #define REMOTE_IP {192, 168, 0, 1}
#define IOT_PORT 80 #define REMOTE_PORT 80
#define NTP_IP {192, 168, 10, 1}
#define NTP_PORT 123
#define SECRET_SSID "<fillme>" #define SECRET_SSID "<fillme>"
#define SECRET_PASSWORD "<fillme>" #define SECRET_PASSWORD "<fillme>"

View File

@ -48,10 +48,8 @@ WiFiClient ethClient;
PubSubClient clientMQTT(ethClient); PubSubClient clientMQTT(ethClient);
struct netConfig { struct netConfig {
IPAddress iot_address; IPAddress address;
unsigned int iot_port; unsigned int port;
IPAddress ntp_address;
unsigned int ntp_port; // not used
} config; } config;
char* serial; char* serial;
@ -96,17 +94,15 @@ void setup(void) {
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
Serial.println(); Serial.println();
Serial.print("Connecting to: "); Serial.print("Connecting to: ");
Serial.print(config.iot_address.toString()); Serial.print(config.address.toString());
Serial.print(":"); Serial.print(":");
Serial.print(config.iot_port); Serial.print(config.port);
Serial.print(" every "); Serial.print(" every ");
Serial.print(TELEMETRY_DELAY); Serial.print(TELEMETRY_DELAY);
Serial.println("s"); Serial.println("s");
#if USE_INTERNAL_NTP #if USE_INTERNAL_NTP
Serial.print("Using NTP: "); timeClient.setPoolServerIP(config.address);
Serial.println(config.ntp_address.toString());
timeClient.setPoolServerIP(config.ntp_address);
#endif #endif
timeClient.begin(); timeClient.begin();
if (timeClient.update()) { if (timeClient.update()) {
@ -124,7 +120,7 @@ void setup(void) {
// payload["id"] = serverName; // payload["id"] = serverName;
#if USE_MQTT #if USE_MQTT
clientMQTT.setServer(config.iot_address, 1883); clientMQTT.setServer(config.address, 1883);
#endif #endif
} }
@ -176,14 +172,14 @@ void publishData(const netConfig &mqtt, const DynamicJsonDocument &json) {
#endif #endif
void postData(const netConfig &postAPI, const String &URL, const DynamicJsonDocument &json) { void postData(const netConfig &postAPI, const String &URL, const DynamicJsonDocument &json) {
if (ethClient.connect(postAPI.iot_address, postAPI.iot_port)) { if (ethClient.connect(postAPI.address, postAPI.port)) {
ethClient.print("POST "); ethClient.print("POST ");
ethClient.print(URL); ethClient.print(URL);
ethClient.println(" HTTP/1.1"); ethClient.println(" HTTP/1.1");
ethClient.print("Host: "); ethClient.print("Host: ");
ethClient.print(postAPI.iot_address.toString()); ethClient.print(postAPI.address.toString());
ethClient.print(":"); ethClient.print(":");
ethClient.println(postAPI.iot_port); ethClient.println(postAPI.port);
ethClient.println("Content-Type: application/json"); ethClient.println("Content-Type: application/json");
ethClient.print("Content-Length: "); ethClient.print("Content-Length: ");
ethClient.println(measureJson(json)); ethClient.println(measureJson(json));