-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WeMOS - Phone communication #2
Comments
Socket on DeviceHow to setupfinal server = await ServerSocket.bind("192.168.43.1", 4567); // Provided address is the default address
// of a device that is hosting a mobile hotspot
server.listen((client) {
handleConnection(client);
}); Handle Connectionvoid handleConnection(Socket client) {
if (kDebugMode) {
print('Connection from'
' ${client.remoteAddress.address}:${client.remotePort}');
}
// listen for events from the client
client.listen(
// handle data from the client
(Uint8List data) async {
if (kDebugMode) {
print(data);
}
final message = String.fromCharCodes(data);
},
// handle errors
onError: (error) {
if (kDebugMode) {
print(error);
}
client.close();
},
// handle the client closing the connection
onDone: () {
if (kDebugMode) {
print('Client left');
}
client.close();
},
);
} |
IP-Address IssueFor now the IP address is hardcoded into program. Most Android Phones should have the same IP address (192.168.43.1) when hosting their hotspot. However, the IP address can still be different from to phone. |
Because receiving messages from the Phone on the WeMOS did not work reliably using the standard socket api, @Tino3141 and I discontinued these efforts. The problem of attaching the right timestamp was temporarily solved in the following way:
We will keep it this way because it works reliably. For publishing a wakeup call we will use MQTT on the WeMOS. |
@Tino3141
The text was updated successfully, but these errors were encountered: