展示HN:模拟真实的 CBCentralManager(Swift)或 BluetoothManager(Android)

1作者: fcpguru29 天前原帖
你好,HN! 我已经在开发一款仅支持蓝牙的 iOS 和 Android 应用程序几个月了。在测试过程中尝试了很多不同的方法。我通过我的 MacBook 运行了多部真实手机。我编写了一个使用 github.com/go-ble/ble 的 Golang 程序,成功实现了从 MacBook 连接到手机的功能。但最终,为了达到我所需的测试水平,我开始了: [https://github.com/andrewarrow/auraphone-blue](https://github.com/andrewarrow/auraphone-blue) 这是一个 100% 的 Go 程序,但它包含一个 "swift" 包,其中有 cb_central_manager.go、cb_peripheral_manager.go 和 cb_peripheral.go,还有一个 "kotlin" 包,包含 bluetooth_device.go、bluetooth_gatt.go 和 bluetooth_manager.go。这些程序模拟了真实的 iOS 和 Android 蓝牙栈及其所有微妙的差异。 使用 Go 的 fyne GUI,我制作了实际的手机 "应用",可以同时运行多部 Android 手机和多部 iPhone。文件系统用于将数据 "通过线传输" 或 "无线传输",因为这是蓝牙。以下是运行时的截图: [https://i.imgur.com/Io3OZ5x.png](https://i.imgur.com/Io3OZ5x.png) 为了测试复杂场景,比如同时运行 7 部 iPhone 和 4 部 Android 手机,我运行这个 GUI,不断调整逻辑并修复所有边缘情况。然后,我将这些逻辑从 Go 转回到真实的 Kotlin 和 Swift 以用于真实的应用程序。iOS 应用已在 App Store 上线: [https://apps.apple.com/us/app/auraphone/id6752836343](https://apps.apple.com/us/app/auraphone/id6752836343) 你觉得这种测试方法怎么样?
查看原文
Hello HN!<p>I&#x27;ve been working on a bluetooth only ios and android app for a few months now. Been through lots of different ways to test. I ran multiple real phones from my macbook. I wrote a golang program using github.com&#x2F;go-ble&#x2F;ble that actually works and connects from the macbook to a phone. But in the end to really get the level of testing I needed I started:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;andrewarrow&#x2F;auraphone-blue" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;andrewarrow&#x2F;auraphone-blue</a><p>Which is a 100% go program but it has a &quot;swift&quot; package with cb_central_manager.go, cb_peripheral_manager.go, and cb_peripheral.go. And a &quot;kotlin&quot; package with bluetooth_device.go, bluetooth_gatt.go and bluetooth_manager.go. These simulate the real ios and android bluetooth stacks with all their subtle differences.<p>Using go&#x27;s fyne GUI I made the actual phone &quot;apps&quot; and can run many android phones and many iphones. The filesystem is used to write data &quot;down the wire&quot; or &quot;over the air&quot; since this is bluetooth. Screenshot of it running:<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;Io3OZ5x.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;Io3OZ5x.png</a><p>To test complex scenarios like 7 iphones and 4 androids all running at the same time I run this gui and keep fine tuning the logic and fixing all the edge cases. Then I move this logic from go back to real kotlin and swift for the real apps. The ios app is live in the app store:<p><a href="https:&#x2F;&#x2F;apps.apple.com&#x2F;us&#x2F;app&#x2F;auraphone&#x2F;id6752836343">https:&#x2F;&#x2F;apps.apple.com&#x2F;us&#x2F;app&#x2F;auraphone&#x2F;id6752836343</a><p>What do you think of this approach for testing?