从Android或iOS使用Microhip的MLDP数据流 [英] Using Microhip's MLDP data streaming from Android or iOS

查看:93
本文介绍了从Android或iOS使用Microhip的MLDP数据流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microchip定义了一种通过蓝牙低能耗(BLE)传输数据的方法,并将其称为MLDP(Microchip低能耗数据配置文件).他们将其内置到 RN4020 芯片中,甚至还有一个示例 Android应用.

但是,我找不到有关该协议如何工作或该应用程序来源的任何规范.我希望能够使用它从Android和/或iOS调试嵌入式设备.

有人知道这个协议或实现它的软件的规范吗?

解决方案

您好,我遇到了同样的问题,但是目前我有一个使用MLDP的有效代码,首先您需要转到Module网页:

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与微芯片的示例代码相同,但具有以下更改:

@Override
public 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=RN4020

then, under Documentation & Software you can find:

  • Android Explorer 16 RN4020 PICtail Demo Code
  • MLDP Demo for Android
  • RN4020 Android App Demo

The 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 value

in 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 SPP

some parts of my code for fast understanding and implementation:

mBluetoothGatt = mDevice.connectGatt(this, false, mGattCallback);//To connect to mDevice

mGattCallBack is the same like the microchip's sample code, but with the change of:

@Override
public 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 data

you 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 it

I hope my answer to be useful for you and someone else.

这篇关于从Android或iOS使用Microhip的MLDP数据流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆