Showing
6 changed files
with
26 additions
and
22 deletions
| ... | ... | @@ -84,7 +84,7 @@ android { |
| 84 | 84 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' |
| 85 | 85 | } |
| 86 | 86 | debug { |
| 87 | - buildConfigField 'String', 'DEFAULT_IP', "\"192.168.4.215\"" | |
| 87 | + buildConfigField 'String', 'DEFAULT_IP', "\"192.168.4.200\"" | |
| 88 | 88 | // buildConfigField 'String', 'MACHINE_TYPE', "\"himedia\""; |
| 89 | 89 | // buildConfigField 'boolean', 'USE_GLIDE', "true"; |
| 90 | 90 | // manifestPlaceholders = [label: "青柠影咖", icon: "@drawable/ic_luancher", channel: "QNJM"] | ... | ... |
| ... | ... | @@ -45,7 +45,7 @@ public class Constant { |
| 45 | 45 | |
| 46 | 46 | public static final String DEFAULT_IP = BuildConfig.DEFAULT_IP; |
| 47 | 47 | public static final String DEFAULT_USER = "admin"; |
| 48 | - public static final String DEFAULT_PWD = "Asd123456"; | |
| 48 | + public static final String DEFAULT_PWD = "zxc123456"; | |
| 49 | 49 | public static final String DEFAULT_FOLDER = "root"; |
| 50 | 50 | public static final String DEFAULT_PATH = ""; |
| 51 | 51 | public static boolean userOpen = false; | ... | ... |
| ... | ... | @@ -5,11 +5,9 @@ import android.content.Intent; |
| 5 | 5 | import android.os.Handler; |
| 6 | 6 | import android.os.IBinder; |
| 7 | 7 | import android.util.Log; |
| 8 | - | |
| 9 | 8 | import com.gimi.common.cinema.model.MessageEvent; |
| 10 | 9 | import com.google.gson.Gson; |
| 11 | 10 | import com.google.gson.JsonSyntaxException; |
| 12 | - | |
| 13 | 11 | import org.greenrobot.eventbus.EventBus; |
| 14 | 12 | |
| 15 | 13 | import java.io.IOException; |
| ... | ... | @@ -22,7 +20,12 @@ import java.util.Arrays; |
| 22 | 20 | |
| 23 | 21 | public class SocketService extends Service { |
| 24 | 22 | private static final String TAG = "BackService"; |
| 25 | - private static final long HEART_BEAT_RATE = 30 * 1000; | |
| 23 | + private static final long HEART_BEAT_RATE = 10 * 1000; | |
| 24 | + | |
| 25 | + public static final int OPEN_DOOR_CMD = 1701; | |
| 26 | + | |
| 27 | + private static final int ROOM_HAS_REGISTERED = 1001; | |
| 28 | + private static final int ROOM_NOT_EXIST_M = 1002; | |
| 26 | 29 | |
| 27 | 30 | public static final String HOST = "121.43.189.162";// "192.168.1.21";// |
| 28 | 31 | public static final int PORT = 9501; |
| ... | ... | @@ -30,7 +33,7 @@ public class SocketService extends Service { |
| 30 | 33 | public static final String MESSAGE_ACTION = "com.dingmore.terminal.socket"; |
| 31 | 34 | public static final String HEART_BEAT_ACTION = "com.dingmore.terminal.socket.heart"; |
| 32 | 35 | |
| 33 | - public static final String HEART_BEAT_STRING = "00";//心跳包内容 | |
| 36 | + public static final String HEART_BEAT_STRING = "\\r\\n\\r\\n";//心跳包内容 | |
| 34 | 37 | |
| 35 | 38 | private ReadThread mReadThread; |
| 36 | 39 | private Gson gson; |
| ... | ... | @@ -181,20 +184,20 @@ public class SocketService extends Service { |
| 181 | 184 | try { |
| 182 | 185 | SocketResponse socketResponse = gson.fromJson(message.trim(), SocketResponse.class); |
| 183 | 186 | switch (socketResponse.getCode()) { |
| 184 | - case 1001: | |
| 187 | + case ROOM_HAS_REGISTERED: | |
| 185 | 188 | sendMsg("{\"cmd\":\"reconnect\",\"data\":{\"room_sn\":\"000002\"}}\\r\\n\\r\\n"); |
| 186 | 189 | Log.d(TAG, "send reconnect mes"); |
| 187 | 190 | break; |
| 188 | - case 1002: | |
| 191 | + case ROOM_NOT_EXIST_M: | |
| 189 | 192 | Log.d(TAG, "re init socket"); |
| 190 | - // sendRegister = false; | |
| 193 | + //sendRegister = false; | |
| 191 | 194 | releaseLastSocket(mWeakSocket); |
| 192 | 195 | initSocket(); |
| 193 | 196 | break; |
| 194 | 197 | } |
| 195 | 198 | if (("openDoor").equals(socketResponse.getCmd())) { |
| 196 | 199 | MessageEvent messageEvent = new MessageEvent(); |
| 197 | - messageEvent.setEventId(1701); | |
| 200 | + messageEvent.setEventId(OPEN_DOOR_CMD); | |
| 198 | 201 | messageEvent.setMessage("click item"); |
| 199 | 202 | EventBus.getDefault().post(messageEvent); |
| 200 | 203 | } | ... | ... |
| ... | ... | @@ -42,7 +42,6 @@ import android.widget.ImageView; |
| 42 | 42 | import android.widget.RelativeLayout; |
| 43 | 43 | import android.widget.ScrollView; |
| 44 | 44 | import android.widget.Toast; |
| 45 | - | |
| 46 | 45 | import com.bluetoothle.BLEBroadcastReceiver; |
| 47 | 46 | import com.bluetoothle.BLEOpenRecord; |
| 48 | 47 | import com.bluetoothle.GREENBluetoothLeService; |
| ... | ... | @@ -87,7 +86,6 @@ import com.xgimi.gimicinema.presenter.MainPresenter; |
| 87 | 86 | import com.xgimi.gimicinema.view.ClazzItem; |
| 88 | 87 | import com.xgimi.gimicinema.view.MovieItem; |
| 89 | 88 | import com.xgimi.gimicinema.view.OrderRecyclerView; |
| 90 | - | |
| 91 | 89 | import org.greenrobot.eventbus.EventBus; |
| 92 | 90 | import org.greenrobot.eventbus.Subscribe; |
| 93 | 91 | import org.greenrobot.eventbus.ThreadMode; |
| ... | ... | @@ -172,7 +170,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 172 | 170 | mainSearch = (Button) findViewById(R.id.mainSearch); |
| 173 | 171 | scrollView = (ScrollView) findViewById(R.id.scrollView); |
| 174 | 172 | clazzRv = (OrderRecyclerView) findViewById(R.id.classification); |
| 175 | -// sourceTypeIv.setVisibility(View.INVISIBLE); | |
| 173 | + sourceTypeIv.setVisibility(View.INVISIBLE); | |
| 176 | 174 | mainSearch.setTextColor(Color.GRAY); |
| 177 | 175 | mainSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
| 178 | 176 | @Override |
| ... | ... | @@ -851,13 +849,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 851 | 849 | @Subscribe(threadMode = ThreadMode.MAIN) |
| 852 | 850 | public void onMoonEvent(MessageEvent messageEvent) { |
| 853 | 851 | switch (messageEvent.getEventId()) { |
| 854 | - case 0: | |
| 855 | - Log.d("event bus", messageEvent.getMessage()); | |
| 856 | - break; | |
| 857 | - case 1: | |
| 858 | - Log.d("event bus", messageEvent.getMessage()); | |
| 859 | - break; | |
| 860 | - case 1701: | |
| 852 | + case SocketService.OPEN_DOOR_CMD: | |
| 861 | 853 | openDoor(); |
| 862 | 854 | Log.d("event bus", messageEvent.getMessage()); |
| 863 | 855 | Log.d("event bus", "open door"); |
| ... | ... | @@ -865,7 +857,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 865 | 857 | } |
| 866 | 858 | } |
| 867 | 859 | |
| 868 | - private void openDoor(){ | |
| 860 | + private void openDoor() { | |
| 869 | 861 | bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() { |
| 870 | 862 | |
| 871 | 863 | @Override |
| ... | ... | @@ -887,6 +879,7 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen |
| 887 | 879 | bleBroadcastReceiver.setResponseObj(null); |
| 888 | 880 | Toast.makeText(MainActivity.this, "开门失败," + error, Toast.LENGTH_SHORT).show(); |
| 889 | 881 | } |
| 882 | + | |
| 890 | 883 | }); |
| 891 | 884 | GREENBLE.send(this, "DC:F6:70:C1:AA:D6", openCMD.getBytes()); |
| 892 | 885 | } | ... | ... |
| ... | ... | @@ -274,6 +274,10 @@ public class CinemaControlService extends Service { |
| 274 | 274 | |
| 275 | 275 | private void fadeIn() { |
| 276 | 276 | DeviceInfo connectDevice = mApplication.getConnectDevice(); |
| 277 | + if (connectDevice == null) { | |
| 278 | + Log.d("aidl", "connect device is null"); | |
| 279 | + return; | |
| 280 | + } | |
| 277 | 281 | Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); |
| 278 | 282 | if (byMeshAddress.status == ConnectionStatus.ON) { |
| 279 | 283 | return; |
| ... | ... | @@ -286,6 +290,10 @@ public class CinemaControlService extends Service { |
| 286 | 290 | |
| 287 | 291 | private void fadeOut() { |
| 288 | 292 | DeviceInfo connectDevice = mApplication.getConnectDevice(); |
| 293 | + if (connectDevice == null) { | |
| 294 | + Log.d("aidl", "connect device is null"); | |
| 295 | + return; | |
| 296 | + } | |
| 289 | 297 | Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); |
| 290 | 298 | if (byMeshAddress.status == ConnectionStatus.OFF) { |
| 291 | 299 | return; | ... | ... |
Please
register
or
login
to post a comment