Android Studio 中用于 ON/OFF LED 灯的 BluetoothLEGatt 示例代码

BluetoothLEGatt sample codes in Android Studio to ON/OFF LED lights

我正在寻找 "simple" 一对用 Android Studio 编写的应用程序和 mbed 中的代码一起工作,并允许:- 将应用程序发送到 mbed (LED On/Off) - 将 mbed 发送到应用程序(按钮状态) - 通知 mbed 到应用程序,(按下按钮时响铃)

感谢任何指点或指导,我将在 mbed 上生成生成的 mbed 代码和应用程​​序源 public。

我已经在 mbed(HTM、HTM、UART 等)上完成了几个示例,但只将它们与 Nordic 示例应用程序(nRF-MCP、工具箱等)一起使用.这些应用程序是在较旧的 Eclipse 中编写的,当导入到新的 Android Studio 中时,结果是非常神秘的代码,而不是初学者所需要的。我看过其他供应商的应用程序,但他们倾向于使用自定义的旧库,而不是最新的 mbed、Android Studio 或 Android SDK。

我为 BLE 找到的唯一 Android Studio 示例代码是 BlueToothLeGatt,它是连接和列出服务的通用起点,但仅此而已:http://developer.android.com/samples/BluetoothLeGatt/index.html.

请帮助我。 提前致谢。

我自己找的。哦哦

 @Override
        public void onClick(View v) {
            if (v.getId() == R.id.red_button) {
                if ((v.getTag() != null)
                        && (v.getTag() instanceof BluetoothGattCharacteristic)) {
                    BluetoothGattCharacteristic ch = (BluetoothGattCharacteristic) v
                            .getTag();
                     ch.setValue(new byte[] { (byte) 0x03 });
                    if (mConnGatt.readCharacteristic(ch)) {
                        setProgressBarIndeterminateVisibility(true);
                    }
                }