Exemplo n.º 1
0
  /**
   * Called when a physical channel is opened
   *
   * <p>When this method is called the derived class must have created a valid inStream and
   * outStream
   */
  boolean attemptSucceeded() {
    // Create a new object manager and register all objects
    // in the future the particular register method should
    // be dependent on what is connected (e.g. board and
    // version number).
    objMngr = new UAVObjectManager();
    TelemObjectsInitialize.register(objMngr);

    // Register to get an update from FirmwareIAP in order to register
    // the appropriate objects
    UAVObject obj = objMngr.getObject("FirmwareIAPObj");
    obj.addUpdatedObserver(firmwareIapUpdated);

    // Create the required telemetry objects attached to this
    // data stream
    uavTalk = new UAVTalk(inStream, outStream, objMngr);
    tel = new Telemetry(uavTalk, objMngr, Looper.myLooper());
    mon = new TelemetryMonitor(objMngr, tel, telemService);

    // Create an observer to notify system of connection
    mon.addObserver(connectionObserver);

    // Create a new thread that processes the input bytes
    startInputProcessing();

    connected = true;
    return connected;
  }
Exemplo n.º 2
0
        @Override
        public void update(Observable observable, Object data) {
          if (DEBUG) Log.d(TAG, "Received firmware IAP Updated message");

          UAVObject obj = objMngr.getObject("FirmwareIAPObj");
          UAVObjectField description = obj.getField("Description");
          if (description == null || description.getNumElements() < 100) {
            telemService.toastMessage("Failed to determine UAVO set");
          } else {
            final int HASH_SIZE_USED = 8;
            String jarName = new String();
            for (int i = 0; i < HASH_SIZE_USED; i++)
              jarName += Integer.toHexString((int) description.getDouble(i + 60));
            jarName += ".jar";
            if (DEBUG) Log.d(TAG, "Attempting to load: " + jarName);
            if (telemService.loadUavobjects(jarName, objMngr)) {
              telemService.toastMessage("Loaded appropriate UAVO set");
            } else telemService.toastMessage("Failed to determine UAVO set");
          }

          obj.removeUpdatedObserver(this);
        }