Beispiel #1
0
  private void processSetSystemPropertiesCmd(DataInputStream params, IOTACommandHelper helper)
      throws IOException {
    int dataSize = helper.getDataInputStream().readInt();
    ByteArrayOutputStream baos = new ByteArrayOutputStream(dataSize);
    helper.receiveFile(dataSize, baos);
    Properties newPersistentProperties = new Properties();
    newPersistentProperties.load(new ByteArrayInputStream(baos.toByteArray()));

    Properties oldPersistentProperties = spot.getPersistentProperties();

    // store new properties in flash
    spot.storeProperties(newPersistentProperties);

    // remove deleted properties from current isolate
    Enumeration oldKeys = oldPersistentProperties.keys();
    while (oldKeys.hasMoreElements()) {
      String oldKey = (String) oldKeys.nextElement();
      if (!newPersistentProperties.containsKey(oldKey)) {
        VM.setProperty(oldKey, null);
      }
    }

    // store new and modified properties in current isolate
    Enumeration newKeys = newPersistentProperties.keys();
    while (newKeys.hasMoreElements()) {
      String newKey = (String) newKeys.nextElement();
      VM.setProperty(newKey, newPersistentProperties.getProperty(newKey));
    }

    helper.sendPrompt();
  }
Beispiel #2
0
 private void processSetStartupCmd(DataInputStream params, IOTACommandHelper helper)
     throws IOException {
   ConfigPage configPage = spot.getConfigPage();
   configPage.setStartup(params.readUTF(), params.readUTF(), params.readUTF());
   spot.flashConfigPage(configPage);
   helper.sendPrompt();
 }
Beispiel #3
0
 private void processGetSystemPropertiesCmd(IOTACommandHelper helper) throws IOException {
   Properties p = spot.getPersistentProperties();
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   p.store(baos, "System properties on SPOT");
   helper.sendData(baos.toByteArray(), 0, baos.size());
   helper.sendPrompt();
 }
Beispiel #4
0
 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();
 }
Beispiel #5
0
 private void setPublicKey(byte[] newKey) {
   ConfigPage configPage = spot.getConfigPage();
   configPage.setPublicKey(newKey);
   spot.flashConfigPage(configPage);
 }