【问题标题】:CloudPebble emulator vs iOS pebble native app?CloudPebble 模拟器 vs iOS pebble 本机应用程序?
【发布时间】:2015-06-09 08:03:32
【问题描述】:

我想知道如何与 iOS pebble 原生应用进行通信。我可以使用云 pebble 创建手表应用,但我不知道如何在云模拟器和 iOS pebble 原生之间建立连接。

任何帮助链接或任何东西都将不胜感激。谢谢

【问题讨论】:

    标签: ios iphone pebble-sdk cloudpebble


    【解决方案1】:

    终于我自己找到了。感谢@dustin @kirby

    默认情况下,pebble iOS 应用程序没有启用开发者选项模式的选项 要启用选项,您需要使用蓝牙将 pebble 手表与 pebble iOS 应用程序连接。

    启用后,pebble iOS 应用程序将从云 pebble 监听您的 pebble 手表安装。(我正在使用云 pebble)。

    有两种方法可以启用它。

    1.从云卵石的编译选项卡中选择您的设备。 2.手动输入IP地址(但我认为它已从最新版本的pebble sdk中删除)。

    您应该将您的设备插入您的 Mac 计算机。 您应该将您的 pebble 手表与您的 iPhone 设备配对。

    如果你使用c代码创建卵石手表(我的建议使用cloud pebble

    如果您想与您的 iPhone 设备和 pebble watch 通信。

    Follow here.

    示例代码:C语言

    从 iPhone 应用接收数据以供观看:

    static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
      APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
        Tuple *t = dict_read_first(iterator);
    
      while (t != NULL) {
        // Long lived buffer
            static char s_buffer[64];
            APP_LOG(APP_LOG_LEVEL_INFO, "Message ready to get!");
            snprintf(s_buffer, sizeof(s_buffer), "'%s'", t->value->cstring);
            text_layer_set_text(hello_text_layer, s_buffer);
        // Get next pair, if any
        t = dict_read_next(iterator);
      }
    }
    

    从手表接收数据到 iPhone 应用:

    - (IBAction)send:(id)sender {
    
        [self.watch appMessagesLaunch:^(PBWatch *watch, NSError *error) {
            if (!error) {
                NSLog(@"Successfully launched app.");
            }
            else {
                NSLog(@"Error launching app - Error: %@", error);
            }
        }
         ];
        // Register to receive events
        [[PBPebbleCentral defaultCentral] setDelegate:self];
        // Set UUID
    //UUID is must which is available in watch application.
            uuid_t myAppUUIDbytes;
            NSUUID *myAppUUID = [[NSUUID alloc] initWithUUIDString:@"3c74cf8f-74e5-4975-8ad5-e4b25beea86f"];
              [myAppUUID getUUIDBytes:myAppUUIDbytes];
            [[PBPebbleCentral defaultCentral] setAppUUID:[NSData dataWithBytes:myAppUUIDbytes length:16]];
    
        NSDictionary *message = @{@(0):@"optisol",
                                  };
        NSLog(@"%@",message);
    
    //sending code
        [self.watch appMessagesPushUpdate:message onSent:^(PBWatch *watch, NSDictionary *update, NSError *error) {
            NSLog(@"getting called");
            if (!error) {
                NSLog(@"Message sent!!!!!!!!");
            }
            else
            {
                NSLog(@"Message not sent!!!!!!!!\n\n%@",error.localizedDescription);
    
            }
    
    
        }];
        //receving code
        [self.watch appMessagesAddReceiveUpdateHandler:^BOOL(PBWatch *watch, NSDictionary *update) {
            // Process incoming messages
            NSLog(@"%@",update);
            NSLog(@"received called");
    
            return YES;
        }];
    }
    

    应该是: 1.移动设备和电脑要在同一个网络 2.应该配对 3.可选(我使用的是chrome浏览器和firefox)。

    您可以下载示例项目..

    Source

    启用开发者连接:

    Here

    要编写移动应用程序:

    Here

    如果您对此有疑问,只需重新启动所有设备并重试。

    【讨论】:

      【解决方案2】:

      如果我对您的理解正确,您是在尝试让您的代码在您的物理 pebble 手表上编译和执行,对吗?

      如果是这样,那么 cloud pebble 让这变得非常容易。确保您在 pebble 云中登录到与手机上的 pebble 应用程序中相同的 pebble 帐户。确保您的手机有互联网连接也是明智之举。后记在cloudpebble中打开你的应用项目,点击编译选项卡,然后点击“手机”。

      现在打开手机的 pebble 应用程序并进入“开发者连接”屏幕,并确保它已启用。

      如果一切设置正确,现在当您从 cloudpebble“安装并运行”时,应用程序将自动下载到您的手机并推送到您的手表上。

      【讨论】:

      • 是的,如建议的那样。我尝试编译->电话->安装,然后运行它加载消息“等待电话:确保电话连接已启用”我的设备已与我的 mac 和两者连接有相同的 wifi 网络连接。
      • 它很长时间了,我在 pebble iOS 应用程序中找不到任何开发者模式选项,正如这里所建议的 developer.getpebble.com/guides/publishing-tools/…
      【解决方案3】:

      您只需要在您的 iOS 应用上启用开发者连接即可。

      你可以在这里找到它。 http://i.imgur.com/uqNIGpN.png

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-26
        • 1970-01-01
        • 2014-06-26
        • 2018-10-28
        • 2021-11-20
        • 1970-01-01
        • 2012-04-14
        相关资源
        最近更新 更多