Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SensorDataCollectorAppServer_IOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miklósi Máté
SensorDataCollectorAppServer_IOS
Commits
bd845a86
Commit
bd845a86
authored
1 year ago
by
Miklosimate
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup, comments
parent
4bcfd6cd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.html
+1
-32
1 addition, 32 deletions
index.html
index.js
+7
-6
7 additions, 6 deletions
index.js
list.html
+1
-0
1 addition, 0 deletions
list.html
with
9 additions
and
38 deletions
index.html
+
1
−
32
View file @
bd845a86
<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
...
...
@@ -142,38 +143,6 @@
console
.
error
(
'
Error fetching devices:
'
,
error
);
}
}
async
function
handleStillHereMessageAndRefresh
(
deviceID
)
{
try
{
const
response
=
await
fetch
(
`/stillHere/
${
deviceID
}
`
,
{
method
:
'
POST
'
,
});
const
data
=
await
response
.
json
();
// Refresh the device list after receiving "stillHere" message
await
populateDeviceList
();
}
catch
(
error
)
{
console
.
error
(
'
Error handling stillHere message:
'
,
error
);
}
}
async
function
handleReadyMessageAndRefresh
(
deviceID
)
{
try
{
const
response
=
await
fetch
(
`/ready/
${
deviceID
}
`
,
{
method
:
'
POST
'
,
});
const
data
=
await
response
.
json
();
// Refresh the device list after receiving "ready" message
await
populateDeviceList
();
}
catch
(
error
)
{
console
.
error
(
'
Error handling ready message:
'
,
error
);
}
}
// Populate device list on page load
populateDeviceList
();
</script>
...
...
This diff is collapsed.
Click to expand it.
index.js
+
7
−
6
View file @
bd845a86
...
...
@@ -28,7 +28,7 @@ app.get('/list', (req, res) => {
res
.
sendFile
(
path
.
join
(
__dirname
,
'
list.html
'
));
});
//
Add route to get server info
//
This function was written by chatGPT (3.5), the rest of the code and the "Write me the route for server info" input was given.
app
.
get
(
'
/server-info
'
,
(
req
,
res
)
=>
{
const
serverInfo
=
{
ip
:
ip
.
address
(),
...
...
@@ -36,8 +36,7 @@ app.get('/server-info', (req, res) => {
};
res
.
json
(
serverInfo
);
});
// POST route for handling "init" messages
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app
.
post
(
'
/init
'
,
(
req
,
res
)
=>
{
console
.
log
(
`Received "init" message\n`
);
//If the measurement parameters has not been set yet
...
...
@@ -67,6 +66,7 @@ app.post('/init', (req, res) => {
// POST route for checking "am-i-ok" messages
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app
.
post
(
'
/am-i-ok/:deviceID
'
,
(
req
,
res
)
=>
{
const
deviceID
=
req
.
params
.
deviceID
;
let
responseToSend
...
...
@@ -85,7 +85,7 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
}
console
.
log
(
'
Sent JSON:
'
,
responseToSend
);
});
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app
.
post
(
'
/json/:deviceID/:f_n
'
,
(
req
,
res
)
=>
{
const
deviceID
=
req
.
params
.
deviceID
;
const
f_n
=
req
.
params
.
f_n
;
...
...
@@ -139,7 +139,7 @@ app.post('/ready/:deviceID', (req, res) => {
connectedDevices
[
deviceID
].
state
=
'
Ready
'
;
}
});
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app
.
post
(
'
/stillHere/:deviceID
'
,
(
req
,
res
)
=>
{
const
deviceID
=
req
.
params
.
deviceID
;
// Check if the device is registered
...
...
@@ -169,7 +169,7 @@ function generateDeviceID() {
// Generate a unique device ID (you can use a more robust method if needed)
return
Date
.
now
().
toString
(
36
)
+
Math
.
random
().
toString
(
36
).
substr
(
2
,
5
);
}
//This function was written by chatGPT (3.5)
app
.
get
(
'
/get-devices
'
,
(
req
,
res
)
=>
{
const
devicesList
=
Object
.
keys
(
connectedDevices
).
map
(
deviceID
=>
{
return
{
...
...
@@ -181,6 +181,7 @@ app.get('/get-devices', (req, res) => {
res
.
json
(
devicesList
);
});
//This function was written by chatGPT (3.5) manual corrections was needed.
app
.
post
(
'
/set-server-config
'
,
(
req
,
res
)
=>
{
// Handle the POST request to set server configuration
const
{
NumberOfMeasurements
,
Intervals
,
Delay
}
=
req
.
body
;
...
...
This diff is collapsed.
Click to expand it.
list.html
+
1
−
0
View file @
bd845a86
<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment