|
@@ -60,6 +60,7 @@ import com.gimi.common.cinema.utils.ScreenUtils; |
|
@@ -60,6 +60,7 @@ import com.gimi.common.cinema.utils.ScreenUtils; |
|
60
|
import com.gimi.common.cinema.utils.SystemUtils;
|
60
|
import com.gimi.common.cinema.utils.SystemUtils;
|
|
61
|
import com.qnbar.smc.model.Light;
|
61
|
import com.qnbar.smc.model.Light;
|
|
62
|
import com.qnbar.smc.model.Lights;
|
62
|
import com.qnbar.smc.model.Lights;
|
|
|
|
63
|
+import com.qnbar.smc.service.SocketService;
|
|
63
|
import com.qnbar.smc.service.TelinkLightService;
|
64
|
import com.qnbar.smc.service.TelinkLightService;
|
|
64
|
import com.telink.bluetooth.LeBluetooth;
|
65
|
import com.telink.bluetooth.LeBluetooth;
|
|
65
|
import com.telink.bluetooth.TelinkLog;
|
66
|
import com.telink.bluetooth.TelinkLog;
|
|
@@ -153,7 +154,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -153,7 +154,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
153
|
EventBus.getDefault().register(this);
|
154
|
EventBus.getDefault().register(this);
|
|
154
|
|
155
|
|
|
155
|
initLight();
|
156
|
initLight();
|
|
156
|
-// initLock();
|
157
|
+ initLock();
|
|
157
|
context = this;
|
158
|
context = this;
|
|
158
|
mData = new ArrayList<>();
|
159
|
mData = new ArrayList<>();
|
|
159
|
clazzData = new ArrayList<>();
|
160
|
clazzData = new ArrayList<>();
|
|
@@ -171,7 +172,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -171,7 +172,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
171
|
mainSearch = (Button) findViewById(R.id.mainSearch);
|
172
|
mainSearch = (Button) findViewById(R.id.mainSearch);
|
|
172
|
scrollView = (ScrollView) findViewById(R.id.scrollView);
|
173
|
scrollView = (ScrollView) findViewById(R.id.scrollView);
|
|
173
|
clazzRv = (OrderRecyclerView) findViewById(R.id.classification);
|
174
|
clazzRv = (OrderRecyclerView) findViewById(R.id.classification);
|
|
174
|
- sourceTypeIv.setVisibility(View.INVISIBLE);
|
175
|
+// sourceTypeIv.setVisibility(View.INVISIBLE);
|
|
175
|
mainSearch.setTextColor(Color.GRAY);
|
176
|
mainSearch.setTextColor(Color.GRAY);
|
|
176
|
mainSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
177
|
mainSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
177
|
@Override
|
178
|
@Override
|
|
@@ -204,6 +205,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -204,6 +205,8 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
204
|
clazzRv.setAdapter(adapterClazz);
|
205
|
clazzRv.setAdapter(adapterClazz);
|
|
205
|
|
206
|
|
|
206
|
presenter.load(this);
|
207
|
presenter.load(this);
|
|
|
|
208
|
+ Intent intent = new Intent(this, SocketService.class);
|
|
|
|
209
|
+ startService(intent);
|
|
207
|
}
|
210
|
}
|
|
208
|
|
211
|
|
|
209
|
|
212
|
|
|
@@ -608,7 +611,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -608,7 +611,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
608
|
|
611
|
|
|
609
|
//lock
|
612
|
//lock
|
|
610
|
private String openCMD = "Open the door";
|
613
|
private String openCMD = "Open the door";
|
|
611
|
- private String onClickDeviceMac;
|
614
|
+// private String onClickDeviceMac;
|
|
612
|
|
615
|
|
|
613
|
private boolean HAS_SYSTEM_FEATURE_BLUETOOTH_LE = true;
|
616
|
private boolean HAS_SYSTEM_FEATURE_BLUETOOTH_LE = true;
|
|
614
|
private BLEBroadcastReceiver bleBroadcastReceiver = new BLEBroadcastReceiver();
|
617
|
private BLEBroadcastReceiver bleBroadcastReceiver = new BLEBroadcastReceiver();
|
|
@@ -622,7 +625,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -622,7 +625,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
622
|
startService(new Intent(this, GREENBluetoothLeService.class));
|
625
|
startService(new Intent(this, GREENBluetoothLeService.class));
|
|
623
|
}
|
626
|
}
|
|
624
|
|
627
|
|
|
625
|
- bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() {
|
628
|
+ /* bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() {
|
|
626
|
|
629
|
|
|
627
|
@Override
|
630
|
@Override
|
|
628
|
public void writeSuccess() {
|
631
|
public void writeSuccess() {
|
|
@@ -630,7 +633,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -630,7 +633,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
630
|
Toast.makeText(MainActivity.this, "开门成功", Toast.LENGTH_SHORT).show();
|
633
|
Toast.makeText(MainActivity.this, "开门成功", Toast.LENGTH_SHORT).show();
|
|
631
|
|
634
|
|
|
632
|
BLEOpenRecord bleOpenRecord = new BLEOpenRecord();
|
635
|
BLEOpenRecord bleOpenRecord = new BLEOpenRecord();
|
|
633
|
- bleOpenRecord.setLockmac(onClickDeviceMac);
|
636
|
+ bleOpenRecord.setLockmac("DC:F6:70:C1:AA:D6");
|
|
634
|
bleOpenRecord.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
|
637
|
bleOpenRecord.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
|
|
635
|
Intent intent = new Intent();
|
638
|
Intent intent = new Intent();
|
|
636
|
intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS);
|
639
|
intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS);
|
|
@@ -644,7 +647,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -644,7 +647,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
644
|
Toast.makeText(MainActivity.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
|
647
|
Toast.makeText(MainActivity.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
|
|
645
|
}
|
648
|
}
|
|
646
|
});
|
649
|
});
|
|
647
|
- GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());
|
650
|
+ GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());*/
|
|
648
|
}
|
651
|
}
|
|
649
|
|
652
|
|
|
650
|
@Override
|
653
|
@Override
|
|
@@ -855,9 +858,36 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
@@ -855,9 +858,36 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
|
855
|
Log.d("event bus", messageEvent.getMessage());
|
858
|
Log.d("event bus", messageEvent.getMessage());
|
|
856
|
break;
|
859
|
break;
|
|
857
|
case 1701:
|
860
|
case 1701:
|
|
858
|
- initLock();
|
861
|
+ openDoor();
|
|
859
|
Log.d("event bus", messageEvent.getMessage());
|
862
|
Log.d("event bus", messageEvent.getMessage());
|
|
|
|
863
|
+ Log.d("event bus", "open door");
|
|
860
|
break;
|
864
|
break;
|
|
861
|
}
|
865
|
}
|
|
862
|
}
|
866
|
}
|
|
|
|
867
|
+
|
|
|
|
868
|
+ private void openDoor(){
|
|
|
|
869
|
+ bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() {
|
|
|
|
870
|
+
|
|
|
|
871
|
+ @Override
|
|
|
|
872
|
+ public void writeSuccess() {
|
|
|
|
873
|
+ bleBroadcastReceiver.setResponseObj(null);
|
|
|
|
874
|
+ Toast.makeText(MainActivity.this, "开门成功", Toast.LENGTH_SHORT).show();
|
|
|
|
875
|
+
|
|
|
|
876
|
+ BLEOpenRecord bleOpenRecord = new BLEOpenRecord();
|
|
|
|
877
|
+ bleOpenRecord.setLockmac("DC:F6:70:C1:AA:D6");
|
|
|
|
878
|
+ bleOpenRecord.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
|
|
|
|
879
|
+ Intent intent = new Intent();
|
|
|
|
880
|
+ intent.setAction(GREENBluetoothLeService.ACTION_OPEN_SUCCESS);
|
|
|
|
881
|
+ intent.putExtra("openrecord", bleOpenRecord);
|
|
|
|
882
|
+ sendBroadcast(intent);
|
|
|
|
883
|
+ }
|
|
|
|
884
|
+
|
|
|
|
885
|
+ @Override
|
|
|
|
886
|
+ public void writeFailure(String error) {
|
|
|
|
887
|
+ bleBroadcastReceiver.setResponseObj(null);
|
|
|
|
888
|
+ Toast.makeText(MainActivity.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
|
|
|
|
889
|
+ }
|
|
|
|
890
|
+ });
|
|
|
|
891
|
+ GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes());
|
|
|
|
892
|
+ }
|
|
863
|
} |
893
|
} |