Comments (3)
Socket on Device
How to setup
final 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 Connection
void 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();
},
);
}
from nus-cs3237-iot-buoys.
IP-Address Issue
For 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.
from nus-cs3237-iot-buoys.
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:
- the WeMOS connects to phone wifi
- the WeMOS sends
reset
message - the phone receives
reset
and resets an internalwemos-alive
value - when the WeMOS sends collected data, it sets the timestamp relative to the time at which the
reset
was sent - when phone receives data, it mutates the timestamp by offsetting it by
wemos-alive
We will keep it this way because it works reliably. For publishing a wakeup call we will use MQTT on the WeMOS.
from nus-cs3237-iot-buoys.
Related Issues (10)
- Prof briefing 1 HOT 5
- Phone - Cloud communication HOT 5
- Cloud backend infrastructure HOT 2
- Sensors HOT 5
- Cloud Servers HOT 6
- Check-in 2 Pointers HOT 2
- Cloud Analytics HOT 1
- data collection HOT 2
- power management and wake up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nus-cs3237-iot-buoys.