gpt4 book ai didi

javascript - Javascript(Ionic)中两个移动设备之间的距离

转载 作者:数据小太阳 更新时间:2023-10-29 03:57:58 25 4
gpt4 key购买 nike

对于我的一个项目,我目前想要构建一个 Ionic 应用程序,以便为 iOS 和 Android 平台编写一次代码。我正在寻找一种方法来测量两个移动设备之间的距离。一个设备应该放在一个特定的位置,另一个应该在进入第一个设备的范围(或者更具体地说是第一个设备所在的位置)时被检测到。

位于特定位置的设备 1 将连接到互联网,访问该位置的设备 2 也是如此。

我已经阅读了很多不同的实现,但大多数时候它需要用于 Android 或 iOS 的 native 代码。

以下是我已经找到的解决方案:

  • 蓝牙:每部手机都有蓝牙,所以手机靠近另一部手机应该不难检测到,但这意味着要与另一台设备配对,这不太可能测量两个设备之间的距离。
  • iBeacons 和 BLE:我们希望避免在发布时购买大量信标。这意味着我们想创建一个移动应用程序来充当信标,但在许多设备上的 Android 上是不可能的。此外,我们不关心微位置,这意味着我们不会 100% 地使用信标。
  • GPS:在安全方面并不是很好,无法确保两个设备的位置都正确。
  • 在位置手动签到:确保设备 2 在设备 1 的位置上运行的最佳方法是在地点。但这有点令人沮丧,因为在全部。

我实际上已经没有想法了。实现应该使用 Javascript 来编写快速原型(prototype),因此选项有限。

我在 StackExchange 上读过一篇帖子:Stack ,但问题是没有描述实现。

换句话说,我希望签到系统知道设备 2 去了设备 1 的位置。即使在请求我们的服务器的 API 之间进行了交换,我们如何确定两个设备被或关闭了至少设备 2 到达了特定位置?

编辑与新闻

为了给可能面临相同情况的人提供更多选择,我联系了一位在 Microsoft 工作的人并参与了一个名为:ThaliProject 的项目,您可以在 Google 上找到它,这是一个用于在移动设备之间进行通信的点对点库。但它不适合这个问题:

Unfortunately Thali isn't going to solve your problem. :( We depend on Bluetooth 4.2 support on Android (so we can be both a BLE central and peripheral).

Bluetooth also won't work if you need things to work between an Android and iOS device because Apple uses a proprietary variant of Bluetooth that doesn't work.

Now BLE does work between Android and iOS. And while many Android phones can't be peripheral, most of them can be central.

Another possibility that different folks are playing around with is sound. Something like https://developers.google.com/nearby/messages/overview?hl=en. A number of groups have been experimenting with local discovery via ultrasonic communication. Just send the challenge and get the response over ultrasonic and you have proven that devices 1 and 2 are very close to each other.

我偶然发现了一个名为 SonicNet.JS 的 JavaScript 库,它可以通过超声波发送数据和字符串,但实际上我正在努力让它在我的电脑上运行。这可能是一种解决方案,可以避免互操作性问题。

最佳答案

您可以使用适用于 Cordova 的低功耗蓝牙插件 ( https://github.com/evothings/cordova-ble )。它主要适用于 Android 和 iOS。

当然,这些设备应该支持 BLE,但许多新智能手机都支持 BLE。

您可以先使用 evothings.ble.startScan(success, error) 扫描您周围,然后使用 RSSItxPower 值获取设备之间的距离。

关于javascript - Javascript(Ionic)中两个移动设备之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42797813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com