我想知道如何与iOS pebble原生应用程序进行通信。我可以使用cloud pebble创建手表应用程序,但我不知道如何建立云模拟器和iOS pebble原生之间的连接。
任何帮助链接或任何东西将不胜感激。由于
如果我理解正确的话,您是想让您的代码在您的物理pebble watch上编译和执行,对吗?
如果是这样,那么云卵石使这非常容易。请确保您在pebble cloud中登录的pebble帐户与您在手机上的pebble应用程序中登录的相同。确保你的手机有互联网连接也是明智的。在cloudpebble中打开应用程序项目,单击编译选项卡,然后单击"phone"。
现在打开pebble应用程序,进入"开发者连接"界面,并确保它已启用。
如果一切设置正确,现在当你从cloudpebble"安装并运行"时,应用程序将自动下载到您的手机并推送到您的手表上。
你只需要在你的iOS应用上启用开发者连接。
你可以在这里找到它。https://i.stack.imgur.com/vGFuh.png
最后我自己找到了。感谢@dustin @kirby
默认pebble iOS应用程序没有选项启用开发者选项模式要启用此选项,您需要使用蓝牙将您的pebble手表与pebble iOS应用程序连接。
一旦你启用,pebble iOS应用程序将从云pebble监听你的pebble手表安装。(我用的是云卵石)
有两种方法可以启用它。
1。从cloud pebble的编译选项卡中选择您的设备。2.手动输入IP地址(但我认为它已从最新版本的pebble sdk中删除)。
你应该把你的设备和你的Mac电脑连接起来。你应该把你的pebble watch和你的iPhone设备配对。
如果你使用c代码创建pebble watch(我建议使用cloud pebble)
如果你想与你的iPhone设备和pebble watch通信。
跟随。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!!!!!!!!nn%@",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)。
你可以下载样例项目..
来源启用开发人员连接:
这里如何编写移动应用程序:
这里如果您有问题,请重新启动所有设备,然后再试一次