Skip to content

Commit

Permalink
2020.10.19:使用so库
Browse files Browse the repository at this point in the history
  • Loading branch information
konewu committed Oct 22, 2020
1 parent e3c45d0 commit a9b7c4e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

/**
* @Description: BLE常量
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/20 20:31.
*/
public class BleConstant {
public static final String SERVICE_UUID_FM60 = "0000f6f6-0000-1000-8000-00805f9b34fb"; //蓝牙服务的 UUID
Expand All @@ -12,27 +10,4 @@ public class BleConstant {
public static final String CHARACTERISTIC_UUID_FM67 = "0000f7f7-0000-1000-8000-00805f9b34fb"; //蓝牙服务下的 characteristic 的UUID
public static final String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";

public static final int TIME_FOREVER = -1;

public static final int DEFAULT_SCAN_TIME = 20000;
public static final int DEFAULT_CONN_TIME = 10000;
public static final int DEFAULT_OPERATE_TIME = 5000;

public static final int DEFAULT_RETRY_INTERVAL = 1000;
public static final int DEFAULT_RETRY_COUNT = 3;

public static final int DEFAULT_MAX_CONNECT_COUNT = 5;

public static final int MSG_CONNECT_TIMEOUT = 0x01;
public static final int MSG_WRITE_DATA_TIMEOUT = 0x02;
public static final int MSG_READ_DATA_TIMEOUT = 0x03;
public static final int MSG_RECEIVE_DATA_TIMEOUT = 0x04;
public static final int MSG_CONNECT_RETRY = 0x05;
public static final int MSG_WRITE_DATA_RETRY = 0x06;
public static final int MSG_READ_DATA_RETRY = 0x07;
public static final int MSG_RECEIVE_DATA_RETRY = 0x08;

//yankee
public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;

}
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,14 @@ private LinkedHashMap bindPhone(String datavalue){
Log.d(TAG,"绑定成功,blemac:"+bleMac + ",bleSno:"+bleSno);

//生成随机密码进行登录
String rndCode = ComTool.getRndNumber(6,9,10);
String rndCode = ComTool.getRndNumber();
String data = bleSno + SinovoBle.getInstance().getPhoneIMEI() + rndCode;
exeCommand("01", data, false);
exeCommand("11", bleSno, false); //查询锁的名称
exeCommand("1a", bleSno, false); //查询锁的固件版本

//同步锁端的时间
String nowtime = ComTool.getSpecialTime("",1,1,0);
String nowtime = ComTool.getSpecialTime(1,0);
nowtime = nowtime.replace(":","").replace(" ","").replace("-","");
nowtime = nowtime.substring(2);
data = bleSno + nowtime;
Expand Down Expand Up @@ -993,7 +993,7 @@ private LinkedHashMap calcTime(String datavalue){
String locktime = datavalue.substring(0, len-2);

// Log.d(TAG,"得到锁端的时间:"+locktime);
locktime = ComTool.getEDate(locktime, 0, false, true,true); //转换时间格式
locktime = ComTool.getEDate(locktime); //转换时间格式
map.put("lockTime",locktime);
}

Expand Down Expand Up @@ -1434,7 +1434,7 @@ private LinkedHashMap baseTime(String datavalue) {
map.put("baseTime", basetime);
}
if (errCode.equals("0a")){
String pre_basetime = ComTool.getSpecialTime("",0,1,-2);
String pre_basetime = ComTool.getSpecialTime(0,-2);
// Log.d(TAG,"还没设置基准时间,准备设置为:"+ pre_basetime);
String data = SinovoBle.getInstance().getLockSNO() +pre_basetime;
exeCommand("1f",data,true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
public class BleScanDevice {
private BluetoothDevice device;
private int averagerssi ;
int rssi;
byte[] scanRecord;
private int rssi;
private byte[] scanRecord;

private String joinTime; //设备加入队列的时间

Expand All @@ -24,23 +24,21 @@ public BluetoothDevice GetDevice() {
}

// 更新信息
public boolean ReflashInf(BluetoothDevice device, int rssi,
public void ReflashInf(BluetoothDevice device, int rssi,
byte[] scanRecord, String joinTime) {
this.device = device;
this.rssi = rssi;
this.scanRecord = scanRecord;
this.joinTime = joinTime;
averagerssi = (averagerssi + rssi) / 2;
return true;
}

public String getJoinTime() {
return joinTime;
}

public void setJoinTime(String joinTime) {
this.joinTime = joinTime;
}

// public void setJoinTime(String joinTime) {
// this.joinTime = joinTime;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import java.util.Objects;

public class BluetoothListenerReceiver extends BroadcastReceiver {
private String TAG = "SinovoBle";
@Override
public void onReceive(Context context, Intent intent) {
if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(Objects.requireNonNull(intent.getAction()))) {
int blueState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);
String TAG = "SinovoBle";
switch (blueState) {
case BluetoothAdapter.STATE_TURNING_ON:
Log.e(TAG, "onReceive---------Bluetooth is turning on");
Expand Down
Loading

0 comments on commit a9b7c4e

Please sign in to comment.