http://www.microchip.com/wwwproducts/Devices.aspx? product = RN4020然后,在文档和文档"下您可以找到的软件: Android Explorer 16 RN4020 PICtail演示代码 Android的MLDP演示 RN4020 Android应用演示第一项是用于与Android的模块和MLDP一起使用的示例代码,它使用从Android 4.3(API 18)实现的Bluetooth GATT clases MLDP概念与BTL的任何其他"GATT特性"一样,但是它是直接从RF发送到UART的,而无需微控制器需要该特性值在示例代码中,您将找到两个项目(一个带有服务(Android后台组件)),转到"RN4020 Die"项目,如果需要,将其导入到您的工作区中,但是在src/package name/文件夹下,您将找到文件'DeviceControlActivity.java'该文件包含使用所选的BluetoothDevice对象并与其建立GATT连接的主要代码,然后您将看到诸如写入和读取特征,检查和/或使用部分代码等功能的功能.使用像SPP这样的模块我的代码的某些部分便于快速理解和实施:mBluetoothGatt = mDevice.connectGatt(this, false, mGattCallback);//To connect to mDevice mGattCallBack与微芯片的示例代码相同,但具有以下更改:@Overridepublic void onCharacteristicChanged(BluetoothGatt gatt,BluetoothGattCharacteristic characteristic) { String dataValue = characteristic.getStringValue(0);//get modified data RX.append(dataValue);//append it on my RX textview}进行此修改后,当特性发生变化时,您将收到一个事件",在这种情况下,每次微控制器发送数据时您可以使用提供的函数'writeCharacteristic'发送数据,您可以像这样使用它:mDataMDLP.setValue("R=>" + TX.getText() + "\r\n");writeCharacteristic(mDataMDLP);最后,函数'findMldpGattService'太重要了,它将比较MLDP协议的已声明UUID与设备上可用的UUID,然后它将初始化'mDataMDLP'对象,以供您使用我希望我的回答对您和其他人有用.Microchip defined a way to stream data over BlueTooth low energy (BLE) and called it MLDP (Microchip Low-energy Data Profile). They built it into their RN4020 chip, and there is even an sample Android app.However, I can't find any specification of how the protocol works or source for the app. I'd like to be able to use it to debug an embedded device from Android and/or iOS.Does anyone know the specification for this protocol or software that implements it? 解决方案 Hi i was in the same problem, but at this moment i have a working code with MLDP, first you need to go to the Module web page:http://www.microchip.com/wwwproducts/Devices.aspx?product=RN4020then, under Documentation & Software you can find:Android Explorer 16 RN4020 PICtail Demo CodeMLDP Demo for AndroidRN4020 Android App DemoThe first item is an example code for working with the module and MLDP from android, it uses Bluetooth GATT clases which was implemented from Android 4.3 (API 18)The MLDP concept is like any other 'GATT Characteristic' of BTL, but it is send directly from the RF to the UART without microcontroller need to request the characteristic valuein the example code you will find two projects (one with service (android background component)), go to the 'RN4020 Die' project, import it to your workspace if you want, but under the src/package name/ folders, you will find the file 'DeviceControlActivity.java'that file contains the main code for using de BluetoothDevice object you select and create the GATT connection with it, then you will see functions like write and read characteristic, checking and/or using parts of the code you will be able to begin using the module like SPPsome parts of my code for fast understanding and implementation:mBluetoothGatt = mDevice.connectGatt(this, false, mGattCallback);//To connect to mDevicemGattCallBack is the same like the microchip's sample code, but with the change of:@Overridepublic void onCharacteristicChanged(BluetoothGatt gatt,BluetoothGattCharacteristic characteristic) { String dataValue = characteristic.getStringValue(0);//get modified data RX.append(dataValue);//append it on my RX textview}with that modification, you will receive an 'event' when characteristic changes, in this case, every time microcontroller send datayou can use the provided function 'writeCharacteristic' to send data, you can use it like this:mDataMDLP.setValue("R=>" + TX.getText() + "\r\n");writeCharacteristic(mDataMDLP);Finally, the function 'findMldpGattService' is too important, it will compare the declared UUIDs of the MLDP protocol with the available on the device, then it will initialice the 'mDataMDLP' object, allowing you to use itI hope my answer to be useful for you and someone else. 这篇关于从Android或iOS使用Microhip的MLDP数据流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-26 12:11