• I assume you have sent these one by one manually.

    No, after one first message is pushed, when response is captured, I check if it is ACK class. If it is, I call pushing of second message, and so on, until the buffer's end is reached.

    var EPO=new DataView(
      require("Storage").readArrayBuffer("ble_­epo_offline.bin"));
    var i=0, h1=0, h2=0, len=0, cs=0, p=0, pe=0,s="";
    function pushNextAGPSMessage(){
      while(i<EPO.byteLength){
      h1=EPO.getUint8(i);
      h2=EPO.getUint8(i+1);
      if(h1==0xBA && h2==0xCE){
        s="";
        len=EPO.getUint16(i+2,true)+10;
        p=i; pe=p+len;
        print("push ",h1,h2, p, len);
        while(p<pe){
          s+=",0x"+EPO.buffer[p].toString(16);
          Serial2.write(EPO.buffer[p]);
          p++;
        }
        print(s);
        print(prsMsgGPSEph({payload:EPO.buffer},­i+6));
        i=p;
        return;
      }else{i++;}
      }
    }
    
    D29.write(0);
    Serial2.removeAllListeners();
    Serial2.setup(9600,{rx:D30,tx:D31});
    Serial2.removeAllListeners();
    var msg;
    Serial2.on('data', function(data){
    //print(data);
      msg=parseCASIC(data);
      if(i<EPO.byteLength && typeof msg != 'undefined' && msg.class==0x05){ 
        msg=undefined;
        while(Serial2.available()>0)print('A');
        pushNextAGPSMessage();
      }
    });
    
    D29.write(1);
    
    Serial2.println("$PCAS03,0,0,0,0,0,0,0,0­,0,,0,,,0*32");
    
    i=0;
    pushNextAGPSMessage();
    

    this code is very experimental. And parseCASIC(data) is not here. it is part of CASIC module I am working on.

About

Avatar for Mark_M @Mark_M started