Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AndroidSensorSharing
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
Container registry
Model registry
Operate
Environments
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
OpenLicht
AndroidSensorSharing
Commits
e5c32ad3
Commit
e5c32ad3
authored
6 years ago
by
boqiren
Browse files
Options
Downloads
Patches
Plain Diff
fix bugs
parent
65e158f0
Branches
Branches containing commit
Tags
0.3.1
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mobile/src/main/AndroidManifest.xml
+2
-0
2 additions, 0 deletions
mobile/src/main/AndroidManifest.xml
mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
+20
-9
20 additions, 9 deletions
.../java/de/tudresden/inf/st/sensorsharing/MainActivity.java
with
22 additions
and
9 deletions
mobile/src/main/AndroidManifest.xml
+
2
−
0
View file @
e5c32ad3
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<application
<application
android:allowBackup=
"true"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
...
@@ -24,6 +25,7 @@
...
@@ -24,6 +25,7 @@
</activity>
</activity>
<service
android:name=
"org.eclipse.paho.android.service.MqttService"
/>
<service
android:name=
"org.eclipse.paho.android.service.MqttService"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
+
20
−
9
View file @
e5c32ad3
...
@@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements
private
static
final
String
TAG
=
"SensorSharing"
;
private
static
final
String
TAG
=
"SensorSharing"
;
// private static final String MQTT_TOPIC_SAMSUNG = "sensors/samsung/brightness";
// private static final String MQTT_TOPIC_SAMSUNG = "sensors/samsung/brightness";
private
static
in
t
return_value_seekbar
=
0
;
private
static
Str
in
g
return_value_seekbar
=
""
;
// sensor management
// sensor management
private
SensorManager
mSensorManager
;
private
SensorManager
mSensorManager
;
private
Sensor
mLight
;
private
Sensor
mLight
;
...
@@ -287,7 +287,8 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -287,7 +287,8 @@ public class MainActivity extends AppCompatActivity implements
private
void
setupLightsController
(){
private
void
setupLightsController
(){
final
String
openhab_topic
=
"oh2/out/iris1_item/state"
;
final
String
openhab_topic
=
"oh2/in/iris1_item"
;
//final String openhab_topic1 = "oh2/out/iris1_item";
final
String
home_e_lights_topic
=
"out/E_Lights_Analog/state"
;
final
String
home_e_lights_topic
=
"out/E_Lights_Analog/state"
;
final
String
home_d_lights_1_topic
=
"out/D_Lights_1_Analog/state"
;
final
String
home_d_lights_1_topic
=
"out/D_Lights_1_Analog/state"
;
final
String
home_d_lights_2_topic
=
"out/D_Lights_2_Analog/state"
;
final
String
home_d_lights_2_topic
=
"out/D_Lights_2_Analog/state"
;
...
@@ -304,13 +305,15 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -304,13 +305,15 @@ public class MainActivity extends AppCompatActivity implements
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
isChecked
)
{
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
isChecked
)
{
switch
(
compoundButton
.
getId
()){
switch
(
compoundButton
.
getId
()){
case
R
.
id
.
checkbox_openhab_light_1
:
case
R
.
id
.
checkbox_openhab_light_1
:
//sendMqttUpdates.put(openhab_topic1, isChecked);
sendMqttUpdates
.
put
(
openhab_topic
,
isChecked
);
sendMqttUpdates
.
put
(
openhab_topic
,
isChecked
);
SeekBar
openhab_seekbar
=
findViewById
(
R
.
id
.
openhab_seekBar_1
);
SeekBar
openhab_seekbar
=
findViewById
(
R
.
id
.
openhab_seekBar_1
);
openhab_seekbar
.
setOnSeekBarChangeListener
(
new
SeekBar
.
OnSeekBarChangeListener
()
{
openhab_seekbar
.
setOnSeekBarChangeListener
(
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
i
,
boolean
b
)
{
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
i
,
boolean
b
)
{
System
.
out
.
println
(
"seekbar:"
+
i
);
return_value_seekbar
=
String
.
valueOf
(
i
);
sendUpdate
(
openhab_topic
,
String
.
valueOf
(
i
));
sendUpdate
(
openhab_topic
,
"7,"
+
"100,"
+
String
.
valueOf
(
i
));
//sendUpdate(openhab_topic1,"7,"+"100,"+String.valueOf(i));
}
}
@Override
@Override
...
@@ -536,6 +539,7 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -536,6 +539,7 @@ public class MainActivity extends AppCompatActivity implements
final
String
serverURI
=
valueServerURI
.
getText
().
toString
();
final
String
serverURI
=
valueServerURI
.
getText
().
toString
();
Toast
.
makeText
(
MainActivity
.
this
,
"Connecting to "
+
serverURI
,
Toast
.
makeText
(
MainActivity
.
this
,
"Connecting to "
+
serverURI
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
LENGTH_SHORT
).
show
();
System
.
out
.
println
(
serverURI
);
mqttAndroidClient
=
new
MqttAndroidClient
(
this
,
serverURI
,
clientId
);
mqttAndroidClient
=
new
MqttAndroidClient
(
this
,
serverURI
,
clientId
);
mqttAndroidClient
.
setCallback
(
new
MqttCallback
()
{
mqttAndroidClient
.
setCallback
(
new
MqttCallback
()
{
...
@@ -729,7 +733,8 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -729,7 +733,8 @@ public class MainActivity extends AppCompatActivity implements
@Override
@Override
public
void
onMessageReceived
(
@NonNull
final
MessageEvent
messageEvent
)
{
public
void
onMessageReceived
(
@NonNull
final
MessageEvent
messageEvent
)
{
final
String
openhab_topic
=
"oh2/out/iris1_item/state"
;
final
String
openhab_topic
=
"oh2/in/iris1_item"
;
final
String
openhab_topic1
=
"oh2/out/iris1_item"
;
String
path
=
messageEvent
.
getPath
();
String
path
=
messageEvent
.
getPath
();
if
(
path
==
null
)
return
;
if
(
path
==
null
)
return
;
if
(
path
.
startsWith
(
BASE_KEY
))
{
if
(
path
.
startsWith
(
BASE_KEY
))
{
...
@@ -746,18 +751,24 @@ public class MainActivity extends AppCompatActivity implements
...
@@ -746,18 +751,24 @@ public class MainActivity extends AppCompatActivity implements
TextView
color
=
findViewById
(
R
.
id
.
label_openhab_button
);
TextView
color
=
findViewById
(
R
.
id
.
label_openhab_button
);
if
(
isChecked_colorControl
){
if
(
isChecked_colorControl
){
sendMqttUpdates
.
put
(
openhab_topic
,
isChecked_colorControl
);
sendMqttUpdates
.
put
(
openhab_topic
,
isChecked_colorControl
);
//sendMqttUpdates.put(openhab_topic1, isChecked_colorControl);
if
(
mColor
==
1
){
if
(
mColor
==
1
){
color
.
setTextColor
(
Color
.
RED
);
color
.
setTextColor
(
Color
.
RED
);
sendUpdate
(
openhab_topic
,
"255,0,0"
);
sendUpdate
(
openhab_topic
,
"7,100,"
+
return_value_seekbar
);
//sendUpdate(openhab_topic1,"7,100,"+return_value_seekbar);
}
else
if
(
mColor
==
2
){
}
else
if
(
mColor
==
2
){
color
.
setTextColor
(
Color
.
BLUE
);
color
.
setTextColor
(
Color
.
BLUE
);
sendUpdate
(
openhab_topic
,
"0,0,255"
);
sendUpdate
(
openhab_topic
,
"240,100,"
+
return_value_seekbar
);
//sendUpdate(openhab_topic1,"240,100,"+return_value_seekbar);
}
else
if
(
mColor
==
3
){
}
else
if
(
mColor
==
3
){
color
.
setTextColor
(
Color
.
GREEN
);
color
.
setTextColor
(
Color
.
GREEN
);
sendUpdate
(
openhab_topic
,
"0,255,0"
);
sendUpdate
(
openhab_topic
,
"130,100,"
+
return_value_seekbar
);
//sendUpdate(openhab_topic1,"130,100,"+return_value_seekbar);
}
else
{
color
.
setTextColor
(
Color
.
GRAY
);
}
else
{
color
.
setTextColor
(
Color
.
GRAY
);
sendUpdate
(
openhab_topic
,
"0,0,0"
);}
sendUpdate
(
openhab_topic
,
"7,100,"
+
return_value_seekbar
);
//sendUpdate(openhab_topic1,"7,100,"+return_value_seekbar);
}
}
}
case
SUB_KEY_COUNTER:
case
SUB_KEY_COUNTER:
...
...
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