FRDM-KW41Z BLE for HM-10 pairing and transmission

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-KW41Z BLE for HM-10 pairing and transmission

Jump to solution
2,348 Views
javiermonrealtr
Contributor II

Good morning,

It is my first time programming Bluetooth in a uC without AT commands, and I'm having troubles in transmitting messages between the demo example provided in the SDK and my PC.

I am using an FRDM-KW41Z board and an HM-10, both connected to my PC through USB and terminal. Both have the terminals opened in my PC properly (because I did it in previous experiences the same way, see Additional information).

I set the HM-10 as master, and the FRDM as a slave (SW4 button) and bound them (both have fixed red LED shinning), now what I write in the HM-10 terminal should be shown in the FRDM terminal, but it doesn't show anything.

Both UARTs are set to 115200 bauds, 8 bits, NP.

I am developing a Matlab GUI for remotely controlling the FRDM, that is why I am using the HM-10 as BLE master.

What can I do for receiving and sending messages from FRDM-KW41Z to HM-10 and vice-versa? Or what am I doing wrong? Every reply will be really helpful, I don't know what is missing. 

Thanks in advance,

Javier

-> EDIT (3rd June): I think the problem is the GATT profiles: HM-10 has a non-standard profile for communication, meanwhile the KW41Z has another. I can connect to the HM-10 with my smartphone and transmit, but I'm not sure what I shall modify in my NXP project to modify the GATT to make it compatible with HM-10 one.

Software information:

I'm using MCUxpresso IDE v10.1.1_606 (JLink and OpenSDA seem installed). The demo example I am using is from SDK_2.x_FRDM-KW41Z (version 2.2.0), called frdmkw41z_wireless_examples_bluetooth_wireless_uart_freertos.

Additional information:

I had no problem in using GPIO, DAC and ADC. Neither using the beacon demo.

HM-10 is working properly, I paired two of them and communicated via terminals.

I can connect the FRDM running the demo example with my smartphone, and use the PC-terminal and the Android app-terminal.

1 Solution
1,830 Views
javiermonrealtr
Contributor II

I made a decision: I will use another NXP as USB dongle. Now everything is working with my custom service.

Best regards,

Javier

View solution in original post

0 Kudos
Reply
4 Replies
1,831 Views
javiermonrealtr
Contributor II

I made a decision: I will use another NXP as USB dongle. Now everything is working with my custom service.

Best regards,

Javier

0 Kudos
Reply
1,830 Views
javiermonrealtr
Contributor II

Good evening, @Estephania,

I am using a BLE app with my smartphone. This way I can scan the BLE peripherals (HM-10 and KW41Z), connect to them with my smartphone as central and see and use their services.

I programmed the KW41Z to behave the same way than the HM-10 peripheral (same UUIDs, services, characteristics...), and I can access to the message value from my phone and write it, the same way.

But when I connect the HM-10 as central to the KW41Z, I cannot transmit messages, am I missing something?

Javier

0 Kudos
Reply
1,830 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

You will need to create a custom profile in order to achieve what you are trying to do. You will need to investigate the way the profile it's made for the HM-10 and create the profile for the KW41Z.

To help you in the creation of the custom profile and understanding more about the topic, could you please check the following guides? 

Creating a custom profile using NXP BLE stack – Server 

How to create a Custom Profile - Client 

Regards,

Estephania

1,830 Views
javiermonrealtr
Contributor II

Thanks for your reply, @Estephania,

About the HM-10 profile, it has just one characteristic, which value is the message. Its length is 20 bytes.

HM10 Custom Characteristic UUID 0000FFE100001000800000805F9B34FB

HM10 Custom Service UUID 0000FFE000001000800000805F9B34FB

This characteristic is notifiable, writable without response and readable. If we have an HM-10 as peripheral, and another HM-10 as central, the first one would act as the server and the second one as the client. Both modify the value of the attribute of the peripheral, notifying when the other makes a change.

My objective is to use the KW41Z as peripheral and the HM-10 as central connected to my PC, so then I have tried to implement a GATT server service for the KW41Z.

I've actually been following the guides you sent and I've written my own profile, which I attach. I had to main problems:

1. In Creating a custom profile using NXP BLE stack – Server which value is...

potentiometerCharacteristicUuid128

In standard profiles they use reduced UUIDs, that are reserved, how do I set my Hermes UUID for this function?

2. About Handling Notifications and Write Requests, should I define in gatt_db.h...

cccd_input_report

 ...as a second cccd of my service, or with one would be enough (because I just want one characteristic to be notified)? In that case, I think that I should add just this part properly modified to my code:

case cccd_potentiometer:{
              //Determine if the timer must be started or stopped
              if (pServerEvent->eventData.charCccdWrittenEvent.newCccd){
                // CCCD set, start timer
                TMR_StartTimer(potTimerId, gTmrIntervalTimer_c, gPotentiometerUpdateTime_c ,BleApp_PotentiometerTimer, NULL);
#if gAllowUartDebug
                Serial_Print(debugUartId, "Potentiometer notifications enabled \n\r", gNoBlock_d);
#endif
              }
              else{
                // CCCD cleared, stop timer
                TMR_StopTimer(potTimerId);
#if gAllowUartDebug
                Serial_Print(debugUartId, "Potentiometer notifications disabled \n\r", gNoBlock_d);
#endif
              }

But how should I define these variables?

potTimerId, gTmrIntervalTimer_c, gPotentiometerUpdateTime_c ,BleApp_PotentiometerTimer

Thank you very much and best regards,

Javier

0 Kudos
Reply