Delete src/modules/mod_bitchat_mesh.c

removed till i see what happens with jacks case
This commit is contained in:
dcosnet 2026-07-28 02:02:23 -04:00
parent 0d3bcabcfc
commit f8f17708d9
1 changed files with 0 additions and 168 deletions

View File

@ -1,168 +0,0 @@
/*
* mod_bitchat_mesh.c -- OreBolt OS bitchat mesh networking module
* ====================================================================
*
* SPDX-License-Identifier: AGPL-3.0-only
*
* Copyright (C) 2026 OreBolt OS Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* --------------------------------------------------------------------
*
* WHY AGPL FOR THE BITCHAT LAYER?
*
* The bitchat mesh layer is the part of OreBolt OS that runs as a
* networked service: nodes exchange messages with other nodes, and any
* user interacting with a bitchat node over the mesh is effectively
* interacting with the software "over a network" within the meaning of
* AGPL v3 §13. AGPL v3 closes the SaaS loophole that GPL leaves open:
*
* * If someone forks this module, runs it on a modified bitchat node,
* and lets other users interact with that node over the mesh, they
* MUST make their modified source available to those users via the
* "Written Offer" mechanism in §13(d). Pure GPL would not require
* this for network-only interaction.
*
* * AGPL v3 §6 (User Product) also blocks tivoization on the device
* itself: the H2 firmware must allow installation of modified
* versions of bitchat.mod. This is exactly what we want for a
* hackable pocket rig -- users own the device they carry.
*
* * The AGPL boundary is clean: bitchat is a single .mod binary that
* links against liblvgl.so (MIT) and liborebolt.a (GPL-2.0-or-later).
* Under AGPL v3 §13, the AGPL covers the bitchat module itself and
* its modifications; it does NOT retroactively relicense the rest
* of OreBolt OS because the rest of OreBolt OS is NOT a derivative work
* of bitchat (bitchat links TO them, not the other way around).
* See LICENSE.md §4 for the full boundary analysis.
*
* If you modify this file, you MUST:
* 1. Keep this license header.
* 2. Make your modified source available to anyone who interacts with
* your modified bitchat node over the mesh (AGPL v3 §13).
* 3. Bump the BITCHAT_PROTOCOL_VERSION if you change the wire format.
*
* The build system enforces an AGPL_BITCHAT preprocessor define so the
* running binary self-identifies (see build.sh Phase 7 verify step).
* --------------------------------------------------------------------
*/
#ifdef AGPL_BITCHAT
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "h2_ui.h"
#include "log_manager.h"
#include "panic_purge_api.h"
#define BITCHAT_PROTOCOL_VERSION 1
#define BITCHAT_LICENSE_STRING "AGPL-3.0-only"
#define BITCHAT_SOURCE_URL "https://example.invalid/orebolt-bitchat-src"
/* ^ Replace with the actual Written Offer URL before shipping. AGPL v3 §13(d). */
/* Mesh message types -- wire format is little-endian, packed. */
typedef enum {
BITCHAT_MSG_HELLO = 0x01,
BITCHAT_MSG_ACK = 0x02,
BITCHAT_MSG_BROADCAST= 0x03,
BITCHAT_MSG_DIRECT = 0x04,
BITCHAT_MSG_PURGE = 0xFE, /* used by panic_purge_api.h */
BITCHAT_MSG_LICENSE = 0xFF /* AGPL v3 §13 -- advertise source URL */
} bitchat_msg_type_t;
#pragma pack(push, 1)
typedef struct {
uint8_t magic[4]; /* "BTCH" */
uint8_t protocol_ver;
uint8_t msg_type;
uint16_t payload_len;
uint32_t sender_id;
uint32_t timestamp;
/* payload follows */
} bitchat_hdr_t;
#pragma pack(pop)
#define BITCHAT_MAGIC ((uint8_t[]) {'B','T','C','H'})
static lv_obj_t *bitchat_screen = NULL;
static lv_obj_t *bitchat_log_label = NULL;
/* Build a license-advertisement message. Sent on every mesh HELLO so
* any user interacting with this node over the network is informed of
* their AGPL v3 §13 source-code rights. */
static size_t bitchat_build_license_msg(uint8_t *out, size_t cap)
{
const char *url = BITCHAT_SOURCE_URL;
size_t url_len = strlen(url);
if (cap < sizeof(bitchat_hdr_t) + url_len + 1) return 0;
bitchat_hdr_t *h = (bitchat_hdr_t*)out;
memcpy(h->magic, BITCHAT_MAGIC, 4);
h->protocol_ver = BITCHAT_PROTOCOL_VERSION;
h->msg_type = BITCHAT_MSG_LICENSE;
h->payload_len = (uint16_t)(url_len + 1);
h->sender_id = 0; /* TODO: device-unique ID from MAC */
h->timestamp = 0; /* TODO: RTC */
memcpy(out + sizeof(bitchat_hdr_t), url, url_len + 1);
return sizeof(bitchat_hdr_t) + url_len + 1;
}
/* LVGL UI: a single screen with a scrollable log and a "Send Hello" button. */
void bitchat_init(lv_obj_t *parent)
{
bitchat_screen = lv_obj_create(parent);
lv_obj_set_size(bitchat_screen, H2_LCD_WIDTH - 4, H2_LCD_HEIGHT - 4);
lv_obj_center(bitchat_screen);
bitchat_log_label = lv_label_create(bitchat_screen);
lv_label_set_text(bitchat_log_label,
"bitchat mesh v" STRINGIFY(BITCHAT_PROTOCOL_VERSION) "\n"
"License: " BITCHAT_LICENSE_STRING "\n"
"Source: " BITCHAT_SOURCE_URL "\n"
"(idle)");
lv_obj_set_width(bitchat_log_label, H2_LCD_WIDTH - 16);
lv_label_set_long_mode(bitchat_log_label, LV_LABEL_LONG_WRAP);
LOG_INF("bitchat init: protocol=%d license=%s",
BITCHAT_PROTOCOL_VERSION, BITCHAT_LICENSE_STRING);
/* Advertise source URL on first mesh hello. */
uint8_t buf[256];
size_t n = bitchat_build_license_msg(buf, sizeof(buf));
if (n > 0) {
/* TODO: mod_radio_input_multiplex_send(buf, n); */
LOG_DBG("queued license-advertisement msg (%zu bytes)", n);
}
}
void bitchat_deinit(void)
{
if (bitchat_screen) {
lv_obj_del(bitchat_screen);
bitchat_screen = NULL;
bitchat_log_label = NULL;
}
LOG_INF("bitchat deinit");
}
/* Helper macro for the version string in the UI label. */
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#else /* !AGPL_BITCHAT */
# error "mod_bitchat_mesh.c must be compiled with -DAGPL_BITCHAT (see Makefile.orebolt-v1.5). \
This guard prevents accidental compilation under a different license."
#endif /* AGPL_BITCHAT */