Skip to content
Snippets Groups Projects
Commit e5c32ad3 authored by boqiren's avatar boqiren
Browse files

fix bugs

parent 65e158f0
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
......@@ -24,6 +25,7 @@
</activity>
<service android:name="org.eclipse.paho.android.service.MqttService" />
</application>
</manifest>
\ No newline at end of file
......@@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements
private static final String TAG = "SensorSharing";
// private static final String MQTT_TOPIC_SAMSUNG = "sensors/samsung/brightness";
private static int return_value_seekbar = 0;
private static String return_value_seekbar = "";
// sensor management
private SensorManager mSensorManager;
private Sensor mLight;
......@@ -287,7 +287,8 @@ public class MainActivity extends AppCompatActivity implements
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_d_lights_1_topic = "out/D_Lights_1_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
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
switch (compoundButton.getId()){
case R.id.checkbox_openhab_light_1:
//sendMqttUpdates.put(openhab_topic1, isChecked);
sendMqttUpdates.put(openhab_topic, isChecked);
SeekBar openhab_seekbar = findViewById(R.id.openhab_seekBar_1);
openhab_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
System.out.println("seekbar:" +i);
sendUpdate(openhab_topic,String.valueOf(i));
return_value_seekbar = String.valueOf(i);
sendUpdate(openhab_topic,"7,"+"100,"+String.valueOf(i));
//sendUpdate(openhab_topic1,"7,"+"100,"+String.valueOf(i));
}
@Override
......@@ -536,6 +539,7 @@ public class MainActivity extends AppCompatActivity implements
final String serverURI = valueServerURI.getText().toString();
Toast.makeText(MainActivity.this, "Connecting to " + serverURI,
Toast.LENGTH_SHORT).show();
System.out.println(serverURI);
mqttAndroidClient = new MqttAndroidClient(this, serverURI, clientId);
mqttAndroidClient.setCallback(new MqttCallback() {
......@@ -729,7 +733,8 @@ public class MainActivity extends AppCompatActivity implements
@Override
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();
if (path == null) return;
if (path.startsWith(BASE_KEY)) {
......@@ -746,18 +751,24 @@ public class MainActivity extends AppCompatActivity implements
TextView color = findViewById(R.id.label_openhab_button);
if(isChecked_colorControl){
sendMqttUpdates.put(openhab_topic, isChecked_colorControl);
//sendMqttUpdates.put(openhab_topic1, isChecked_colorControl);
if(mColor == 1){
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){
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){
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);
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment