mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-28 14:36:39 +10:00
Added the basics for path tracing
This commit is contained in:
@@ -127,6 +127,7 @@ const int cmdSendStatusReq = 27;
|
|||||||
const int cmdGetContactByKey = 30;
|
const int cmdGetContactByKey = 30;
|
||||||
const int cmdGetChannel = 31;
|
const int cmdGetChannel = 31;
|
||||||
const int cmdSetChannel = 32;
|
const int cmdSetChannel = 32;
|
||||||
|
const int cmdSendTracePath = 36;
|
||||||
const int cmdGetRadioSettings = 57;
|
const int cmdGetRadioSettings = 57;
|
||||||
const int cmdGetTelemetryReq = 39;
|
const int cmdGetTelemetryReq = 39;
|
||||||
const int cmdGetCustomVar = 40;
|
const int cmdGetCustomVar = 40;
|
||||||
@@ -176,6 +177,7 @@ const int pushCodeLoginSuccess = 0x85;
|
|||||||
const int pushCodeLoginFail = 0x86;
|
const int pushCodeLoginFail = 0x86;
|
||||||
const int pushCodeStatusResponse = 0x87;
|
const int pushCodeStatusResponse = 0x87;
|
||||||
const int pushCodeLogRxData = 0x88;
|
const int pushCodeLogRxData = 0x88;
|
||||||
|
const int pushCodeTraceData = 0x89;
|
||||||
const int pushCodeNewAdvert = 0x8A;
|
const int pushCodeNewAdvert = 0x8A;
|
||||||
const int pushCodeTelemetryResponse = 0x8B;
|
const int pushCodeTelemetryResponse = 0x8B;
|
||||||
const int pushCodeBinaryResponse = 0x8C;
|
const int pushCodeBinaryResponse = 0x8C;
|
||||||
@@ -708,3 +710,18 @@ Uint8List buildSendBinaryReq(Uint8List repeaterPubKey, {Uint8List? payload}) {
|
|||||||
}
|
}
|
||||||
return writer.toBytes();
|
return writer.toBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Build a trace request frame
|
||||||
|
//[cmd][tag x4][auth x4][flag][payload]
|
||||||
|
Uint8List buildTraceReq(int tag, int auth, int flag, {Uint8List? payload})
|
||||||
|
{
|
||||||
|
final writer = BufferWriter();
|
||||||
|
writer.writeByte(cmdSendTracePath);
|
||||||
|
writer.writeUInt32LE(tag);
|
||||||
|
writer.writeUInt32LE(auth);
|
||||||
|
writer.writeByte(flag);
|
||||||
|
if (payload != null && payload.isNotEmpty) {
|
||||||
|
writer.writeBytes(payload);
|
||||||
|
}
|
||||||
|
return writer.toBytes();
|
||||||
|
}
|
||||||
@@ -752,7 +752,20 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (isRepeater)
|
if (isRepeater) ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.radar, color: Colors.green),
|
||||||
|
title: Text("Ping"),
|
||||||
|
onTap: () async {
|
||||||
|
final frame = buildTraceReq(
|
||||||
|
DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
payload: contact.publicKey.sublist(0,1),
|
||||||
|
);
|
||||||
|
await connector.sendFrame(frame);
|
||||||
|
}
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.cell_tower, color: Colors.orange),
|
leading: const Icon(Icons.cell_tower, color: Colors.orange),
|
||||||
title: Text(context.l10n.contacts_manageRepeater),
|
title: Text(context.l10n.contacts_manageRepeater),
|
||||||
@@ -761,7 +774,20 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
_showRepeaterLogin(context, contact);
|
_showRepeaterLogin(context, contact);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else if (isRoom) ...[
|
]else if (isRoom) ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.radar, color: Colors.green),
|
||||||
|
title: Text("Ping"),
|
||||||
|
onTap: () async {
|
||||||
|
final frame = buildTraceReq(
|
||||||
|
DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
payload: contact.publicKey.sublist(0,1),
|
||||||
|
);
|
||||||
|
await connector.sendFrame(frame);
|
||||||
|
}
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.room, color: Colors.blue),
|
leading: const Icon(Icons.room, color: Colors.blue),
|
||||||
title: Text(context.l10n.contacts_roomLogin),
|
title: Text(context.l10n.contacts_roomLogin),
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
return 'CMD_GET_RADIO_SETTINGS';
|
return 'CMD_GET_RADIO_SETTINGS';
|
||||||
case cmdSetCustomVar:
|
case cmdSetCustomVar:
|
||||||
return 'CMD_SET_CUSTOM_VAR';
|
return 'CMD_SET_CUSTOM_VAR';
|
||||||
|
case cmdSendTracePath:
|
||||||
|
return 'CMD_SEND_TRACE_PATH';
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -195,6 +197,8 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
return 'RESP_CODE_CHANNEL_INFO';
|
return 'RESP_CODE_CHANNEL_INFO';
|
||||||
case respCodeRadioSettings:
|
case respCodeRadioSettings:
|
||||||
return 'RESP_CODE_RADIO_SETTINGS';
|
return 'RESP_CODE_RADIO_SETTINGS';
|
||||||
|
case pushCodeTraceData:
|
||||||
|
return 'PUSH_CODE_TRACE_DATA';
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user