/**
   * Sends a full dictionary with updated information when called. If no pebble is present, the
   * watchapp isn't installed, or the watchapp isn't running, nothing will happen.
   *
   * @param drone
   */
  public void sendDataToWatchNow(Drone drone) {
    Follow followMe = ((DroidPlannerApp) applicationContext).followMe;
    PebbleDictionary data = new PebbleDictionary();

    String mode = drone.state.getMode().getName();
    if (!drone.state.isArmed()) mode = "Disarmd";
    else if (((DroidPlannerApp) applicationContext).followMe.isEnabled() && mode == "Guided")
      mode = "Follow";
    data.addString(KEY_MODE, mode);

    FollowModes type = followMe.getType();
    if (type != null) {
      data.addString(KEY_FOLLOW_TYPE, type.toString());
    } else data.addString(KEY_FOLLOW_TYPE, "none");

    String bat = "Bat:" + Double.toString(roundToOneDecimal(drone.battery.getBattVolt())) + "V";
    String speed = "Speed: " + Double.toString(roundToOneDecimal(drone.speed.getAirSpeed()));
    String altitude = "Alt: " + Double.toString(roundToOneDecimal(drone.altitude.getAltitude()));
    String telem = bat + "\n" + altitude + "\n" + speed;
    data.addString(KEY_TELEM, telem);

    data.addString(KEY_APP_VERSION, EXPECTED_APP_VERSION);

    PebbleKit.sendDataToPebble(applicationContext, DP_UUID, data);
  }
  public void sendWeatherDataToWatch(int weatherIconId, String temp) {
    // Build up a Pebble dictionary containing the weather icon and the current temperature in
    // degrees fahrenheit
    PebbleDictionary data = new PebbleDictionary();
    data.addUint8(ICON_KEY, (byte) weatherIconId);
    data.addString(TEMP_KEY, temp);

    // Send the assembled dictionary to the weather watch-app; this is a no-op if the app isn't
    // running or is not
    // installed
    PebbleKit.sendDataToPebble(caller.getApplicationContext(), WEATHER_UUID, data);
  }
Beispiel #3
0
  /**
   * Sends an event to the app, and tells whether it's been added or removed
   *
   * @param e
   * @param added
   */
  public void sendEvent(Event e, boolean added) {
    byte b_false = 0;
    byte b_true = 1;
    PebbleDictionary data = new PebbleDictionary();
    //		data.addInt32(0,e.hashCode); //The batch number of this transaction
    data.addInt8(1, added ? b_true : b_false); // I have no idea what I'm doing
    data.addInt32(2, e.startDay);
    data.addInt32(3, e.endDay);
    data.addInt32(4, e.startTime);
    data.addInt32(5, e.endTime);
    data.addString(6, e.title);
    pending_events.put(COUNTER, data);
    Log.i(MainActivity.TAG, "start time:" + e.startTime);
    Log.i(MainActivity.TAG, "start day:" + e.startDay);

    pending_events.put(COUNTER, data);
    PebbleKit.sendDataToPebbleWithTransactionId(
        ctx, PEBBLE_APP_UUID, data, COUNTER); // counter is also transaction ID
    COUNTER++;
  }