@@ -0,0 +1,1763 @@
+/*%0D%0A * To change this license header, choose License Headers in Project Properties.%0D%0A * To change this template file, choose Tools %7C Templates%0D%0A * and open the template in the editor.%0D%0A */%0D%0Apackage ts.mqttsn;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author loki.chuang%0D%0A */%0D%0Apublic class MqttSnPackage%0D%0A%7B%0D%0A    public enum PackageTyep%0D%0A    %7B   %0D%0A        NOTIMPLIMENT,%0D%0A        PUBLISH,%0D%0A        SUBSCRIBE%0D%0A    %7D%0D%0A    %0D%0A    public class ParseFailedException extends Exception%0D%0A    %7B%0D%0A        public ParseFailedException(String message)%0D%0A        %7B%0D%0A            super(message);%0D%0A        %7D%0D%0A    %7D%0D%0A    %0D%0A    public int length=0;%0D%0A    public PackageTyep packageType=PackageTyep.NOTIMPLIMENT;%0D%0A    public int topicId;%0D%0A    public byte%5B%5D payload=new byte%5B0%5D;%0D%0A    %0D%0A    public void parsePackage(byte%5B%5D dataArray) throws ParseFailedException%0D%0A    %7B%0D%0A        int len=dataArray%5B0%5D;        %0D%0A        if(dataArray.length!=len)%0D%0A        %7B            %0D%0A            throw new ParseFailedException(%22Data length field not equal to received data length%22);%0D%0A        %7D%0D%0A        %0D%0A        %0D%0A        PackageTyep type=PackageTyep.NOTIMPLIMENT;%0D%0A        switch (dataArray%5B1%5D)%0D%0A        %7B%0D%0A            case 0x10:%0D%0A                type=PackageTyep.PUBLISH;%0D%0A                break;%0D%0A            case 0x12:%0D%0A                type=PackageTyep.SUBSCRIBE;%0D%0A                break;%0D%0A            default:%0D%0A                throw new ParseFailedException(%22The mqtt message type not impliment yet%22);                %0D%0A        %7D%0D%0A        %0D%0A        this.length=len;%0D%0A        this.packageType=type;%0D%0A        this.topicId=dataArray%5B2%5D;%0D%0A        this.payload=new byte%5Blen-3%5D;%0D%0A        %0D%0A        for(int i=0;i%3Clen-3;i++)%0D%0A        %7B%0D%0A            this.payload%5Bi%5D=dataArray%5Bi+3%5D;%0D%0A        %7D        %0D%0A        %0D%0A    %7D%0D%0A    %0D%0A    %0D%0A    %0D%0A%7D%0D%0A

Work for XBeeAtClient 80%