Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sensor_server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
sensor_server
Commits
fd86ff04
Commit
fd86ff04
authored
Sep 06, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aded gnss
parent
16940052
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
SensorsUpdate.java
src/com/elphel/sensorserver/SensorsUpdate.java
+19
-0
Server.java
src/com/elphel/sensorserver/Server.java
+8
-5
No files found.
src/com/elphel/sensorserver/SensorsUpdate.java
View file @
fd86ff04
...
...
@@ -32,6 +32,8 @@ import android.hardware.Sensor;
import
android.hardware.SensorEvent
;
import
android.hardware.SensorEventListener
;
import
android.hardware.SensorManager
;
import
android.location.Location
;
import
android.location.LocationManager
;
import
android.util.Log
;
public
class
SensorsUpdate
implements
SensorEventListener
{
...
...
@@ -121,4 +123,21 @@ public class SensorsUpdate implements SensorEventListener{
return
mOrientationAngles
;
}
public
double
[]
getLocation
()
{
double
longitude
=
Double
.
NaN
;
double
latitude
=
Double
.
NaN
;;
try
{
LocationManager
lm
=
(
LocationManager
)
activity
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
Location
location
=
lm
.
getLastKnownLocation
(
LocationManager
.
GPS_PROVIDER
);
longitude
=
location
.
getLongitude
();
latitude
=
location
.
getLatitude
();
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Problem getting longitude/latitude"
);
}
double
[]
thisLocation
=
{
longitude
,
latitude
};
return
thisLocation
;
}
}
src/com/elphel/sensorserver/Server.java
View file @
fd86ff04
...
...
@@ -95,10 +95,11 @@ public class Server {
Log
.
d
(
TAG
,
"Request over"
);
float
[]
orientationAngles
=
sensorsUpdate
.
getOrientation
();
double
[]
location
=
sensorsUpdate
.
getLocation
();
// Date today = new Date();
String
httpResponse
=
"HTTP/1.1 200 OK\r\n\r\n"
+
// today+"\r\n"+
orientationDegreeXml
(
orientationAngles
);
orientationDegreeXml
(
orientationAngles
,
location
);
// String.format("<p>azimuth=%f</p>\r\n<p>pitch=%f</p>\r\n<p>roll=%f</p>\r\n",
// orientationAngles[0],orientationAngles[1],orientationAngles[2]);
try
{
...
...
@@ -186,24 +187,26 @@ public class Server {
}
}
}
private
String
orientationDegreeXml
(
float
[]
orientationAngles
)
{
private
String
orientationDegreeXml
(
float
[]
orientationAngles
,
double
[]
location
)
{
float
[]
oad
=
new
float
[
orientationAngles
.
length
];
for
(
int
i
=
0
;
i
<
oad
.
length
;
i
++)
{
oad
[
i
]
=
orientationAngles
[
i
]*
180
/
(
float
)
Math
.
PI
;
}
return
orientationXml
(
oad
);
return
orientationXml
(
oad
,
location
);
}
@SuppressLint
(
"DefaultLocale"
)
private
String
orientationXml
(
float
[]
orientationAngles
)
{
private
String
orientationXml
(
float
[]
orientationAngles
,
double
[]
location
)
{
return
String
.
format
(
"<?xml version=\"1.0\"?>\r\n"
+
"<orientationAngles>\r\n"
+
"<azimuth>%f</azimuth>\r\n"
+
"<pitch>%f</pitch>\r\n"
+
"<roll>%f</roll>\r\n"
+
"<longitude>%f</longitude>\r\n"
+
"<latitude>%f</latitude>\r\n"
+
"<date>%s</date>\r\n"
+
"</orientationAngles>\r\n"
,
orientationAngles
[
0
],
orientationAngles
[
1
],
orientationAngles
[
2
],
new
Date
());
orientationAngles
[
0
],
orientationAngles
[
1
],
orientationAngles
[
2
],
location
[
0
],
location
[
1
],
new
Date
());
}
public
int
getPort
()
{
return
PORT
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment