Skip to content

Commit

Permalink
add:增加支持tc1 1.0.0以下旧版本固件通信协议
Browse files Browse the repository at this point in the history
版本:0.11.6
  • Loading branch information
a2633063 committed Sep 23, 2019
1 parent b3c050d commit 6c902dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 20
versionName "v0.11.5"
versionName "v0.11.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,15 @@ public void onClick(View v) {

void Send(String message) {
if (mConnectService == null) return;
boolean b = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/ztc1/" + device_mac + "/set", message);
boolean udp = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/ztc1/set";
else topic = "device/ztc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message);
}

//数据接收处理函数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,16 @@ public void onClick(View v) {

//region 数据接收发送处理函数
void Send(String message) {
boolean b = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/ztc1/" + device_mac + "/set", message);
if (mConnectService == null) return;
boolean udp = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/ztc1/set";
else topic = "device/ztc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message);
}

void Receive(String ip, int port, String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,16 @@ public void onClick(DialogInterface dialogInterface, int i) {
//endregion

void Send(String message) {
boolean b = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/ztc1/" + device_mac + "/set", message);
if (mConnectService == null) return;
boolean udp = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/ztc1/set";
else topic = "device/ztc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message);
}

//数据接收处理函数
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/tc1_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
android:title="重新获取数据"
android:summary="获取版本/激活状态失败时点此重试"/>

<CheckBoxPreference
android:defaultValue="false"
android:disableDependentsState="true"
android:key="old_protocol"
android:summary="固件版本1.0.0以下时,请勾选此项"
android:title="使用旧版通信协议" />

</PreferenceCategory>

</PreferenceScreen>

0 comments on commit 6c902dc

Please sign in to comment.