Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -8,23 +8,49 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
|
||||
}
|
||||
}
|
||||
|
||||
void Connectivity::websocketSetup(char* ip, uint16_t port, char* adress){
|
||||
//ws server address, port and URL
|
||||
webSocket.begin(ip , port, adress);
|
||||
// try every 500 again if connection has failed
|
||||
webSocket.setReconnectInterval(500);
|
||||
}
|
||||
// void Connectivity::websocketSetup(char* ip, uint16_t port, char* adress){
|
||||
// //ws server address, port and URL
|
||||
// webSocket.begin(ip , port, adress);
|
||||
// // try every 500 again if connection has failed
|
||||
// webSocket.setReconnectInterval(500);
|
||||
// }
|
||||
|
||||
void Connectivity::sendData(float roll, float pitch, float yaw){
|
||||
String message = "{\"Sensor\": 1, \"roll\":\"" + String(roll) + "\",\"pitch\":\"" + String(pitch) + "\",\"yaw\":\"" + String(yaw) + "\"}";
|
||||
webSocket.sendTXT(message);
|
||||
// void Connectivity::sendData(float roll, float pitch, float yaw){
|
||||
// String message = "{\"Sensor\": 1, \"roll\":\"" + String(roll) + "\",\"pitch\":\"" + String(pitch) + "\",\"yaw\":\"" + String(yaw) + "\"}";
|
||||
// webSocket.sendTXT(message);
|
||||
// }
|
||||
|
||||
const char* getServerURL = "http://145.92.8.132:443/get-ip";
|
||||
String ipAddress = "";
|
||||
|
||||
String Connectivity::fetchIPAddress() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
HTTPClient http;
|
||||
WiFiClient client;
|
||||
http.begin(client, getServerURL);
|
||||
|
||||
int httpCode = http.GET();
|
||||
if (httpCode > 0) {
|
||||
if (httpCode == HTTP_CODE_OK) {
|
||||
ipAddress = http.getString();
|
||||
}
|
||||
} else {
|
||||
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
}
|
||||
|
||||
http.end();
|
||||
} else {
|
||||
Serial.println("WiFi not connected");
|
||||
}
|
||||
return ipAddress; // Add this return statement
|
||||
}
|
||||
|
||||
/** Send a POST request to a server with provided data */
|
||||
int Connectivity::httpPost(const char *serverAddress, const char *serverSubPath, const unsigned short serverPort,
|
||||
const char *data, const size_t dataLength, const char *contentType)
|
||||
{
|
||||
if ( wifi_client.connect(serverAddress, serverPort)) {
|
||||
WiFiClient wifi_client; // Ensure WiFiClient is declared and initialized
|
||||
if (wifi_client.connect(serverAddress, serverPort)) {
|
||||
wifi_client.printf("POST %s HTTP/1.1\r\n", serverSubPath);
|
||||
wifi_client.printf("Content-Type: %s\r\n", contentType);
|
||||
wifi_client.printf("Content-Length: %d\r\n", dataLength);
|
||||
@@ -35,4 +61,4 @@ int Connectivity::httpPost(const char *serverAddress, const char *serverSubPath,
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <WebSocketsClient.h>
|
||||
#include <ArduinoWiFiServer.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ESP8266WiFiGeneric.h>
|
||||
#include <ESP8266WiFiMulti.h>
|
||||
#include <ESP8266WiFiSTA.h>
|
||||
@@ -18,12 +19,12 @@ public:
|
||||
void websocketSetup(char* ip, uint16_t port, char* adress);
|
||||
void sendData(float roll, float pitch, float yaw);
|
||||
int httpPost(const char *serverAddress, const char *serverSubPath, const unsigned short serverPort, const char *data, const size_t dataLength, const char *contentType);
|
||||
|
||||
String fetchIPAddress();
|
||||
|
||||
private:
|
||||
ESP8266WiFiMulti wifi;
|
||||
WiFiClient wifi_client;
|
||||
WebSocketsClient webSocket;
|
||||
// WebSocketsClient webSocket;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -4,6 +4,7 @@ void setup() {
|
||||
//connect to internet and start sensor
|
||||
connectivity.connectWiFi(ssid, pass);
|
||||
sensorManager.sensorSetup();
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
unsigned long lastTime = 0; // will store the last time the code was run
|
||||
@@ -12,7 +13,6 @@ void loop() {
|
||||
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
||||
// SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
||||
|
||||
|
||||
struct acceleration {
|
||||
float x = 9;
|
||||
float y = 9;
|
||||
@@ -34,7 +34,7 @@ struct acceleration {
|
||||
accelData.z,
|
||||
"data");
|
||||
// %d = int, %f = floatation, %s = string
|
||||
connectivity.httpPost("192.168.137.243", "/", 3445, buffer, strlen(buffer), "application/json");
|
||||
connectivity.httpPost(connectivity.fetchIPAddress(), "/", 3445, buffer, strlen(buffer), "application/json");
|
||||
lastTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
@@ -12,4 +12,6 @@ WebSocketsClient webSocket;
|
||||
#define pass "12345678"
|
||||
#define BUFFER_SIZE 1024
|
||||
#define DEVICE_ID 1
|
||||
#define IP_ADDRESS "192.168.137.12"
|
||||
|
||||
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
|
||||
|
22
code/server/ipSender/index.js
Normal file
22
code/server/ipSender/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
|
||||
app.use(express.json()); // for parsing application/json
|
||||
|
||||
let ipAddress = ''; // to store the received IP address
|
||||
|
||||
// endpoint to receive an IP address from an external source
|
||||
app.post('/set-ip', (req, res) => {
|
||||
ipAddress = req.body.ip;
|
||||
console.log('IP address received:', ipAddress);
|
||||
});
|
||||
|
||||
// endpoint for the ESP32 to fetch the IP address
|
||||
app.get('/get-ip', (req, res) => {
|
||||
res.json({ ip: ipAddress });
|
||||
console.log('IP address sent to ESP32');
|
||||
});
|
||||
|
||||
app.listen(42069, () => {
|
||||
console.log('Server is running on port 42069');
|
||||
});
|
@@ -21,6 +21,20 @@ const pool = mariadb.createPool(databaseCredentials);
|
||||
// Register incoming HTTP request handlers
|
||||
require('./incoming_request_handlers')(app, pool);
|
||||
|
||||
let ipAddress = ''; // to store the received IP address
|
||||
|
||||
// endpoint to receive an IP address from an external source
|
||||
app.post('/set-ip', (req, res) => {
|
||||
ipAddress = req.body.ip;
|
||||
console.log('IP address received:', ipAddress);
|
||||
});
|
||||
|
||||
// endpoint for the ESP32 to fetch the IP address
|
||||
app.get('/get-ip', (req, res) => {
|
||||
res.json({ ip: ipAddress });
|
||||
console.log('IP address sent to ESP32');
|
||||
});
|
||||
|
||||
// Start server
|
||||
app.listen(serverPort, () => {
|
||||
console.log(`Server running on port ${serverPort}`);
|
||||
|
@@ -10,13 +10,15 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@@ -86,7 +86,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
int randomMessageIndex = (int) Math.floor(Math.random() * EXERCISE_NOT_FOUND_MESSAGES.length);
|
||||
Pepper.say(EXERCISE_NOT_FOUND_MESSAGES[randomMessageIndex]);
|
||||
Pepper.say(EXERCISE_NOT_FOUND_SEEK_HELP_MESSAGE);
|
||||
NavigationManager.navigateToActivity(this, MainActivity.class);
|
||||
NavigationManager.navigateToActivity(this, EndScreenActivity.class);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.example.fitbot.ui.activities;
|
||||
|
||||
import static com.example.fitbot.util.Networking.sendIpAddress;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -17,6 +18,10 @@ import android.widget.Button;
|
||||
import com.example.fitbot.R;
|
||||
import com.example.fitbot.util.NavigationManager;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
// Variables
|
||||
@@ -30,7 +35,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// Set full screen mode to hide status bar
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
@@ -49,6 +53,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
// Hide system UI
|
||||
NavigationManager.hideSystemUI(this);
|
||||
sendIpAddress(this);
|
||||
}
|
||||
|
||||
private void setUpUi() {
|
||||
@@ -106,4 +111,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,76 @@
|
||||
package com.example.fitbot.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Networking {
|
||||
|
||||
public static void sendIpAddress(final Context context) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
String ipAddress = getIPAddress(context);
|
||||
String jsonInputString = "{\"ip\":\"" +
|
||||
ipAddress +
|
||||
"\"}";
|
||||
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
URL url = new URL("http://145.92.8.132:443/set-ip"); // Replace with your Node server URL
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setDoOutput(true);
|
||||
|
||||
OutputStream os = conn.getOutputStream();
|
||||
os.write(input, 0, input.length);
|
||||
os.close();
|
||||
|
||||
int responseCode = conn.getResponseCode();
|
||||
Log.i("NetworkUtils", "Response Code: " + responseCode);
|
||||
} catch (Exception e) {
|
||||
Log.e("NetworkUtils", "Error sending IP address", e);
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
|
||||
private static String getIPAddress(Context context) {
|
||||
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
|
||||
|
||||
// Convert little-endian to big-endian if needed
|
||||
if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
|
||||
ipAddress = Integer.reverseBytes(ipAddress);
|
||||
}
|
||||
|
||||
byte[] ipByteArray = BigInteger.valueOf(ipAddress).toByteArray();
|
||||
|
||||
String ip = "";
|
||||
try {
|
||||
ip = InetAddress.getByAddress(ipByteArray).getHostAddress();
|
||||
} catch (UnknownHostException ex) {
|
||||
Log.e("WIFIIP", "Unable to get host address.");
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||
</vector>
|
@@ -0,0 +1,5 @@
|
||||
<vector android:height="40dp" android:tint="?attr/colorControlNormal"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||
</vector>
|
@@ -0,0 +1,5 @@
|
||||
<vector android:height="48dp" android:tint="?attr/colorControlNormal"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||
</vector>
|
@@ -2,7 +2,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners
|
||||
android:radius="25dp"
|
||||
android:radius="30dp"
|
||||
/>
|
||||
|
||||
<gradient
|
||||
|
@@ -17,34 +17,47 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/border_background_2"
|
||||
android:orientation="horizontal"
|
||||
android:padding="30dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.505"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_width="410dp"
|
||||
android:layout_height="410dp"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/border_background"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal">
|
||||
android:layout_gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/infoButtonFitness"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:background="@drawable/red_button_gradient"
|
||||
android:drawableTop="@drawable/ic_baseline_info_40"
|
||||
android:drawableTint="@color/white"
|
||||
android:padding="2.5dp"
|
||||
android:layout_margin="10dp"
|
||||
tools:ignore="SpeakableTextPresentCheck" />
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/videoView"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_centerInParent="true" />
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_margin="50dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
android:layout_width="410dp"
|
||||
android:layout_height="410dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:background="@drawable/border_background"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
|
@@ -1,2 +1,14 @@
|
||||
# BOM
|
||||
|
||||
### Embedded hardware
|
||||
|
||||
- [BNO085](https://shop.slimevr.dev/products/slimevr-imu-module-bno085) (IMU)
|
||||
- [Custom PCB](https://github.com/Sorakage033/SlimeVR-CheeseCake/tree/main/002-%E2%80%98%E2%80%99Choco%E2%80%98%E2%80%99SpecialRemake) (Use file 8 9 and 10 and pcb thickness 1 mm)
|
||||
- [Battery](https://nl.aliexpress.com/item/32583443309.html) (900 mAh)
|
||||
- [3D print model](https://github.com/Sorakage033/SlimeVR-CheeseCake/blob/main/004-3D%20Print%20Model/001.3-Chocolate-Case_TypeC-Only.stl)
|
||||
|
||||
- [Optional Acrylic lid](https://github.com/Sorakage033/SlimeVR-CheeseCake/blob/main/004-3D%20Print%20Model/acryliclid.svg)
|
||||
|
||||
#### Extra notes for assembly
|
||||
* Watch out when inserting the assembled product into the case. Make sure you put it in at an angle so you don't break the power switch.
|
||||
|
||||
|
@@ -21,7 +21,9 @@ There are a lot of different IMU's with a lot of different specifications.
|
||||
* Bmi160
|
||||
|
||||
### Which one are we gonna use?
|
||||
|
||||
We are going to use the BNO085 because it has the least amount of drift and its very versatile. We can get almost any type of rotational and acceleration data from it.
|
||||
|
||||
---
|
||||
<br>
|
||||
<br>
|
||||
|
@@ -381,6 +381,136 @@ Done
|
||||
|
||||
**31 May**
|
||||
|
||||
To do
|
||||
|
||||
- Expert review
|
||||
- Add Ui for exercises
|
||||
|
||||
Done
|
||||
|
||||
- Expert review
|
||||
|
||||
**1 June**
|
||||
|
||||
- Weekend
|
||||
|
||||
**2 June**
|
||||
|
||||
- Weekend
|
||||
|
||||
**3 June**
|
||||
|
||||
To do
|
||||
|
||||
- Add Ui for exercises
|
||||
- Retrieve exercises from database and show them in the app
|
||||
|
||||
Done
|
||||
|
||||
- Add Ui for exercises
|
||||
|
||||
**4 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**5 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**6 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**7 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**8 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**9 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**10 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**11 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**12 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**13 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
||||
Done
|
||||
|
||||
-
|
||||
|
||||
**14 June**
|
||||
|
||||
To do
|
||||
|
||||
-
|
||||
|
Reference in New Issue
Block a user