// Define the IP address and port of the Lovense device
const lovenseIP = ‘192.168.1.94’;
const lovensePort = 30010; // Default port for Lovense Local API
// Define the endpoint and parameters for the command
const endpoint = ‘/GetToys’;
// Construct the full URL
const url = http://${lovenseIP}:${lovensePort}${endpoint};
// Send the HTTP GET request to the Lovense device
fetch(url, {
method: ‘POST’
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ’ + response.statusText);
}
return response.text(); // Change to text to handle non-JSON responses
})
.then(data => {
console.log(‘Success:’, data);
})
.catch(error => {
console.error(‘There was a problem with the fetch operation:’, error);
});
Could someone help me form a simple script that starts vibration on a toy?
The URL of request should be "http://192.168.1.94:20010/command" (or alternatively "https://192.168.1.94:30010/command" if you want to use SSL, but in such case it might fail on SSL certificate validation, so try without SSL first), and the body should contain JSON of your request ‘{ “command”: “GetToys” }’
I am not JavaScript guy, I only tested it in bash with curl - and following worked for me just fine:
I messed around with a quite a bit and the problem seems to be connection to the app via the IP:PORT.
I tried your curl command and got: curl: (7) Failed to connect to 192.168.1.24 port 20010 after 2498 ms: Couldn't connect to server
I can ping the IP, but when I do nmap -p 20010 192.168.1.24 with the app open I get:
nmap -p 20010 192.168.1.24
Starting Nmap 7.95 ( https://nmap.org ) at 2024-07-20 17:49 Rom, sommertid
Nmap scan report for xxx-Galaxy-S10 (192.168.1.24)
Host is up (0.023s latency).
PORT STATE SERVICE
20010/tcp closed unknown
MAC Address: xx:xx:xx:xx:xx:xx(Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds
Firewall is off.
What could be stopping my request from getting through?
I had no idea (that’s why no answer from me for long time), just now I got one: Check your WiFi settings. If you have so called “isolation” enabled (depending on your WiFi router/AP it might be called “AP isolation” or “client isolation” or similar), then wireless clients cannot make direct connection to each other (they can only make connection to outside internet). Sometimes this is enforced on “guest-WiFi” (if you have that enabled) and maybe you don’t even see such isolation option in router settings, in such case try to use primary wireless instead of guest one.
It’s just an idea, I do not know what your network environment is. As long as the Lovense Remote application in my phone is in Game Mode, it is listening on those 2 ports (one plain and one SSL), so I believe issue is somewhere in your networking.