diff --git a/iFish7/build.gradle b/iFish7/build.gradle
index 1d76b82fb..acb9035a8 100644
--- a/iFish7/build.gradle
+++ b/iFish7/build.gradle
@@ -174,7 +174,7 @@ dependencies {
implementation 'com.tencent:mmkv:2.0.0'
implementation("com.github.bumptech.glide:okhttp3-integration:4.11.0" )
- implementation 'com.github.Jasonchenlijian:FastBle:2.4.0'
+// implementation 'com.github.Jasonchenlijian:FastBle:2.4.0'
//
// annotationProcessor 'com.github.bumptech.glide:compiler:3.7.0'
// implementation 'com.getui:gtsdk:3.3.7.0' //个推SDK
diff --git a/iFish7/src/main/AndroidManifest.xml b/iFish7/src/main/AndroidManifest.xml
index 74ddde4e8..d5b24e2d6 100644
--- a/iFish7/src/main/AndroidManifest.xml
+++ b/iFish7/src/main/AndroidManifest.xml
@@ -18,7 +18,7 @@
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
-
+
@@ -29,61 +29,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -102,23 +62,9 @@
android:required="true" />
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -243,14 +149,14 @@
android:resource="@xml/filepaths" />
-
-
-
-
-
+
+
+
+
+
+
+
+
baseBean) {
result = baseBean.result;
- BleManager.getInstance().disconnectAllDevice();
+ //jjia-push
+// BleManager.getInstance().disconnectAllDevice();
}
@Override
diff --git a/iFish7/src/main/java/com/ifish/activity/NewBindDeviceChoiceActivity.java b/iFish7/src/main/java/com/ifish/activity/NewBindDeviceChoiceActivity.java
index 22bfbb73b..a5dbd892b 100644
--- a/iFish7/src/main/java/com/ifish/activity/NewBindDeviceChoiceActivity.java
+++ b/iFish7/src/main/java/com/ifish/activity/NewBindDeviceChoiceActivity.java
@@ -21,7 +21,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.jwkj.soundwave.SoundWaveManager;
import com.ifish.airkiss.AirKissEncoder;
-import com.ifish.airkiss.UDPReceiver;
+//import com.ifish.airkiss.UDPReceiver;
import com.ifish.airkiss.UdpCallback;
import com.ifish.basebean.BaseBean;
import com.ifish.basebean.ConnectMessageEvent;
@@ -83,7 +83,8 @@ public class NewBindDeviceChoiceActivity extends BaseActivity implements View.On
private int deviceIsNullNum = 0;//循环请求次数
private CountDownTimer deviceIsNullTimer;
// private DatagramSocket sendSocket = null;
- private UDPReceiver udpReceiver = null;
+ //jjia-udp
+// private UDPReceiver udpReceiver = null;
private boolean isRegFilter;
private byte mAuthMode;
private byte AuthModeOpen = 0;
diff --git a/iFish7/src/main/java/com/ifish/activity/newbind/AirKissUtil.java b/iFish7/src/main/java/com/ifish/activity/newbind/AirKissUtil.java
index a83b896b3..57681fc1e 100644
--- a/iFish7/src/main/java/com/ifish/activity/newbind/AirKissUtil.java
+++ b/iFish7/src/main/java/com/ifish/activity/newbind/AirKissUtil.java
@@ -12,7 +12,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.ifish.activity.LoadingActivity;
import com.ifish.airkiss.AirKissEncoder;
-import com.ifish.airkiss.UDPReceiver;
import com.ifish.basebean.BaseBean;
import com.ifish.basebean.Device;
import com.ifish.baseclass.BaseGradeActivity;
@@ -71,8 +70,8 @@ public class AirKissUtil {
//当前需要连接的是什么设备
private String devicetype;
-
- private UDPReceiver udpReceiver = null;
+ //jjia-udp
+// private UDPReceiver udpReceiver = null;
private DatagramSocket sendSocket = null;
ProgressDialog mDialog = null;
@@ -432,9 +431,9 @@ public class AirKissUtil {
sendSocket.close();
sendSocket.disconnect();
}
- if (udpReceiver != null) {
- udpReceiver.stopRunning();
- }
+// if (udpReceiver != null) {
+// udpReceiver.stopRunning();
+// }
}
public void unSubscribe() {
diff --git a/iFish7/src/main/java/com/ifish/activity/newbind/NewBindDeviceActivity.java b/iFish7/src/main/java/com/ifish/activity/newbind/NewBindDeviceActivity.java
index a31018ee4..dec378755 100644
--- a/iFish7/src/main/java/com/ifish/activity/newbind/NewBindDeviceActivity.java
+++ b/iFish7/src/main/java/com/ifish/activity/newbind/NewBindDeviceActivity.java
@@ -29,15 +29,15 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
-
-import com.clj.fastble.BleManager;
-import com.clj.fastble.callback.BleGattCallback;
-import com.clj.fastble.callback.BleMtuChangedCallback;
-import com.clj.fastble.callback.BleNotifyCallback;
-import com.clj.fastble.callback.BleScanCallback;
-import com.clj.fastble.callback.BleWriteCallback;
-import com.clj.fastble.data.BleDevice;
-import com.clj.fastble.exception.BleException;
+//jjia-push
+//import com.clj.fastble.BleManager;
+//import com.clj.fastble.callback.BleGattCallback;
+//import com.clj.fastble.callback.BleMtuChangedCallback;
+//import com.clj.fastble.callback.BleNotifyCallback;
+//import com.clj.fastble.callback.BleScanCallback;
+//import com.clj.fastble.callback.BleWriteCallback;
+//import com.clj.fastble.data.BleDevice;
+//import com.clj.fastble.exception.BleException;
import com.ifish.activity.BindCameraActivity;
import com.ifish.activity.BindTankActivity;
import com.ifish.activity.BindTankPetActivity;
@@ -151,8 +151,8 @@ public class NewBindDeviceActivity extends AppCompatActivity {
devicetype = getIntent().getStringExtra("devicetype");
L.i("jjia----------------devicetype="+devicetype);
airKissUtil.init(this,devicetype);
-
- BleManager.getInstance().disconnectAllDevice();
+ //jjia-push
+// BleManager.getInstance().disconnectAllDevice();
if ("bluetooth".equals(type)){
curConnectType = BlueTooth;
}else {
@@ -163,7 +163,8 @@ public class NewBindDeviceActivity extends AppCompatActivity {
switchUIConnectType(curConnectType);
if ("bluetooth".equals(type)){ // 主动去联网
- currentDevice = getIntent().getParcelableExtra("device");
+ //jjia-push
+// currentDevice = getIntent().getParcelableExtra("device");
}
EventBus.getDefault().register(this);
@@ -471,39 +472,40 @@ public class NewBindDeviceActivity extends AppCompatActivity {
- boolean support = BleManager.getInstance().isSupportBle();
- if (!support){
- ToastUtil.show(NewBindDeviceActivity.this,"当前设备不支持低功耗蓝牙");
- } else {
- boolean enable = BleManager.getInstance().isBlueEnable();
- if (enable){
- if (TextUtils.isEmpty(type)){
- blueScan();
- }else {
- showDialog("开始连接蓝牙设备");
- connectBle();
- }
- }else {
- AlertDialog.Builder dialog = new AlertDialog.Builder(NewBindDeviceActivity.this, AlertDialog.THEME_HOLO_LIGHT);
- dialog.setCancelable(false);
- dialog.setMessage("蓝牙没有打开,现在去申请打开蓝牙,请允许后,再点击'确定'连接");
- dialog.setPositiveButton("去申请", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(
- DialogInterface dialog,
- int which) {
- BlueToothUtil.openBlueTooth(NewBindDeviceActivity.this);
- }
- });
- dialog.setNegativeButton("拒绝", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- });
- dialog.show();
- }
- }
+ //jjia-push
+// boolean support = BleManager.getInstance().isSupportBle();
+// if (!support){
+// ToastUtil.show(NewBindDeviceActivity.this,"当前设备不支持低功耗蓝牙");
+// } else {
+// boolean enable = BleManager.getInstance().isBlueEnable();
+// if (enable){
+// if (TextUtils.isEmpty(type)){
+// blueScan();
+// }else {
+// showDialog("开始连接蓝牙设备");
+// connectBle();
+// }
+// }else {
+// AlertDialog.Builder dialog = new AlertDialog.Builder(NewBindDeviceActivity.this, AlertDialog.THEME_HOLO_LIGHT);
+// dialog.setCancelable(false);
+// dialog.setMessage("蓝牙没有打开,现在去申请打开蓝牙,请允许后,再点击'确定'连接");
+// dialog.setPositiveButton("去申请", new DialogInterface.OnClickListener() {
+// @Override
+// public void onClick(
+// DialogInterface dialog,
+// int which) {
+// BlueToothUtil.openBlueTooth(NewBindDeviceActivity.this);
+// }
+// });
+// dialog.setNegativeButton("拒绝", new DialogInterface.OnClickListener() {
+// @Override
+// public void onClick(DialogInterface dialog, int which) {
+// finish();
+// }
+// });
+// dialog.show();
+// }
+// }
break;
case APConnect:
@@ -518,43 +520,44 @@ public class NewBindDeviceActivity extends AppCompatActivity {
break;
}
}
-
- private void blueScan(){
- BleManager.getInstance().scan(new BleScanCallback() {
- @Override
- public void onScanFinished(List scanResultList) {
-
- if (currentDevice!=null){
- connectBle();
- }else {
- ToastUtil.show(NewBindDeviceActivity.this,"扫描结束,没有搜索到可用设备");
- dismissDialog();
- }
- }
-
- @Override
- public void onScanStarted(boolean success) {
-// ToastUtil.show(NewBindDeviceActivity.this,"开始扫描");
- showDialog("正在搜索附近设备,请确保设备处于配网状态");
- }
-
- @SuppressLint("MissingPermission")
- @Override
- public void onScanning(BleDevice bleDevice) {
- if (bleDevice!=null && bleDevice.getDevice()!=null){
- BluetoothDevice bean = bleDevice.getDevice();
- if (!TextUtils.isEmpty(bean.getName()) && bean.getName().startsWith("ifish")){
- currentDevice = bleDevice;
-// tvname.setText(bean.getName()+bean.getAddress());
- BleManager.getInstance().cancelScan();
- }
- L.i(bean.getName()+"jjia---------"+bean.getAddress());
- }
- }
- });
- }
+//jjia-push
+// private void blueScan(){
+// BleManager.getInstance().scan(new BleScanCallback() {
+// @Override
+// public void onScanFinished(List scanResultList) {
+//
+// if (currentDevice!=null){
+// connectBle();
+// }else {
+// ToastUtil.show(NewBindDeviceActivity.this,"扫描结束,没有搜索到可用设备");
+// dismissDialog();
+// }
+// }
+//
+// @Override
+// public void onScanStarted(boolean success) {
+//// ToastUtil.show(NewBindDeviceActivity.this,"开始扫描");
+// showDialog("正在搜索附近设备,请确保设备处于配网状态");
+// }
+//
+// @SuppressLint("MissingPermission")
+// @Override
+// public void onScanning(BleDevice bleDevice) {
+// if (bleDevice!=null && bleDevice.getDevice()!=null){
+// BluetoothDevice bean = bleDevice.getDevice();
+// if (!TextUtils.isEmpty(bean.getName()) && bean.getName().startsWith("ifish")){
+// currentDevice = bleDevice;
+//// tvname.setText(bean.getName()+bean.getAddress());
+// BleManager.getInstance().cancelScan();
+// }
+// L.i(bean.getName()+"jjia---------"+bean.getAddress());
+// }
+// }
+// });
+// }
private boolean isJump = false;
- BleDevice currentDevice;
+ //jjia-push
+// BleDevice currentDevice;
/**
* 1.跳转设置页面连接ifish-xxx的wifi,连接成功后返回
*/
@@ -633,138 +636,142 @@ public class NewBindDeviceActivity extends AppCompatActivity {
}
}
}
+ //jjia-push
private String device_mac;
- private void openNotify(){
- BleManager.getInstance().notify(currentDevice, SERVICE_UUID, WRITE_UUID, new BleNotifyCallback() {
- @Override
- public void onNotifySuccess() {
- sendBleData();
- }
-
- @Override
- public void onNotifyFailure(BleException exception) {
-// dismissProgressDialogCancelble();
- dismissDialog();
- }
-
- @Override
- public void onCharacteristicChanged(byte[] data) {
-
- if (data!=null && data.length>0){
- int check_code = data[1];
- int length = data[14];
- byte[] dataByte = new byte[length];
- for (int i = 0; i < dataByte.length; i++) {
- dataByte[i] = data[i];
- }
-
- Object object = ModelCodec.deCode(dataByte,Commons.IoBuffer);
- if (object!=null && object instanceof BackFunctionCode7_11){
- BackFunctionCode7_11 model = (BackFunctionCode7_11) object;
- String status = ByteUtil.toHex(model.getStatus());
- device_mac = ByteUtil.bytesToHexString(model.getSrc());
-
-
- dismissDialog();
- if (!TextUtils.isEmpty(device_mac)){
- showDialog("正在绑定设备...");
- connectDevice.cancel();
- connectDevice.start();
- }
-// checkoutMac(device_mac);
- }
- L.i("jjia-------check_code-"+check_code);
- L.i("jjia-------length-"+length);
- L.i("jjia-------device_mac-"+device_mac);
- }
- }
- });
- }
+// private void openNotify(){
+// BleManager.getInstance().notify(currentDevice, SERVICE_UUID, WRITE_UUID, new BleNotifyCallback() {
+// @Override
+// public void onNotifySuccess() {
+// sendBleData();
+// }
+//
+// @Override
+// public void onNotifyFailure(BleException exception) {
+//// dismissProgressDialogCancelble();
+// dismissDialog();
+// }
+//
+// @Override
+// public void onCharacteristicChanged(byte[] data) {
+//
+// if (data!=null && data.length>0){
+// int check_code = data[1];
+// int length = data[14];
+// byte[] dataByte = new byte[length];
+// for (int i = 0; i < dataByte.length; i++) {
+// dataByte[i] = data[i];
+// }
+//
+// Object object = ModelCodec.deCode(dataByte,Commons.IoBuffer);
+// if (object!=null && object instanceof BackFunctionCode7_11){
+// BackFunctionCode7_11 model = (BackFunctionCode7_11) object;
+// String status = ByteUtil.toHex(model.getStatus());
+// device_mac = ByteUtil.bytesToHexString(model.getSrc());
+//
+//
+// dismissDialog();
+// if (!TextUtils.isEmpty(device_mac)){
+// showDialog("正在绑定设备...");
+// connectDevice.cancel();
+// connectDevice.start();
+// }
+//// checkoutMac(device_mac);
+// }
+// L.i("jjia-------check_code-"+check_code);
+// L.i("jjia-------length-"+length);
+// L.i("jjia-------device_mac-"+device_mac);
+// }
+// }
+// });
+// }
int devicePosition = 0;
- private void sendBleData(){
-
- String ssid = tvWifiName.getText().toString();
- String pwd = tvWifiPwd.getText().toString();
-
- OrderDeviceConnectModel model = OrderModel.OrderDeviceConnectModel(ssid, pwd,true);//设置正式环境域名
- byte[] data = ModelCodec.enCode(model, Commons.IoBuffer);
- BleManager.getInstance().write(currentDevice, SERVICE_UUID, WRITE_UUID, data,false, new BleWriteCallback() {
- @Override
- public void onWriteSuccess(int current, int total, byte[] justWrite) {
-
- L.i("jjia-------------ssid 发送");
- }
-
- @Override
- public void onWriteFailure(BleException exception) {
-
- }
- });
- }
- private void toReset(){
- ResetDeviceModel model = OrderModel.resetDevice();//设置正式环境域名
- byte[] data = ModelCodec.enCode(model);
-// data = new byte[1];
-
-// QueryTempeSettingModel xx = OrderModel.OrderQueryTempeSettingModel(device_mac);
-// byte[] data = ModelCodec.enCode(xx);
- BleManager.getInstance().write(currentDevice, SERVICE_UUID, WRITE_UUID, data,false, new BleWriteCallback() {
- @Override
- public void onWriteSuccess(int current, int total, byte[] justWrite) {
- L.i("jjia-------------重启 发送 成功-");
- }
-
- @Override
- public void onWriteFailure(BleException exception) {
- L.i("jjia-------------重启 发送 失败"+exception.toString());
- }
- });
- }
+ //jjia-push
+// private void sendBleData(){
+//
+// String ssid = tvWifiName.getText().toString();
+// String pwd = tvWifiPwd.getText().toString();
+//
+// OrderDeviceConnectModel model = OrderModel.OrderDeviceConnectModel(ssid, pwd,true);//设置正式环境域名
+// byte[] data = ModelCodec.enCode(model, Commons.IoBuffer);
+// BleManager.getInstance().write(currentDevice, SERVICE_UUID, WRITE_UUID, data,false, new BleWriteCallback() {
+// @Override
+// public void onWriteSuccess(int current, int total, byte[] justWrite) {
+//
+// L.i("jjia-------------ssid 发送");
+// }
+//
+// @Override
+// public void onWriteFailure(BleException exception) {
+//
+// }
+// });
+// }
+ //jjia-push
+// private void toReset(){
+// ResetDeviceModel model = OrderModel.resetDevice();//设置正式环境域名
+// byte[] data = ModelCodec.enCode(model);
+//// data = new byte[1];
+//
+//// QueryTempeSettingModel xx = OrderModel.OrderQueryTempeSettingModel(device_mac);
+//// byte[] data = ModelCodec.enCode(xx);
+// BleManager.getInstance().write(currentDevice, SERVICE_UUID, WRITE_UUID, data,false, new BleWriteCallback() {
+// @Override
+// public void onWriteSuccess(int current, int total, byte[] justWrite) {
+// L.i("jjia-------------重启 发送 成功-");
+// }
+//
+// @Override
+// public void onWriteFailure(BleException exception) {
+// L.i("jjia-------------重启 发送 失败"+exception.toString());
+// }
+// });
+// }
public static final String SERVICE_UUID = "000000ff-0000-1000-8000-00805f9b34fb"; //蓝牙通讯服务
public static final String READ_UUID = "0000ff01-0000-1000-8000-00805f9b34fb"; //读特征
public static final String WRITE_UUID = "0000ff01-0000-1000-8000-00805f9b34fb"; //写特征
- private void connectBle(){
- BleManager.getInstance().connect(currentDevice, new BleGattCallback() {
- @Override
- public void onStartConnect() {
- showDialog("开始连接蓝牙设备");
- }
-
- @Override
- public void onConnectFail(BleDevice bleDevice, BleException exception) {
- ToastUtil.show(NewBindDeviceActivity.this,"连接蓝牙设备失败,请重试");
- dismissDialog();
- }
-
- @Override
- public void onConnectSuccess(BleDevice bleDevice, BluetoothGatt gatt, int status) {
-// ToastUtil.show(NewBindDeviceActivity.this,"蓝牙连接成功");
-// setMessage("蓝牙连接成功");
- BleManager.getInstance().setMtu(bleDevice, 512, new BleMtuChangedCallback() {
- @Override
- public void onSetMTUFailure(BleException exception) {
- L.i("jjia-------MTU--"+exception.toString());
- dismissDialog();
- }
-
- @Override
- public void onMtuChanged(int mtu) {
- L.i("jjia-------MTU--"+mtu);
- openNotify();
- }
- });
- }
-
- @Override
- public void onDisConnected(boolean isActiveDisConnected, BleDevice device, BluetoothGatt gatt, int status) {
-// ToastUtil.show(NewBindDeviceActivity.this,"连接断开了");
- }
- });
- }
+ //jjia-push
+// private void connectBle(){
+// BleManager.getInstance().connect(currentDevice, new BleGattCallback() {
+// @Override
+// public void onStartConnect() {
+// showDialog("开始连接蓝牙设备");
+// }
+//
+// @Override
+// public void onConnectFail(BleDevice bleDevice, BleException exception) {
+// ToastUtil.show(NewBindDeviceActivity.this,"连接蓝牙设备失败,请重试");
+// dismissDialog();
+// }
+//
+// @Override
+// public void onConnectSuccess(BleDevice bleDevice, BluetoothGatt gatt, int status) {
+//// ToastUtil.show(NewBindDeviceActivity.this,"蓝牙连接成功");
+//// setMessage("蓝牙连接成功");
+// BleManager.getInstance().setMtu(bleDevice, 512, new BleMtuChangedCallback() {
+// @Override
+// public void onSetMTUFailure(BleException exception) {
+// L.i("jjia-------MTU--"+exception.toString());
+// dismissDialog();
+// }
+//
+// @Override
+// public void onMtuChanged(int mtu) {
+// L.i("jjia-------MTU--"+mtu);
+// openNotify();
+// }
+// });
+// }
+//
+// @Override
+// public void onDisConnected(boolean isActiveDisConnected, BleDevice device, BluetoothGatt gatt, int status) {
+//// ToastUtil.show(NewBindDeviceActivity.this,"连接断开了");
+// }
+// });
+// }
private Activity act;
private ConnectDevice connectDevice;
private boolean isContinue = true;
@@ -784,7 +791,8 @@ public class NewBindDeviceActivity extends AppCompatActivity {
@Override
public int compareTo(Boolean available) {
if (available) {
- toReset();
+ //jjia-push
+// toReset();
isContinue = false;
connectDevice.cancel();
L.i("jjia-----------调用绑定接口---");
@@ -1147,22 +1155,23 @@ public class NewBindDeviceActivity extends AppCompatActivity {
// myProgressDialogCancelble = null;
// }
// }
-
- List deviceList;
+ //jjia-push
+// List deviceList;
@SuppressLint("MissingPermission")
private void findConencted(){
- deviceList = BleManager.getInstance().getAllConnectedDevice();
- if (deviceList!=null && deviceList.size()>0){
- for (BleDevice item:deviceList){
- if (item!=null){
- L.i("jjia-----------"+item.getDevice().getName());
- }
- }
-
- }else {
- L.i("jjia--------没有连接的蓝牙---");
- }
+ //jjia-push
+// deviceList = BleManager.getInstance().getAllConnectedDevice();
+// if (deviceList!=null && deviceList.size()>0){
+// for (BleDevice item:deviceList){
+// if (item!=null){
+// L.i("jjia-----------"+item.getDevice().getName());
+// }
+// }
+//
+// }else {
+// L.i("jjia--------没有连接的蓝牙---");
+// }
}
@Override
diff --git a/iFish7/src/main/java/com/ifish/airkiss/UDPReceiver.java b/iFish7/src/main/java/com/ifish/airkiss/UDPReceiver.java
index 05ae13cff..3497da235 100644
--- a/iFish7/src/main/java/com/ifish/airkiss/UDPReceiver.java
+++ b/iFish7/src/main/java/com/ifish/airkiss/UDPReceiver.java
@@ -1,99 +1,99 @@
-package com.ifish.airkiss;
-
-import android.util.Log;
-
-import com.ifish.utils.WifiUtil;
-import com.lidroid.xutils.util.LogUtils;
-
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetSocketAddress;
-import java.net.SocketException;
-import java.nio.charset.StandardCharsets;
-
-/**
- * @author:zau18
- * @date: 2023/9/4 9:09 下午
- * @description:
- */
-// 创建一个接收器类
-public class UDPReceiver extends Thread {
- private static final int MAX_UDP_DATAGRAM_LEN = 15000;
- private DatagramSocket mSocket;
- private boolean mRunning;
- private UdpCallback resultBack;
- private WifiUtil wifiUtil;
-
- public UDPReceiver(WifiUtil wifiUtil,UdpCallback resultBack) {
- this.wifiUtil = wifiUtil;
- this.resultBack = resultBack;
- try {
- if(mSocket != null){
- mSocket.close();
- mSocket.disconnect();
- mSocket = null;
- }
- // 创建一个UDP套接字
- mSocket = new DatagramSocket(null);
- mSocket.bind(new InetSocketAddress(10000));
- mSocket.setSoTimeout(1000 * 60);
- } catch (SocketException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void run() {
- mRunning = true;
- byte[] buffer = new byte[MAX_UDP_DATAGRAM_LEN];
- DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
-
- while (mRunning) {
- try {
- LogUtils.d("LHD 开始接受");
- // 接收UDP数据包
- mSocket.receive(packet);
- String ip3 = WifiUtil.intToIp(wifiUtil.getConnectIpAddress());
- LogUtils.d("LHD 开始接受 = "+" ip3 = "+ip3);
-// Log.e("LHD test9999999990","收到的udp包 ip=" + packet.getAddress().getHostAddress()+" ip3 = "+ip3);
- // 处理接收到的数据
- if(!packet.getAddress().getHostAddress().equals(WifiUtil.intToIp(wifiUtil.getConnectIpAddress()))){
- String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8);
- String hexString = Str_Hex.byte2hex(packet.getData());
- handleData(hexString);
- }
- }catch (SocketException e) {
- LogUtils.d("LHD SocketException : " + e.getLocalizedMessage());
- handleErrorData(e.toString());
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- handleErrorData(e.toString());
- }
- }
- mSocket.close();
- }
-
- public void stopRunning() {
- mRunning = false;
- if(mSocket != null){
- mSocket.close();
- mSocket.disconnect();
- }
- }
-
- private void handleData(String data) {
- // 处理接收到的数据
- if(resultBack != null){
- resultBack.onReceive(data);
- }
- }
-
- private void handleErrorData(String data) {
- stopRunning();
- // 处理接收到的数据
- if(resultBack != null){
- resultBack.onError(data);
- }
- }
-}
+//package com.ifish.airkiss;
+//
+//import android.util.Log;
+//
+//import com.ifish.utils.WifiUtil;
+//import com.lidroid.xutils.util.LogUtils;
+//
+//import java.net.DatagramPacket;
+//import java.net.DatagramSocket;
+//import java.net.InetSocketAddress;
+//import java.net.SocketException;
+//import java.nio.charset.StandardCharsets;
+//
+///**
+// * @author:zau18
+// * @date: 2023/9/4 9:09 下午
+// * @description:
+// */
+//// 创建一个接收器类
+//public class UDPReceiver extends Thread {
+// private static final int MAX_UDP_DATAGRAM_LEN = 15000;
+// private DatagramSocket mSocket;
+// private boolean mRunning;
+// private UdpCallback resultBack;
+// private WifiUtil wifiUtil;
+//
+// public UDPReceiver(WifiUtil wifiUtil,UdpCallback resultBack) {
+// this.wifiUtil = wifiUtil;
+// this.resultBack = resultBack;
+// try {
+// if(mSocket != null){
+// mSocket.close();
+// mSocket.disconnect();
+// mSocket = null;
+// }
+// // 创建一个UDP套接字
+// mSocket = new DatagramSocket(null);
+// mSocket.bind(new InetSocketAddress(10000));
+// mSocket.setSoTimeout(1000 * 60);
+// } catch (SocketException e) {
+// e.printStackTrace();
+// }
+// }
+//
+// @Override
+// public void run() {
+// mRunning = true;
+// byte[] buffer = new byte[MAX_UDP_DATAGRAM_LEN];
+// DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
+//
+// while (mRunning) {
+// try {
+// LogUtils.d("LHD 开始接受");
+// // 接收UDP数据包
+// mSocket.receive(packet);
+// String ip3 = WifiUtil.intToIp(wifiUtil.getConnectIpAddress());
+// LogUtils.d("LHD 开始接受 = "+" ip3 = "+ip3);
+//// Log.e("LHD test9999999990","收到的udp包 ip=" + packet.getAddress().getHostAddress()+" ip3 = "+ip3);
+// // 处理接收到的数据
+// if(!packet.getAddress().getHostAddress().equals(WifiUtil.intToIp(wifiUtil.getConnectIpAddress()))){
+// String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8);
+// String hexString = Str_Hex.byte2hex(packet.getData());
+// handleData(hexString);
+// }
+// }catch (SocketException e) {
+// LogUtils.d("LHD SocketException : " + e.getLocalizedMessage());
+// handleErrorData(e.toString());
+// e.printStackTrace();
+// } catch (Exception e) {
+// e.printStackTrace();
+// handleErrorData(e.toString());
+// }
+// }
+// mSocket.close();
+// }
+//
+// public void stopRunning() {
+// mRunning = false;
+// if(mSocket != null){
+// mSocket.close();
+// mSocket.disconnect();
+// }
+// }
+//
+// private void handleData(String data) {
+// // 处理接收到的数据
+// if(resultBack != null){
+// resultBack.onReceive(data);
+// }
+// }
+//
+// private void handleErrorData(String data) {
+// stopRunning();
+// // 处理接收到的数据
+// if(resultBack != null){
+// resultBack.onError(data);
+// }
+// }
+//}
diff --git a/iFish7/src/main/java/com/ifish/baseclass/BaseApplication.java b/iFish7/src/main/java/com/ifish/baseclass/BaseApplication.java
index 07d172eee..185f55a34 100644
--- a/iFish7/src/main/java/com/ifish/baseclass/BaseApplication.java
+++ b/iFish7/src/main/java/com/ifish/baseclass/BaseApplication.java
@@ -31,8 +31,8 @@ import com.alibaba.sdk.android.push.PushControlService;
import com.alibaba.sdk.android.push.huawei.HuaWeiRegister;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.alibaba.sdk.android.push.register.MiPushRegister;
-import com.clj.fastble.BleManager;
-import com.clj.fastble.scan.BleScanRuleConfig;
+//import com.clj.fastble.BleManager;
+//import com.clj.fastble.scan.BleScanRuleConfig;
import com.ifish.activity.BuildConfig;
import com.ifish.basebean.EventBean;
import com.ifish.utils.ActivityManager;
@@ -100,18 +100,19 @@ public class BaseApplication extends MultiDexApplication {
//初始化MMKV
// KVUtil.init(this);
initPicasso();
-
- BleManager.getInstance().init(this);
+ //jjia-push
+// BleManager.getInstance().init(this);
UUID[] uuids = {UUID.fromString(SERVICE_UUID)};
- BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder()
- .setServiceUuids(uuids) // 只扫描指定的服务的设备,可选
-// .setDeviceName(true, names) // 只扫描指定广播名的设备,可选
-// .setDeviceMac(mac) // 只扫描指定mac的设备,可选
-// .setAutoConnect(isAutoConnect) // 连接时的autoConnect参数,可选,默认false
- .setScanTimeOut(30000) // 扫描超时时间30S,可选,默认10秒;小于等于0表示不限制扫描时间
- .build();
- BleManager.getInstance().initScanRule(scanRuleConfig);
+ //jjia-push
+// BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder()
+// .setServiceUuids(uuids) // 只扫描指定的服务的设备,可选
+//// .setDeviceName(true, names) // 只扫描指定广播名的设备,可选
+//// .setDeviceMac(mac) // 只扫描指定mac的设备,可选
+//// .setAutoConnect(isAutoConnect) // 连接时的autoConnect参数,可选,默认false
+// .setScanTimeOut(30000) // 扫描超时时间30S,可选,默认10秒;小于等于0表示不限制扫描时间
+// .build();
+// BleManager.getInstance().initScanRule(scanRuleConfig);
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
diff --git a/iFish7/src/main/java/com/ifish/fragment/DeviceFragment.java b/iFish7/src/main/java/com/ifish/fragment/DeviceFragment.java
index e5857515b..70c755ece 100644
--- a/iFish7/src/main/java/com/ifish/fragment/DeviceFragment.java
+++ b/iFish7/src/main/java/com/ifish/fragment/DeviceFragment.java
@@ -52,10 +52,11 @@ import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import com.bumptech.glide.Glide;
-import com.clj.fastble.BleManager;
-import com.clj.fastble.callback.BleScanCallback;
-import com.clj.fastble.data.BleDevice;
-import com.clj.fastble.data.BleScanState;
+//jjia-push
+//import com.clj.fastble.BleManager;
+//import com.clj.fastble.callback.BleScanCallback;
+//import com.clj.fastble.data.BleDevice;
+//import com.clj.fastble.data.BleScanState;
import com.ifish.activity.BindTwoDeviceActivity;
import com.ifish.activity.DeviceInstructionActivity;
import com.ifish.activity.InformationListActivity;
@@ -1867,41 +1868,42 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
}
firstResult = firstResult + HttpManager.PAGESIZE;
}
-
- private void initBooth(){
- boolean enable = BleManager.getInstance().isBlueEnable();
- if (enable) {
- BleManager.getInstance().scan(new BleScanCallback() {
- @Override
- public void onScanFinished(List scanResultList) {
- if (currentDevice!=null){ // 扫描结束,有设备
- L.i("jjjia-----------scan---");
- showDevice();
- }
- }
-
- @Override
- public void onScanStarted(boolean success) {
-
- }
-
- @SuppressLint("MissingPermission")
- @Override
- public void onScanning(BleDevice bleDevice) {
- if (bleDevice!=null && bleDevice.getDevice()!=null){
- BluetoothDevice bean = bleDevice.getDevice();
- if (!TextUtils.isEmpty(bean.getName()) && bean.getName().startsWith("ifish")){
- currentDevice = bleDevice;
- BleManager.getInstance().cancelScan();
- }
- L.i(bean.getName()+"jjia------mac---"+bean.getAddress());
- }
- }
- });
- }
-
- }
- BleDevice currentDevice;
+ //jjia-push
+// private void initBooth(){
+// boolean enable = BleManager.getInstance().isBlueEnable();
+// if (enable) {
+// BleManager.getInstance().scan(new BleScanCallback() {
+// @Override
+// public void onScanFinished(List scanResultList) {
+// if (currentDevice!=null){ // 扫描结束,有设备
+// L.i("jjjia-----------scan---");
+// showDevice();
+// }
+// }
+//
+// @Override
+// public void onScanStarted(boolean success) {
+//
+// }
+//
+// @SuppressLint("MissingPermission")
+// @Override
+// public void onScanning(BleDevice bleDevice) {
+// if (bleDevice!=null && bleDevice.getDevice()!=null){
+// BluetoothDevice bean = bleDevice.getDevice();
+// if (!TextUtils.isEmpty(bean.getName()) && bean.getName().startsWith("ifish")){
+// currentDevice = bleDevice;
+// BleManager.getInstance().cancelScan();
+// }
+// L.i(bean.getName()+"jjia------mac---"+bean.getAddress());
+// }
+// }
+// });
+// }
+//
+// }
+ //jjia-push
+// BleDevice currentDevice;
public void onEventMainThread(BluetoothDevice event) {
}
@@ -1976,7 +1978,8 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
intent.setClass(requireActivity(), NewBindDeviceActivity.class);
intent.putExtra("title", "连接水族箱");
intent.putExtra("type", "bluetooth");
- intent.putExtra("device", currentDevice);
+ //jjia-push
+// intent.putExtra("device", currentDevice);
startActivity(intent);
AnimationUtil.finishAnimation(requireActivity());
});
@@ -1995,21 +1998,22 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
@Override
public void onTick(long l) {
L.i("jjia-----dowmCount--"+dowmCount);
- if (dowmCount%6==0){
- BleScanState scanState = getScanState();
- L.i("jjia-----------timer--"+scanState);
- if (BleScanState.STATE_IDLE.equals(scanState)){
- if (isShowIng){
- L.i("jjia-----已经扫描到设备了,等待反馈-");
- closeDownTimer();
- }else {
- initBooth();
- L.i("jjia-----开始扫描-");
- }
- }else {
- L.i("jjia----timer--上一次的扫描还在继续中-");
- }
- }
+ //jjia-push
+// if (dowmCount%6==0){
+// BleScanState scanState = getScanState();
+// L.i("jjia-----------timer--"+scanState);
+// if (BleScanState.STATE_IDLE.equals(scanState)){
+// if (isShowIng){
+// L.i("jjia-----已经扫描到设备了,等待反馈-");
+// closeDownTimer();
+// }else {
+// initBooth();
+// L.i("jjia-----开始扫描-");
+// }
+// }else {
+// L.i("jjia----timer--上一次的扫描还在继续中-");
+// }
+// }
dowmCount++;
}
@@ -2032,10 +2036,10 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
countDownTimer = null;
}
}
-
- private BleScanState getScanState(){
- return BleManager.getInstance().getScanSate();
- }
+ //jjia-push
+// private BleScanState getScanState(){
+// return BleManager.getInstance().getScanSate();
+// }
@Override
public void onPause() {
@@ -2045,13 +2049,14 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
private void oonPause(){
closeDownTimer();
- BleScanState scanState = getScanState();
- if (BleScanState.STATE_SCANNING.equals(scanState)) {
- BleManager.getInstance().cancelScan();
- L.i("jjia---扫描暂停----------");
- } else {
-
- }
- L.i("jjia---扫描暂停-"+scanState);
+ //jjia-push
+// BleScanState scanState = getScanState();
+// if (BleScanState.STATE_SCANNING.equals(scanState)) {
+// BleManager.getInstance().cancelScan();
+// L.i("jjia---扫描暂停----------");
+// } else {
+//
+// }
+// L.i("jjia---扫描暂停-"+scanState);
}
}
diff --git a/iFish7/src/main/java/com/ifish/fragment/MineFragment.java b/iFish7/src/main/java/com/ifish/fragment/MineFragment.java
index ec6837700..d2b31b41d 100644
--- a/iFish7/src/main/java/com/ifish/fragment/MineFragment.java
+++ b/iFish7/src/main/java/com/ifish/fragment/MineFragment.java
@@ -33,7 +33,8 @@ import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
-import com.clj.fastble.BleManager;
+//jjia-push
+//import com.clj.fastble.BleManager;
import com.ifish.activity.AboutActivity;
import com.ifish.activity.BindTwoDeviceActivity;
import com.ifish.activity.CaptureActivity;