Vasu
Vasu

Reputation: 1110

Pebble Communication Issues [AppSync/AppMessage]

I'm currently attempting to use AppSync to sync a piece of data between an android app and a pebble app. However, I seem to not be able to get the pebble to realize that any data is being transferred - that is, no logs are being produced where they should be. What is really bothering me is that this is essentially the code found in the pebble weather example. I've pasted the relevant bits of code below - could someone possibly look it over and suggest where any issues may be? I've made sure that the UUIDs in both programs (pebble app and android app) are the same, and that they are on the same network, and that the pebble is actually connected to the phone, and that the android function is actually being called and all.

Snippet of pebble app code:

static void sync_error_callback(DictionaryResult dict_error, AppMessageResult app_message_error, void *context) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "App Message Sync Error: %d", app_message_error);
}

static void sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, new_tuple->value->cstring);
}

void home_screen_load() {
    // set up each one of the SimpleMenuItems
    Tuplet initial_values[] = {
        TupletCString(0x0, "Initial 1")
    };

    app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL);
}

Snippet of android app:

    final UUID PEBBLE_APP_UUID = UUID.fromString("10549fd4-1fe4-4d30-8a18-6f2f8149f8fd");

public void sendDataToWatch(String toSend) {
    // Build up a Pebble dictionary containing the weather icon and the current temperature in degrees celsius
    PebbleDictionary data = new PebbleDictionary();
    data.addString(0x0, toSend);
    PebbleKit.sendDataToPebble(getApplicationContext(), PEBBLE_APP_UUID, data);
}

Upvotes: 0

Views: 407

Answers (1)

sarfata
sarfata

Reputation: 4675

To debug this type of problem, you should set a inbox_dropped handler and see if you get anything there.

After initializing AppMessage and AppSync, call:

app_message_register_inbox_dropped(appmsg_in_dropped);

And add this function:

static void appmsg_in_dropped(AppMessageResult reason, void *context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "In dropped: %s", translate_error(reason));
}

Take a look at this question for the source of the translate_error function.

Upvotes: 2

Related Questions