versionCode 1
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
- versionName '0.0.6'
+ versionName '2.0.0'
buildConfigField("String", "SDK_VERSION", "\"${versionName}\"")
multiDexEnabled true
}
import com.zhixun.blesdk.hssdk.callback.OnMsgSendCallBack;
import com.zhixun.blesdk.hssdk.data.BleMsgReceiverHandler;
import com.zhixun.blesdk.hssdk.data.BleMsgSendHandler;
+import com.zhixun.blesdk.hssdk.data.bean.ReceiverData;
import com.zhixun.blesdk.hssdk.entity.AppTime;
import com.zhixun.blesdk.hssdk.entity.E4MsgBody;
import com.zhixun.blesdk.hssdk.entity.HsDeviceInfo;
byte[] value = characteristic.getValue();
SobLog.d(TAG, "onCharacteristicChanged--" + characteristic.getUuid().toString() + ":" +
(value.length > 100 ? value.length : ByteTools.byteArrToHex(value)));
- if (BleUuidUtil.getInstance().getNotifyUUID().toString().equals(characteristic.getUuid().toString())) {
+ if (BleUuidUtil.getInstance().getNotifyUUID().toString().equals(characteristic.getUuid().toString())
+ ||BleUuidUtil.getInstance().getmAudioNotifyUUID().toString().equals(characteristic.getUuid().toString())) {
BleMsgReceiverHandler.getInstance().receiverData(value);
} else if (BleUuidUtil.getInstance().getFileNotifyUUID().toString().equals(characteristic.getUuid().toString())) {
- if (onBleControlCallback != null) {
- onBleControlCallback.onE7Receiver(value);
+
+ if(value[1]==0x08){
+ //ai数据内容
+ BleMsgReceiverHandler.getInstance().receiverData(value);
+ }else {
+ if (onBleControlCallback != null) {
+ onBleControlCallback.onE7Receiver(value);
+ }
}
+
}
}
BluetoothGattCharacteristic characteristic3 = service.getCharacteristic(BleUuidUtil.getInstance().getFileNotifyUUID());//对应server端的setCharacteristic方法
mBluetoothGatt.setCharacteristicNotification(characteristic3, true);
+
+ BluetoothGattCharacteristic characteristic4 = service.getCharacteristic(BleUuidUtil.getInstance().getmAudioNotifyUUID());//对应server端的setCharacteristic方法
+ mBluetoothGatt.setCharacteristicNotification(characteristic4, true);
}
public void deviceWrite(byte[] msg, int type) {
deviceWrite(data,6);
}
+
+
}
int dirrction = ByteTools.byte2Int(data[0]);//传输方向
SobLog.d(TAG, "receiverData--" +
dirrction);
- if(dirrction==0x72){
- ReceiverData receiverData = BleDataUtil.anscyData(data);
- if(receiverData==null)return;
- SobLog.d(TAG,"receiverData--"+receiverData.toString());
- if(receiverData.getDataNum()==1
- ||receiverData.getType()==TYPE_RECEIVER_LOG
+ if(receiverLooperThread.isStartSendAudio()){
+ receiverLooperThread.sendAudio(data);
+ }else {
+ if(dirrction==0x72){
+ ReceiverData receiverData = BleDataUtil.anscyData(data);
+ if(receiverData==null)return;
+ SobLog.d(TAG,"receiverData--"+receiverData.toString());
+ if(receiverData.getDataNum()==1
+ ||receiverData.getType()==TYPE_RECEIVER_LOG
// ||receiverData.getType()==TYPE_GET_WEAR_AUDIO
){
- //说明只有一条数据
- handData(receiverData);
- }else {
- SobLog.d(TAG,"receiverData-分包数据-"+receiverData.toString());
- //是分包数据
- if(splitDataMap.containsKey(receiverData.getType())){
- if (receiverData.getType()==TYPE_GET_WEAR_AUDIO){
- receiverLooperThread.removeAudioTimeOut();
- }
- ArrayList<ReceiverData> cacheData = splitDataMap.get(receiverData.getType());
- cacheData.add(receiverData);
- SobLog.d(TAG,"receiverData-已有-"+cacheData.size());
- if(receiverData.getDataNum()==receiverData.getPageId()
- &&cacheData.size()==receiverData.getDataNum()){
- //数据包已接收完成,进行组包
- //对列表里面的数据进行排序
- receiverData.setContent(composeData(cacheData));
- handData(receiverData);
- splitDataMap.remove(receiverData.getType());
-
- }else {
+ //说明只有一条数据
+ handData(receiverData);
+ }else {
+ SobLog.d(TAG,"receiverData-分包数据-"+receiverData.toString());
+ //是分包数据
+ if(splitDataMap.containsKey(receiverData.getType())){
if (receiverData.getType()==TYPE_GET_WEAR_AUDIO){
- receiverLooperThread.startAudioTimeOut();
+ receiverLooperThread.removeAudioTimeOut();
+ }
+ ArrayList<ReceiverData> cacheData = splitDataMap.get(receiverData.getType());
+ cacheData.add(receiverData);
+ SobLog.d(TAG,"receiverData-已有-"+cacheData.size());
+ if(receiverData.getDataNum()==receiverData.getPageId()
+ &&cacheData.size()==receiverData.getDataNum()){
+ //数据包已接收完成,进行组包
+ //对列表里面的数据进行排序
+ receiverData.setContent(composeData(cacheData));
+ handData(receiverData);
+ splitDataMap.remove(receiverData.getType());
+
+ }else {
+ if (receiverData.getType()==TYPE_GET_WEAR_AUDIO){
+ receiverLooperThread.startAudioTimeOut();
+ }
+ splitDataMap.put(receiverData.getType(),cacheData);
}
+
+ }else {
+ ArrayList<ReceiverData> cacheData = new ArrayList<>();
+ cacheData.add(receiverData);
splitDataMap.put(receiverData.getType(),cacheData);
}
-
- }else {
- ArrayList<ReceiverData> cacheData = new ArrayList<>();
- cacheData.add(receiverData);
- splitDataMap.put(receiverData.getType(),cacheData);
}
- }
+ }
}
+
}
private byte[] composeData(ArrayList<ReceiverData> cacheData){
import android.os.Message;
import android.util.Log;
+import androidx.annotation.BoolRes;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
public static final int TYPE_LOSS_FILE_PAGE = 1030;
public static final int TYPE_AI_READY = 1285;
+
public static final int TYPE_AI_CANCLE_CHAT = 1797;
public static final int TYPE_AI_CHECK_USERD = 1541;
public static final int TYPE_GET_WEAR_AUDIO = 13313;
public static final int TYPE_SEND_AI_RESULT = 7938;
+ public static final int TYPE_START_SEND = 264;
+ public static final int TYPE_STOP_SEND = 520;
+ private boolean startSendAudio = false;
private Handler mReceiverMsgHandle;
private HashMap<Integer, OnMsgSendCallBack> callBackMap = new HashMap<>();
FileHandler.getInstance().addLogContent(content);
break;
case TYPE_AI_READY:
+ SobLog.d(TAG, "TYPE_START_CHAT--");
E3MsgBody msgBody = new E3MsgBody(TYPE_AI_READY);
msgBody.setData(ByteTools.little_intToByte(1, 1));
BleMsgSendHandler.getInstance().sendMsg(msgBody, null);
}
// AiManage.getInstance().startTrans();
break;
+ case TYPE_START_SEND:
+ SobLog.d(TAG, "TYPE_START_SEND--");
+ if(iAiFunctionListener!=null){
+ iAiFunctionListener.onStart();
+ }
+ startSendAudio = true;
+ break;
+ case TYPE_STOP_SEND:
+ SobLog.d(TAG, "TYPE_STOP_SEND--");
+ if(iAiFunctionListener!=null){
+ iAiFunctionListener.onStop();
+ }
+ startSendAudio = false;
+ if(iAiFunctionListener!=null){
+ iAiFunctionListener.sendAudio(audioCache.length,audioCache);
+ }
+ audioCache = new byte[0];
+ break;
case TYPE_AI_CANCLE_CHAT:
SobLog.d(TAG, "TYPE_AI_CANCLE_CHAT--");
if(iAiFunctionListener!=null){
mReceiverMsgHandle.sendMessage(message);
}
+ private byte[] audioCache = new byte[0];
+ public synchronized void sendAudio(byte[] data){
+ SobLog.d(TAG, "sendAudio---");
+ audioCache = ByteTools.concatAll(audioCache,data);
+
+ }
+ public boolean isStartSendAudio() {
+ return startSendAudio;
+ }
+
public void addResponseCallBack(int type, OnMsgSendCallBack callBack) {
callBackMap.put(type, callBack);
}
public void clear() {
+ startSendAudio = false;
callBackMap.clear();
if (mReceiverMsgHandle != null) mReceiverMsgHandle.removeMessages(MSG_RECEIVERDATA);
public static final int TYPE_GET_SOS = 13825;
public static final int TYPE_SET_SOS = 9474;
+ //AI2.0
+// public static final int TYPE_START_CHAT = 264;
+// public static final int TYPE_CHAT_AUDIO = 520;
+// public static final int TYPE_CHAT_MSG = 776;
+// public static final int TYPE_CHAT_ENABLE = 1032;
+// public static final int TYPE_CHAT_CANCLE = 1288;
+
public static final int TYPE_GET_DIR = 289;
public static int TRAIN_TYPE_WALKING = 0;
public static int TRAIN_TYPE_RUN = 1;
public static final int CHANNEL_E4 = 4;
public static final int CHANNEL_E6 = 6;
-
+ public static final int CHANNEL_E8 = 8;
private int channel;
private int port;
private int type;
private UUID w2AE6UUID = UUID.fromString("00002ae6-0000-1000-8000-00805f9b34fb");//新的文件传输通道
+ private UUID mAudioNotifyUUID = UUID.fromString("00002ae8-0000-1000-8000-00805f9b34fb");//新的AI传输通道
+
private UUID w2AE1UUID = UUID.fromString("00002ae1-0000-1000-8000-00805f9b34fb");//客户端推送消息(仅Android)(发送字节数>20)
private UUID mNotifyUUID = UUID.fromString("00002ae5-0000-1000-8000-00805f9b34fb");//客户端接收
return mFileNotifyUUID;
}
+ public UUID getmAudioNotifyUUID() {
+ return mAudioNotifyUUID;
+ }
+
public UUID getServiceUUID() {
return mServiceUUID;
}