Commit Graph
39 Commits
Author SHA1 Message Date
callebtcandGitHub 83fbcca557 Implement iOS-compatible Direct Peer Detection (TTL Logic) (#574)
* Clean up direct peer detection logic (Max TTL) and remove unrelated routing/media changes

* cleanup fix
2026-01-15 15:24:24 +07:00
callebtcandGitHub c2f60d6ab2 announce peer ID in servicedata to prevent duplicate connections (#613) 2026-01-15 13:51:30 +07:00
callebtcandGitHub 66012e9fe9 Gossip mesh topology + source-based routing (#445)
* wip mesh graph

* gossip fix

* gossip works

* source-based routing wip

* log

* update spec to be explicit about intermediate hops only

* drop duplicate hops

* add to spec

* test

* forgot comma

* source routing v2

* add compression bomb protection

* v2 source routing

* fragmented packets inherit route

* update spec

* Gossip routing tmp with connection limit fixed (#569)

* fix: r8 exception for LocationManager (#566)

* fragmented packets inherit route

* update spec

* fix connection limits

* fix: deserialization issue with routed packets

* log

* dynamic fragment size

* fragment size

* add tests

* feat(gossip): implement two-way handshake for source routing edges

- Update MeshGraphService to track directed announcements
- Require bidirectional announcements for a 'confirmed' edge
- Update RoutePlanner to strictly use confirmed edges
- Update Mesh Topology debug view to show confirmed vs unconfirmed edges (solid vs dotted)

* docs: update SOURCE_ROUTING.md with two-way handshake requirement

* evict stale peers from mesh graph service

* better logging

* fix announce spe

* fix: empty route

* fix spec

* fix: compile error in DebugSettingsSheet and potential NPE in RoutePlanner

* revert

* try again
2026-01-13 04:18:07 +07:00
callebtcandGitHub eef831fe60 scan duration fix (#557) 2026-01-05 16:41:41 +07:00
callebtcandGitHub 3f8c236a72 Background persistence (#505)
* persistence step 1

* fix build

* messages in the background work, notifications not yet

* app state store

* DM icon shows up

* notification launches when app is closed!

* keep ui updated

* lifecycle fixes

* extensive logging, maybe revert later

* send nickname in announcement

* quit in notification

* setting in about sheet

* fix quit bitchat

* lifecycle fixes

* power mode based on background state

* stats for both direciotns

* fix graph persistence

* better counting

* count per device

* only compute when debug sheet is open? untested

* fix read receipts

* fix read receipts fully

* fix unread badge if messages have been read in focus

* foreground promotion fix

* fix app kill in notification

* adjust to new tor

* nice

* about sheet design
2025-12-13 16:43:39 +07:00
callebtcandGitHub a4ce8cc979 better tracking of first announce seen (#502) 2025-10-30 00:39:24 +01:00
callebtcandGitHub 633a506753 Media transfers (#440)
* tor voice wip

* worky BLE a bit

* can send sound

* remove tor

* ui cleanup

* recording time

* progress bar color

* nicknames for audio

* onboarding permissions no microphone

* may work

* fix destionation

* extend

* refactor voice input component

* fix keyboard collapse issue

* send images

* wip image open

* image sending works

* wip waveforms

* better

* better animation

* fix cursor for sending audio

* image sending animation

* image sending animation

* full screen image viewer

* gossip sync for fragments too

* reduce delays

* fix keyboard focus

* use v2 for file transfers

* do not sync fragments

* scrollable image viewer

* ui

* ui adjustments

* nicer animation

* seek through audio

* add spec

* add more details to documentation

* File sharing E2E:
- Add TLV BitchatFilePacket, FileSharingManager
- Implement sendFileNote in ChatViewModel
- File receive path: save to files/incoming and render [file] messages with FileMessageItem or FileSendingAnimation during transfer
- SAF FilePickerButton and dispatcher wiring; image/file choice to follow in MediaPickerOptions
- Add FileViewerDialog with system open/save, FileProvider and file_paths
- Hook transfer progress to file sending UI
- Manifest: READ_MEDIA_* and FileProvider
- Fix MessageHandler saving and prefix for non-image payloads
- Add helper utils (FileUtils)

* kinda wip

* fix buttons

* files half working

* wip file transfer

* file packet has 2-byte TLV and chunks. it wokrs but it sucks

* clean

* remove gossip sync for fragments

* fix audio and image rendering

* adjust FILE_SIZE TLV size too

* cleanup

* haptic

* private messages media

* read receipts for media

* use enum for message type not string

* delivery ack checks dont push content

* check

* animation fix

* refactor

* ui adjustments

* comments

* refactor

* fix crash on send and receive of the same file

* refactor notifications

* tests
2025-09-19 22:46:14 +02:00
callebtcandGitHub 73c91b9509 Plumtree sync (#393)
* wip plumtree

* sync works

* fix logging

* ttl to 0

* fix send packet to one peer

* spec

* wip GCS instead of bloom

* remove bloom filter remainders

* clean

* prune old announcements

* remove announcements from sync after LEAVE

* sync after 1 second

* pruning

* track own announcement and prune messages without announcements

* fix pruning

* getGcsMaxFilterBytes default value 400 bytes

* parameters
2025-09-14 03:32:10 +02:00
callebtcandGitHub c1e56188d6 Revert "Mesh gossip (#381)" (#394)
This reverts commit 0969c0641e.
2025-09-08 15:15:54 +02:00
callebtcandGitHub 0969c0641e Mesh gossip (#381)
* wip mesh graph

* gossip fix

* gossip works

* source-based routing wip

* log
2025-09-08 15:15:32 +02:00
callebtcandGitHub f47819a31e Debug button (#377)
* feat(debug): add DebugSettingsManager + DebugSettingsSheet scaffold and AboutSheet entry; groundwork for verbose logging, GATT controls, relay stats, device/scan views

* fix(debug): wire debug sheet launch via onShowDebug in AboutSheet from ChatScreen; add public start/stop server/client methods}

* fix(about): remove misplaced debug item block inside PoW section; keep debug launcher managed by ChatScreen only

* feat(debug): wire DebugSettingsSheet role switches to explicit startServer/stopServer and startClient/stopClient; expose role controls + disconnectAll on BluetoothConnectionManager; fix syntax error; build passes

* feat(debug): add connect/disconnect helpers; wire DebugSettingsSheet connect/disconnect actions to BluetoothConnectionManager

* feat(debug): add debug settings button at bottom of AboutSheet; wire onShowDebug callback to open DebugSettingsSheet from ChatScreen

* feat(debug): wire verbose logging into chat view via DebugSettingsManager; add rolling relay stats; push connected devices and scan results; ensure GATT role stop closes connections; log incoming packets and relay events; add UI polling for devices; build passes

* chore(debug-branch): remove unrelated files that were mistakenly added in first commit; keep only intended debug settings changes

* fix(chat): prevent mesh→geohash leak

Root cause:
- DebugSettingsManager→chat bridge appended system logs to the global timeline regardless of active channel
- MeshDelegateHandler added public mesh messages to UI unconditionally

Fixes:
- Only inject debug system messages when selected location channel is Mesh
- Only add public mesh messages to UI when Mesh is selected (still send notifications)

Build: ./gradlew assembleDebug
}

* fix(timeline): restore message persistence across channel switches

Root cause:
- NostrGeohashService.switchLocationChannel() called messageManager.clearMessages()
  which wiped ALL messages (mesh + debug + geohash) from main timeline
- Geohash events were adding to main timeline, causing cross-contamination

Fixes:
- Remove messageManager.clearMessages() from channel switching
- ChatScreen displayMessages now routes to separate storage:
  - Mesh: messages (main timeline, includes debug logs when Mesh selected)
  - Geohash: viewModel.getGeohashMessages(geohash) from separate history
  - Private: privateChats[peerID]
  - Channels: channelMessages[channel]
- Geohash events no longer add to main timeline, only to geohash history
- Mesh messages always stored to preserve history when switching away

Result: Each chat type has persistent separate storage, no message loss

* Debug/relay logs: use MessageType names; include device route in verbose packet logs.

* Verbose device-peer assignment and connection/disconnection logs with peerId, deviceId, nickname; packet relay log uses MessageType names.}

* Debug logs API: include nickname and deviceId for incoming/relay; update callers.}

* Fix compile: import MessageType; correct debug manager API usage and remove stray insertion; build.}

* Respect relay toggle; helper to log relay with deviceId.}

* PacketRelayManager: add relay toggle and unified logging helper; clean file header comments; build fixes.}

* changes

* Geohash local echo: do not add to mesh timeline; rely on geohash history and ChatScreen display for location channels.

* persisting

* persist debug settings

* gitignore

* gatt server / client controls

* debugger

* max connection settings and graph

* more graph

* better logging

* refactor logging
2025-09-05 15:40:39 +02:00
callebtcandGitHub 8b3dc71dc6 Refactors cleanup (#372)
* cleanup peermanager

* cleanup geohash code

* direct connections fix

* pow display

* track disconnects too

* display pow only if enabled

* display pow only if enabled

* direct connection tracking
2025-09-02 22:09:44 +02:00
callebtcandGitHub 4cb5932fd0 improve identity announcements (#198)
* improve identity announcements

* touches

* signing noise id

* panic mode delete signing key
2025-07-31 06:26:41 +02:00
callebtcandGitHub c3c395832c Implement Noise XX Handshake Protocol for Direct Messages (#180)
* noise

* works?

* noise

* temporary

* better

* wip: use subnet

* better

* barely working

* werk

* subnet

* fix peer ID

* 8 byte peer ID

* wip noise

* wip fixes for noise

* std lib for noise

* noise handshake one step further

* buffers

* use fork

* fix imports

* simplify counter

* remove trash

* hashing

* no prologue

* nice

* wip, use noise encryption

* peer ID hex

* simplify session manager

* heavy logging

* use singleton

* Fix Noise session race condition with elegant per-peer actor serialization

- Use Kotlin coroutine actors for per-peer packet processing
- Each peer gets dedicated actor that processes packets sequentially
- Eliminates race conditions in session management without complex locking
- Single surgical change in PacketProcessor - minimal, maintainable
- Leverages Kotlin's native concurrency primitives

* decrypt correctly

* iniator works now

* clean code and fix signature to null

* better

* no signature in private message

* small fixes

* refactor ack

* refactor but untested

* messages working

* wip ack

* wip fix ack

* more logging

* pending tracker

* keep pending connections on errors

* less logging

* refactor model

* refactor frombinarydata

* idendityannouncement refactor and update to new binary protocol

* fix keys

* refix keys

* dms work

* revert to mainnet

* do not change bluetooth adapter name

* keep code but uncomment

* clean up comments

* cleanup comments
2025-07-24 12:01:46 +02:00
callebtc 193918d81a track rssi correctly 2025-07-14 00:13:45 +02:00
callebtc f909f01fec integrate into main 2025-07-13 23:23:15 +02:00
callebtc f9a639af2d Merge branch 'main' into fix/android-ios-fragmentation-compatibility 2025-07-13 23:18:00 +02:00
callebtc 725dc01352 fix null delegate 2025-07-13 22:06:43 +02:00
callebtc f7c68d2ff2 fix 2025-07-13 21:38:39 +02:00
callebtc a68e14133b wip refactor 2025-07-13 21:34:31 +02:00
callebtcandGitHub d25d3bf991 Merge branch 'main' into fix/android-ios-fragmentation-compatibility 2025-07-13 21:25:11 +02:00
callebtc 930081bba0 add location services check 2025-07-13 20:27:43 +02:00
callebtc 887ca0119e Merge branch 'main' into adjust-scan-intervals 2025-07-13 19:43:58 +02:00
callebtc 2cf6bf19b1 Merge branch 'main' into routingOpt 2025-07-13 17:20:49 +02:00
callebtc 2a0f84b53b adjust scan intervals and reduce logging 2025-07-13 17:16:31 +02:00
callebtc d54d470614 more logging 2025-07-12 16:36:00 +02:00
callebtc 035273011f fix startup 2025-07-12 15:42:37 +02:00
GUVWAF 1b37f46d1e Fallback to broadcast if direct send fails 2025-07-12 13:18:09 +02:00
GUVWAF d1085fde0b Cheap routing optimizations
- Don't relay back to sender or relayer
- Only send to connected device if recipientID matches one
- Don't relay our own ACK/read receipt
2025-07-12 13:18:09 +02:00
callebtc e58cf4fd0d fix null pointer 2025-07-12 12:53:01 +02:00
ShilohEye 33d273f268 Fix Android fragmentation for iOS/Rust compatibility
- Changed MAX_FRAGMENT_SIZE from 500 to 150 bytes to match iOS/Rust
- Fixed fragment ID generation to use 8 random bytes instead of string
- Implemented automatic fragmentation in BluetoothConnectionManager
- Added 20ms delay between fragments to match iOS/Rust implementation
- Updated fragment calculation to account for full packet overhead (34 bytes)

This ensures Android-generated fragments fit within iOS's default 185-byte BLE MTU,
fixing issues with commands like ?ls -la and ?ifconfig failing on iOS devices.
2025-07-10 19:25:52 -04:00
callebtc b6f281275a fixed 2025-07-09 21:51:04 +02:00
callebtc 3c0d145406 variable mtu clientside fix 2025-07-09 21:39:12 +02:00
callebtc 90750c2635 disable server, but client works 2025-07-09 21:10:20 +02:00
callebtc 250772a693 silent 2025-07-09 19:49:21 +02:00
callebtc 1d7defcbae rate limiting 2025-07-09 18:29:49 +02:00
callebtc dd8aa083b9 power saving 2025-07-09 15:47:54 +02:00
callebtc d3e258b442 precvent duplicate connections 2025-07-09 15:34:20 +02:00
callebtc 3919373025 Add extracted components for BluetoothMeshService refactoring
- PeerManager.kt: Manages peer lifecycle, nicknames, and RSSI tracking (161 lines)
- FragmentManager.kt: Handles message fragmentation and reassembly (194 lines)
- SecurityManager.kt: Manages duplicate detection, replay protection, encryption (236 lines)
- StoreForwardManager.kt: Handles message caching for offline peers (295 lines)
- MessageHandler.kt: Processes different message types and relay logic (284 lines)
- BluetoothConnectionManager.kt: Manages BLE connections and GATT operations (611 lines)
- PacketProcessor.kt: Routes incoming packets to appropriate handlers (108 lines)

All components compile successfully and maintain same functionality as original monolithic service.
Total extracted: ~1789 lines into 7 focused components.
2025-07-08 23:44:24 +02:00