package baowen;
|
import java.math.BigInteger;
|
import frame.Index1;
|
import publicclass.GetNowTime;
|
public class Dell_55AA01 {
|
static String baotou;//°üÍ· 0x55AA
|
static String zhilingtype;//Ö¸ÁîÀàÐÍ0x01Õý³£Ä£Ê½£»0x02ÐÄÌø°ü
|
static String lenth;//Êý¾Ý³¤¶È17 1BYTE
|
static String xuhao;//ÐòºÅ 1BYTE
|
static String tagid;//±êÇ©id 2BYTE
|
static String anchorid;//»ùÕ¾id
|
static String distance10;//10½øÖƾàÀë
|
static String power;//µçÁ¿
|
static String button;//°´¼ü
|
static String baoliu;//±£Áô
|
static String distanceMessage;//ʵʱ¾àÀëÐÅÏ¢
|
static String zhiling01="01";//Ö¸ÁîÀàÐÍ01´ú±íÕý³£Ä£Ê½
|
static String zhiling02="02";//Ö¸ÁîÀàÐÍ02´ú±íÐÄÌø°ü
|
static String zhiling03="03";//Ö¸ÁîÀàÐÍ03´ú±í²ÎÊý¶Áдģʽ
|
static String zhiling="";
|
static String hexshow="";
|
static String sudu="";
|
static String baistart;//°×Ãûµ¥ÆðʼID
|
static String baistop;//°×Ãûµ¥ÖÕÖ¹ID
|
static String gujiantype;//¹Ì¼þÀàÐÍ
|
static int f4gj=0;//¹Ì¼þÀàÐÍ
|
static String tag_state;//±êÇ©¼¤»î״̬
|
static StringBuffer data=new StringBuffer();
|
|
|
static int info_lenth=0;
|
|
static boolean succpeizhi=false;
|
|
|
public static void dell55aa01_start(String message,String ip,int port) {
|
if(!message.startsWith("55AA01")) {
|
return;
|
}
|
message=message.replaceAll("\r\n|\r|\n", "");//È¡³öËùÓÐQÐкͻسµ
|
String[] aa0=message.split("55AA");
|
int size=aa0.length;
|
for(int i=0;i<size;i++) {
|
String info="55AA"+aa0[i];
|
dell55AA01(info,ip,port);
|
}
|
}
|
|
/**´¦Àí55AA01¿ªÍ·µÄ²â¾àÐÅÏ¢
|
* 55 AA 01 11 AF 01 00 05 00 10 02 00 00 64 00 00 00 00 00 C2 FE
|
*/
|
public static void dell55AA01(String infom,String ip,int port) {
|
int timestamp=GetNowTime.timestamp();
|
String intime=GetNowTime.timestamp2();
|
int lenth1=infom.length()/2;
|
if(lenth1>10) {
|
int size=lenth1;
|
//½«ÐÅÏ¢2¸ö×Ö·û1λ±£´æÔÚÊý×éÖÐ
|
String[] hex=new String[size];
|
for(int i=0;i<size;i++) {
|
hex[i]=infom.substring(i*2, 2+i*2);
|
}
|
//Ö¸ÁîÀàÐÍ
|
zhilingtype=hex[2];
|
if(!zhilingtype.equals("01")) {
|
return;
|
}
|
//Êý¾Ý³¤¶È
|
int datalen=decodeHEX(hex[3])+4;
|
lenth= String.valueOf(decodeHEX(hex[3]));
|
if(datalen==lenth1) {
|
//°üÐò
|
xuhao=String.valueOf(decodeHEX(hex[4]));
|
//Ä£¿éID tagid
|
tagid=hex[6]+hex[5];
|
//Ä£¿éID anchorid
|
anchorid=hex[8]+hex[7];
|
/**²â¾à¾àÀë*/
|
int dis=decodeHEX(hex[12]+hex[11]+hex[10]+hex[9]);
|
distance10=String.valueOf(dis);
|
|
/**µçÁ¿*/
|
power=String.valueOf(decodeHEX(hex[13]));
|
|
/**°´¼ü*/
|
button=String.valueOf(decodeHEX(hex[14]));
|
|
/**±£Áôλ*/
|
baoliu=String.valueOf(decodeHEX(hex[15]));
|
showdata();
|
}else {
|
Dell_uanshi_byt.intsert(ip,infom,intime, timestamp,port);
|
}
|
hex=null;
|
}else {
|
Dell_uanshi_byt.intsert(ip,infom,intime, timestamp,port);
|
}
|
|
|
}
|
|
|
/**±¨ÎÄÏÔʾµ÷ÓÃ*/
|
public static void showdata() {
|
if(Index1.getTagid().equals("ÔʼÊý¾Ý")) {
|
return;
|
}
|
if(Index1.isShoware()) {
|
data.append("ID:"+tagid+",");
|
data.append("°üÐò:"+xuhao+",");
|
data.append("µçÁ¿:"+power+",");
|
data.append("񅧏:"+anchorid+",");
|
data.append("¾àÀë:"+distance10);
|
String as=data.toString();
|
if(Index1.getTagid().equals("0")) {
|
Index1.ara_show(as);
|
}else {
|
if(Index1.getTagid().equals(tagid)) {
|
Index1.ara_show(as);
|
}
|
}
|
data.setLength(0);
|
}
|
|
}
|
|
public static String get_realldistance() {
|
return distanceMessage;
|
}
|
|
/**16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int decodeHEX(String hexs){
|
BigInteger bigint=new BigInteger(hexs, 16);
|
int numb=bigint.intValue();
|
return numb;
|
|
}
|
|
/**32½øÖÆ×ªÎª10½øÖÆ*/
|
public static String change32To10(String num) {
|
int f=32;
|
int t=10;
|
return new java.math.BigInteger(num, f).toString(t);
|
}
|
|
|
/**
|
* ½«byte[]תΪ¸÷ÖÖ½øÖƵÄ×Ö·û´®
|
* @param bytes byte[]
|
* @param radix »ùÊý¿ÉÒÔת»»½øÖƵķ¶Î§£¬´ÓCharacter.MIN_RADIXµ½Character.MAX_RADIX£¬³¬³ö·¶Î§ºó±äΪ10½øÖÆ
|
* @return ת»»ºóµÄ×Ö·û´®
|
*/
|
public static String binary(byte[] bytes, int radix){
|
return new BigInteger(1, bytes).toString(radix);// ÕâÀïµÄ1´ú±íÕýÊý
|
}
|
|
|
private static final char[] HEXES = {
|
'0', '1', '2', '3',
|
'4', '5', '6', '7',
|
'8', '9', 'a', 'b',
|
'c', 'd', 'e', 'f'
|
};
|
|
/**
|
* byteÊý×é ת»»³É 16½øÖÆÐ¡Ð´×Ö·û´®
|
*/
|
public static String bytes2Hex(byte[] bytes) {
|
if (bytes == null || bytes.length == 0) {
|
return null;
|
}
|
|
StringBuilder hex = new StringBuilder();
|
|
for (byte b : bytes) {
|
hex.append(HEXES[(b >> 4) & 0x0F]);
|
hex.append(HEXES[b & 0x0F]);
|
}
|
|
return hex.toString();
|
}
|
|
|
|
|
|
/**½ØÈ¡Ö¸¶¨³¤¶ÈµÄBYTEÊý×é
|
* @param srcÔ×Ö½ÚÊý×é
|
* @param ¿ªÊ¼Î»ÖÃ
|
* @param ½ØÈ¡³¤¶È*/
|
public static byte[] subBytes(byte[] src, int begin, int count) {
|
byte[] bs = new byte[count];
|
System.arraycopy(src, begin, bs, 0, count);
|
return bs;
|
}
|
|
|
public static String[] hex(String message) {
|
int size=message.length()/2;
|
String[] hex=new String[size];
|
for(int i=0;i<size;i++) {
|
hex[i]=message.substring(i*2, 2+i*2);
|
}
|
|
return hex;
|
}
|
|
}
|