0

我目前正在尝试使用 AppSync 在 android 应用程序和 pebble 应用程序之间同步一段数据。但是,我似乎无法让鹅卵石意识到正在传输任何数据 - 也就是说,没有在应有的位置生成日志。真正困扰我的是,这基本上是卵石天气示例中的代码。我已经在下面粘贴了相关的代码片段——有人可能会查看它并提出问题所在吗?我已经确保两个程序(pebble 应用程序和 android 应用程序)中的 UUID 相同,并且它们在同一个网络上,并且 pebble 实际上已连接到手机,并且 android 功能实际上是调用和所有。

卵石应用程序代码片段:

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);
}

安卓应用程序片段:

    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);
}
4

1 回答 1

1

要调试此类问题,您应该设置一个inbox_dropped处理程序并查看是否有任何问题。

初始化 AppMessage 和 AppSync 后,调用:

app_message_register_inbox_dropped(appmsg_in_dropped);

并添加此功能:

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

看看这个问题translate_error函数的来源。

于 2014-06-29T20:12:06.387 回答