|
|
|
|
|
|
|
|
import com.pingwang.bluetoothlib.utils.BleDataUtils; |
|
|
import com.pingwang.bluetoothlib.utils.BleDataUtils; |
|
|
import com.pingwang.bluetoothlib.utils.BleLog; |
|
|
import com.pingwang.bluetoothlib.utils.BleLog; |
|
|
import com.pingwang.bluetoothlib.utils.BleStrUtils; |
|
|
import com.pingwang.bluetoothlib.utils.BleStrUtils; |
|
|
import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; |
|
|
|
|
|
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Locale; |
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
|
|
import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; |
|
|
|
|
|
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; |
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.annotation.Nullable; |
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final int REFRESH_DATA = 3; |
|
|
private final int REFRESH_DATA = 3; |
|
|
private List<String> mList; |
|
|
private List<String> mList; |
|
|
private ArrayAdapter listAdapter; |
|
|
private ArrayAdapter listAdapter; |
|
|
private EditText etName, etMacType, etCid, etVid, etPid, etBroadcastTime, etMcuType, etSleepTime, et_set_device; |
|
|
|
|
|
|
|
|
private EditText etName, etMacType, etBroadcastTime, etMcuType, etSleepTime, et_set_device; |
|
|
private Context mContext; |
|
|
private Context mContext; |
|
|
private String mAddress; |
|
|
private String mAddress; |
|
|
private BleSendCmdUtil mBleSendCmdUtil; |
|
|
private BleSendCmdUtil mBleSendCmdUtil; |
|
|
|
|
|
|
|
|
findViewById(R.id.btnMacTypeRead).setOnClickListener(this); |
|
|
findViewById(R.id.btnMacTypeRead).setOnClickListener(this); |
|
|
findViewById(R.id.btnNameWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnNameWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnMacTypeWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnMacTypeWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnDidWrite).setOnClickListener(this); |
|
|
|
|
|
findViewById(R.id.btnDidRead).setOnClickListener(this); |
|
|
findViewById(R.id.btnDidRead).setOnClickListener(this); |
|
|
findViewById(R.id.btnBroadcastTimeWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnBroadcastTimeWrite).setOnClickListener(this); |
|
|
findViewById(R.id.btnBroadcastTimeRead).setOnClickListener(this); |
|
|
findViewById(R.id.btnBroadcastTimeRead).setOnClickListener(this); |
|
|
|
|
|
|
|
|
findViewById(R.id.btnConnect).setOnClickListener(this); |
|
|
findViewById(R.id.btnConnect).setOnClickListener(this); |
|
|
etName = findViewById(R.id.etName); |
|
|
etName = findViewById(R.id.etName); |
|
|
etMacType = findViewById(R.id.etMacType); |
|
|
etMacType = findViewById(R.id.etMacType); |
|
|
etCid = findViewById(R.id.etCid); |
|
|
|
|
|
etVid = findViewById(R.id.etVid); |
|
|
|
|
|
etPid = findViewById(R.id.etPid); |
|
|
|
|
|
etBroadcastTime = findViewById(R.id.etBroadcastTime); |
|
|
etBroadcastTime = findViewById(R.id.etBroadcastTime); |
|
|
etMcuType = findViewById(R.id.etMcuType); |
|
|
etMcuType = findViewById(R.id.etMcuType); |
|
|
etSleepTime = findViewById(R.id.etSleepTime); |
|
|
etSleepTime = findViewById(R.id.etSleepTime); |
|
|
|
|
|
|
|
|
sendBleBean.setHex(mBleSendCmdUtil.setBleBroadcastTime(broadcastTime)); |
|
|
sendBleBean.setHex(mBleSendCmdUtil.setBleBroadcastTime(broadcastTime)); |
|
|
sendData(sendBleBean); |
|
|
sendData(sendBleBean); |
|
|
break; |
|
|
break; |
|
|
case R.id.btnDidWrite: |
|
|
|
|
|
try { |
|
|
|
|
|
String cidS = etCid.getText().toString().trim().toLowerCase(Locale.US); |
|
|
|
|
|
String vidS = etVid.getText().toString().trim().toLowerCase(Locale.US); |
|
|
|
|
|
String pidS = etPid.getText().toString().trim().toLowerCase(Locale.US); |
|
|
|
|
|
int cid = 0; |
|
|
|
|
|
int vid = 0; |
|
|
|
|
|
int pid = 0; |
|
|
|
|
|
if (!TextUtils.isEmpty(cidS)) { |
|
|
|
|
|
cid = Integer.parseInt(cidS); |
|
|
|
|
|
} |
|
|
|
|
|
if (!TextUtils.isEmpty(vidS)) { |
|
|
|
|
|
vid = Integer.parseInt(vidS); |
|
|
|
|
|
} |
|
|
|
|
|
if (!TextUtils.isEmpty(pidS)) { |
|
|
|
|
|
pid = Integer.parseInt(pidS); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
byte[] did = bleDataUtils.getDid(1, 1, 1, cid, vid, pid); |
|
|
|
|
|
sendBleBean = new SendBleBean(); |
|
|
|
|
|
sendBleBean.setHex(mBleSendCmdUtil.setDid(did)); |
|
|
|
|
|
sendData(sendBleBean); |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case R.id.btnDidRead: |
|
|
case R.id.btnDidRead: |
|
|
sendBleBean = new SendBleBean(); |
|
|
sendBleBean = new SendBleBean(); |
|
|
sendBleBean.setHex(mBleSendCmdUtil.getDid()); |
|
|
sendBleBean.setHex(mBleSendCmdUtil.getDid()); |