private byte[] criaPacoteDados(byte checkSumCabecalho, Digital digital) { byte[] requisicao = new byte[] { 0x01, 0x20, 0x03 }; // bytes fixos String dedoAux = digital.template1.Substring(6); // desconsidera os 3 primeiros bytes (fixados acima) dedoAux += digital.template2; requisicao = ProtocolUtils.merge(requisicao, Conversor.hexStringToByteArray(dedoAux)); byte checksum = ProtocolUtils.getChecksum(ProtocolUtils.merge(requisicao, new byte[] { checkSumCabecalho, Convert.ToByte(CommandCodes.END) })); requisicao = ProtocolUtils.merge(requisicao, new byte[] { checksum }); return(requisicao); }
private byte[] criaPacoteDados(byte checkSumCabecalho, byte[] cpf, Company company) { byte tipoId; byte[] identificador; tipoId = 0x01; identificador = Conversor.cnpjToByte(Conversor.SomenteNumeros(Conversor.SomenteNumeros(company.cnpj))); // Campo Identificador 6 bytes byte[] requisicao = { tipoId }; // Campo Tipo de Identificador 1 byte byte[] cei = Conversor.ceiToByte(Conversor.SomenteNumeros(company.cei)); // Campo CEI 5 bytes byte[] razaoSocial = Conversor.stringToByteArray(company.companyName, 150); // Campo Razão Social 150 bytes byte[] localPrestServ = Conversor.stringToByteArray(company.address + " " + company.city, 100); // Campo Local 100 bytes requisicao = ProtocolUtils.merge(requisicao, identificador, cei, razaoSocial, localPrestServ, cpf); byte checksum = ProtocolUtils.getChecksum(ProtocolUtils.merge(requisicao, new byte[] { checkSumCabecalho, Convert.ToByte(CommandCodes.END) })); requisicao = ProtocolUtils.merge(requisicao, new byte[] { checksum }); return(requisicao); }