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