配网长度提醒
This commit is contained in:
parent
59625c2e9f
commit
a65d5e8ac5
|
|
@ -26,5 +26,5 @@ android.enableJetifier=true
|
|||
android.useAndroidX=true
|
||||
android.useDeprecatedNdk=true
|
||||
|
||||
versionCode=56
|
||||
versionName=4.11.16
|
||||
versionCode=57
|
||||
versionName=4.11.17
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
package com.ifish.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.ifish.baseclass.BaseActivity;
|
||||
import com.ifish.tcp.BackFunctionCode7_11;
|
||||
import com.ifish.tcp.Context;
|
||||
import com.ifish.tcp.ModelCodec;
|
||||
import com.ifish.tcp.OrderModel;
|
||||
import com.ifish.tcp.ResetDeviceModel;
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ public class NewBindDeviceActivity extends AppCompatActivity {
|
|||
dataByte[i] = data[i];
|
||||
}
|
||||
|
||||
Object object = ModelCodec.deCode(dataByte);
|
||||
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());
|
||||
|
|
@ -644,7 +644,7 @@ public class NewBindDeviceActivity extends AppCompatActivity {
|
|||
String pwd = tvWifiPwd.getText().toString();
|
||||
|
||||
OrderDeviceConnectModel model = OrderModel.OrderDeviceConnectModel(ssid, pwd,true);//设置正式环境域名
|
||||
byte[] data = ModelCodec.enCode(model);
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
package com.ifish.tcp;
|
||||
|
||||
import com.ifish.utils.Commons;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
public class Context {
|
||||
private final CharsetDecoder decoder;
|
||||
private IoBuffer buf;
|
||||
private int matchCount = 0;
|
||||
private int overflowPosition = 0;
|
||||
|
||||
public Context(Charset charset) {
|
||||
decoder = charset.newDecoder();
|
||||
buf = IoBuffer.allocate(Commons.IoBuffer).setAutoExpand(true);
|
||||
//buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
public CharsetDecoder getDecoder() {
|
||||
return decoder;
|
||||
}
|
||||
|
||||
public IoBuffer getBuffer() {
|
||||
return buf;
|
||||
}
|
||||
|
||||
public int getOverflowPosition() {
|
||||
return overflowPosition;
|
||||
}
|
||||
|
||||
public int getMatchCount() {
|
||||
return matchCount;
|
||||
}
|
||||
|
||||
public void setMatchCount(int matchCount) {
|
||||
this.matchCount = matchCount;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
overflowPosition = 0;
|
||||
matchCount = 0;
|
||||
decoder.reset();
|
||||
}
|
||||
|
||||
public void append(IoBuffer in) {
|
||||
getBuffer().put(in);
|
||||
}
|
||||
}
|
||||
//package com.ifish.tcp;
|
||||
//
|
||||
//import com.ifish.utils.Commons;
|
||||
//
|
||||
//import java.nio.charset.Charset;
|
||||
//import java.nio.charset.CharsetDecoder;
|
||||
//
|
||||
//import org.apache.mina.core.buffer.IoBuffer;
|
||||
//
|
||||
//public class Context {
|
||||
// private final CharsetDecoder decoder;
|
||||
// private IoBuffer buf;
|
||||
// private int matchCount = 0;
|
||||
// private int overflowPosition = 0;
|
||||
//
|
||||
// public Context(Charset charset) {
|
||||
// decoder = charset.newDecoder();
|
||||
// buf = IoBuffer.allocate(Commons.IoBuffer).setAutoExpand(true);
|
||||
// //buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// }
|
||||
//
|
||||
// public CharsetDecoder getDecoder() {
|
||||
// return decoder;
|
||||
// }
|
||||
//
|
||||
// public IoBuffer getBuffer() {
|
||||
// return buf;
|
||||
// }
|
||||
//
|
||||
// public int getOverflowPosition() {
|
||||
// return overflowPosition;
|
||||
// }
|
||||
//
|
||||
// public int getMatchCount() {
|
||||
// return matchCount;
|
||||
// }
|
||||
//
|
||||
// public void setMatchCount(int matchCount) {
|
||||
// this.matchCount = matchCount;
|
||||
// }
|
||||
//
|
||||
// public void reset() {
|
||||
// overflowPosition = 0;
|
||||
// matchCount = 0;
|
||||
// decoder.reset();
|
||||
// }
|
||||
//
|
||||
// public void append(IoBuffer in) {
|
||||
// getBuffer().put(in);
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ public class ModelCodec {
|
|||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static byte[] enCode(Object obj) {
|
||||
IoBuffer buffer = IoBuffer.allocate(Commons.IoBuffer).setAutoExpand(true);
|
||||
public static byte[] enCode(Object obj){
|
||||
return enCode(obj,100);
|
||||
}
|
||||
|
||||
public static byte[] enCode(Object obj,int len) {
|
||||
IoBuffer buffer = IoBuffer.allocate(len).setAutoExpand(true);
|
||||
|
||||
if(obj instanceof BackInfoSix_4F_XunHuanTimes){ //设置循环模式时间
|
||||
BackInfoSix_4F_XunHuanTimes model = (BackInfoSix_4F_XunHuanTimes) obj;
|
||||
|
|
@ -426,10 +430,13 @@ public class ModelCodec {
|
|||
* 把字节数组转成对象
|
||||
*/
|
||||
public static Object deCode(byte[] bys) {
|
||||
return deCode(bys,100);
|
||||
}
|
||||
public static Object deCode(byte[] bys,int len) {
|
||||
int Check_code = getCheck_code(bys);
|
||||
int length = bys.length;
|
||||
Log.i("---------start", Check_code + "---" + ByteUtil.bytesToHexString(bys));
|
||||
IoBuffer buf = ByteUtil.byteToIoBuffer(bys, length);
|
||||
IoBuffer buf = ByteUtil.byteToIoBuffer(bys, length,len);
|
||||
if (Check_code == 21) {
|
||||
return decodexuanduo_set(buf);
|
||||
} else if (Check_code == 22) {
|
||||
|
|
|
|||
|
|
@ -15,15 +15,18 @@ import java.io.Serializable;
|
|||
* @Description: 设备设置tcp域名命令39字节(17字节+22字节)
|
||||
*/
|
||||
public class OrderDeviceConnectModel extends HeadModel implements Serializable {
|
||||
private boolean isNew = false;
|
||||
|
||||
public OrderDeviceConnectModel(boolean x){
|
||||
this.isNew = x;
|
||||
}
|
||||
//路由器wifi名
|
||||
private byte[] ssid_name = new byte[ isNew ?Commons.SSID_LENGTH:20];
|
||||
private byte[] ssid_name;
|
||||
//路由器wifi密码
|
||||
private byte[] ssid_password = new byte[isNew?Commons.SSID_LENGTH:20];
|
||||
private byte[] ssid_password;
|
||||
public OrderDeviceConnectModel(boolean isNew){
|
||||
ssid_name = new byte[ isNew ?Commons.SSID_LENGTH:20];
|
||||
ssid_password = new byte[isNew?Commons.SSID_LENGTH:20];
|
||||
}
|
||||
|
||||
// private byte[] ssid_name = new byte[ isNew ?Commons.SSID_LENGTH:20];
|
||||
// //路由器wifi密码
|
||||
// private byte[]
|
||||
|
||||
public byte[] getSsid_name() {
|
||||
return ssid_name;
|
||||
|
|
|
|||
|
|
@ -71,11 +71,20 @@ public class ByteUtil{
|
|||
* 将byte[]转换成IoBuffer
|
||||
* @param str
|
||||
*/
|
||||
public static IoBuffer byteToIoBuffer(byte [] bt,int length){
|
||||
IoBuffer ioBuffer = IoBuffer.allocate(Commons.IoBuffer).setAutoExpand(true);
|
||||
public static IoBuffer byteToIoBuffer(byte [] bt,int length){
|
||||
// IoBuffer ioBuffer = IoBuffer.allocate(Commons.IoBuffer).setAutoExpand(true);
|
||||
// //ioBuffer.order(ByteOrder.LITTLE_ENDIAN);// 修改此缓冲区的字节顺大端模式
|
||||
// ioBuffer.put(bt, 0, length);
|
||||
// ioBuffer.flip();
|
||||
// return ioBuffer;
|
||||
return byteToIoBuffer(bt,length,100);
|
||||
}
|
||||
|
||||
public static IoBuffer byteToIoBuffer(byte [] bt,int length,int xx){
|
||||
IoBuffer ioBuffer = IoBuffer.allocate(xx).setAutoExpand(true);
|
||||
//ioBuffer.order(ByteOrder.LITTLE_ENDIAN);// 修改此缓冲区的字节顺大端模式
|
||||
ioBuffer.put(bt, 0, length);
|
||||
ioBuffer.flip();
|
||||
ioBuffer.put(bt, 0, length);
|
||||
ioBuffer.flip();
|
||||
return ioBuffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue