write method

void write({
  1. required List<int> data,
  2. required HBleDeviceServicesCharacteristics writeCharacteristic,
  3. required bool withResponse,
})

Implementation

void write({required List<int> data,required HBleDeviceServicesCharacteristics writeCharacteristic,required bool withResponse,}){
  this.writeCharacteristic = writeCharacteristic;

  if((nowTimeMilliSecond() - lastWriteTime) > HBle.onePageSentMainTime){
    willWriteList = [];
    isWriting = false;//发送超时
  }
  if(isWriting){
    willWriteList.add(data);
  }else{
    //int sendTime1 = HTool.nowTimeMilliSecond();
    //debugPrint("send 1 ${HTool.nowTimeMilliSecond()}");
    isWriting = true;
    willWriteList.add(data);
    writeTheWillWriteList(whenComplete:(){
      isWriting = false;
      // debugPrint("sendTime  ${HTool.nowTimeMilliSecond() - sendTime1}");
    },withResponse:withResponse);
  }
}