Implementation
Future<void> probe() async {
loggy.debug('init');
await RawDatagramSocket.bind(broadcastAddress, broadcastPort);
final rawDataGramSocket = await RawDatagramSocket.bind(
InternetAddress.anyIPv4, 0,
reuseAddress: false, reusePort: false);
rawDataGramSocket.listen((RawSocketEvent rawSocketEvent) {
var dataGram = rawDataGramSocket.receive();
if (dataGram == null) return;
String messageReceived = String.fromCharCodes(dataGram.data);
loggy.debug('RESPONSE ADDRESS:\n${dataGram.address}');
loggy.debug('RESPONSE:\n$messageReceived');
var envelope = Envelope.fromXml(messageReceived);
if (envelope.body.response == null) throw Exception();
onvifDevices
.addAll(ProbeMatches.fromJson(envelope.body.response!).probeMatches);
});
start(rawDataGramSocket);
await finish(rawDataGramSocket, timeout);
}