feat: Update project version to 42 and enhance advertisement handling in BLE service

This commit is contained in:
Janez T
2025-10-27 22:47:04 +01:00
parent 8c05c331e2
commit b398dc9aa9
8 changed files with 58 additions and 15 deletions

View File

@@ -409,11 +409,13 @@ class BleResponseHandler {
}
}
/// Handle Advert push
/// Handle Advert push (0x80) - basic advertisement with public key only
void _handleAdvert(BufferReader reader) {
try {
final publicKey = FrameParser.parseAdvert(reader);
if (publicKey != null) {
final shortKey = publicKey.sublist(0, 8).map((b) => b.toRadixString(16).padLeft(2, '0')).join('');
debugPrint(' ✅ [Advert 0x80] From node: $shortKey... (public key only, no location data)');
onAdvertReceived?.call(publicKey);
}
debugPrint(' ✅ [Advert] Parsed successfully');
@@ -856,14 +858,20 @@ class BleResponseHandler {
debugPrint(' 🧹 [Echo] Cleaned up ${toRemove.length} old trackers');
}
/// Handle NewAdvert push
/// Handle NewAdvert push (0x8A) - full contact info with location
void _handleNewAdvert(BufferReader reader) {
try {
final contact = FrameParser.parseContact(reader);
debugPrint(' ✅ [NewAdvert] Parsed successfully: ${contact.advName}');
debugPrint(' ✅ [NewAdvert 0x8A] Parsed successfully: ${contact.advName}');
debugPrint(
' outPathLen: ${contact.outPathLen} (${contact.pathDescription})',
);
if (contact.advLat != 0 || contact.advLon != 0) {
final location = contact.advertLocation;
if (location != null) {
debugPrint(' 📍 Location: ${location.latitude}, ${location.longitude}');
}
}
onContactReceived?.call(contact);
} catch (e) {
debugPrint(' ❌ [NewAdvert] Parsing error: $e');

View File

@@ -122,15 +122,19 @@ class MeshCoreBleService {
// Response handler callbacks
_responseHandler.onContactReceived = (contact) {
debugPrint('🔔 [BleService] onContactReceived - "${contact.advName}" - forwarding to ConnectionProvider');
onContactReceived?.call(contact);
};
_responseHandler.onContactsComplete = (contacts) {
debugPrint('🔔 [BleService] onContactsComplete - ${contacts.length} contacts - forwarding to ConnectionProvider');
onContactsComplete?.call(contacts);
};
_responseHandler.onMessageReceived = (message) {
debugPrint('🔔 [BleService] onMessageReceived - forwarding to ConnectionProvider');
onMessageReceived?.call(message);
};
_responseHandler.onTelemetryReceived = (publicKey, lppData) {
debugPrint('🔔 [BleService] onTelemetryReceived - ${lppData.length} bytes - forwarding to ConnectionProvider');
onTelemetryReceived?.call(publicKey, lppData);
};
_responseHandler.onSelfInfoReceived = (selfInfo) {
@@ -160,9 +164,11 @@ class MeshCoreBleService {
onLoginFail?.call(publicKeyPrefix);
};
_responseHandler.onAdvertReceived = (publicKey) {
debugPrint('🔔 [BleService] onAdvertReceived - forwarding to ConnectionProvider');
onAdvertReceived?.call(publicKey);
};
_responseHandler.onPathUpdated = (publicKey) {
debugPrint('🔔 [BleService] onPathUpdated - forwarding to ConnectionProvider');
onPathUpdated?.call(publicKey);
};
_responseHandler.onMessageSent =