mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 00:45:22 +00:00
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
This commit is contained in:
@@ -43,12 +43,6 @@ class BluetoothConnectionManager(
|
||||
override fun onPacketReceived(packet: BitchatPacket, peerID: String, device: BluetoothDevice?) {
|
||||
Log.d(TAG, "onPacketReceived: Packet received from ${device?.address} ($peerID)")
|
||||
device?.let { bluetoothDevice ->
|
||||
// if connection does not have a peerID yet, we assume that the first package
|
||||
// we receive from that connection is from the peer
|
||||
if (!connectionTracker.addressPeerMap.containsKey(device.address)) {
|
||||
Log.d(TAG, "First packet received from new device: ${bluetoothDevice.address}, assuming peerID: $peerID")
|
||||
connectionTracker.addressPeerMap[device.address] = peerID
|
||||
}
|
||||
// Get current RSSI for this device and update if available
|
||||
val currentRSSI = connectionTracker.getBestRSSI(bluetoothDevice.address)
|
||||
if (currentRSSI != null) {
|
||||
@@ -64,6 +58,10 @@ class BluetoothConnectionManager(
|
||||
override fun onDeviceConnected(device: BluetoothDevice) {
|
||||
delegate?.onDeviceConnected(device)
|
||||
}
|
||||
|
||||
override fun onDeviceDisconnected(device: BluetoothDevice) {
|
||||
delegate?.onDeviceDisconnected(device)
|
||||
}
|
||||
|
||||
override fun onRSSIUpdated(deviceAddress: String, rssi: Int) {
|
||||
delegate?.onRSSIUpdated(deviceAddress, rssi)
|
||||
@@ -262,5 +260,6 @@ class BluetoothConnectionManager(
|
||||
interface BluetoothConnectionManagerDelegate {
|
||||
fun onPacketReceived(packet: BitchatPacket, peerID: String, device: BluetoothDevice?)
|
||||
fun onDeviceConnected(device: BluetoothDevice)
|
||||
fun onDeviceDisconnected(device: BluetoothDevice)
|
||||
fun onRSSIUpdated(deviceAddress: String, rssi: Int)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user