private void processGetFileInfoCmd(DataInputStream params, IOTACommandHelper helper) throws IOException { String filename = params.readUTF(); FlashFile flashFile = new FlashFile(filename); if (flashFile.exists()) { helper.getDataOutputStream().writeBoolean(true); byte[] fileData = new OTAFlashFileInfo(flashFile).toByteArray(); helper.sendData(fileData, 0, fileData.length); } else { helper.getDataOutputStream().writeBoolean(false); } helper.sendPrompt(); }
private void processGetConfigPageCmd(IOTACommandHelper helper, boolean len) throws IOException { ConfigPage configPage; configPage = spot.getConfigPage(); byte[] data = configPage.asByteArray(); if (len) { int i = data.length - 1; while (i > 0 && data[i] == 0) i--; i = i / 4; helper.getDataOutputStream().writeByte(i & 0xff); helper.getDataOutputStream().write(data, 0, (i + 1) * 4); } else { helper.getDataOutputStream().write(data); } helper.sendPrompt(); }
private void processGetFileListCmd(DataInputStream params, IOTACommandHelper helper) throws IOException { IFAT fat = FlashFile.getFAT(); IFlashFileInfo[] fileInfos = fat.getFileInfos(); DataOutputStream dos = helper.getDataOutputStream(); dos.writeInt(fileInfos.length); for (int i = 0; i < fileInfos.length; i++) { dos.writeUTF(fileInfos[i].getName()); } int[] freeSectorIndices = fat.getFreeSectorIndices(); dos.writeInt(freeSectorIndices.length); for (int i = 0; i < freeSectorIndices.length; i++) { dos.writeInt(freeSectorIndices[i]); } helper.sendPrompt(); }
private void processResyncCmd(IOTACommandHelper helper) throws IOException { sendUTF(helper.getDataOutputStream(), helper.getBootloaderIdentificationString()); }