XDK as BLE Master sample project, Bluetooth
응답
18. 6. 25 오전 11:49

Hi everyone,

 

I want to develop an application that will make the XDK device work as BLE Master to communicate with an Arduino as slave via the HC-05 bluetooth module. 

Could you please help with a sample example. Thank you in advance :)

 

Best regards,

Lahcen 

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 26 오후 12:07 as a reply to Lahcen EZZAHED.
Hello Lahcen,

Unfortunately, the BLE master role is not supported by the BLE implementation of the SDK of the XDK currently.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 26 오후 6:04 as a reply to Franjo Stjepandic.

Hello Franjo,

 

Thank you for your reply.

OK, I wonder if you could let me know where is the issue: on the hardware level or  on the software level?

I expanded the Bluetooth labriry in XDK  folder I found there is a .h file named "BleAlpwDataExchange_Client.h" see the attached capture . This .h file contains Client Role's functions. I tried to use them but it doesn't compile.  I get the error illustrated in the second attached capture.

undefined reference to `BLEALPWDATAEXCHANGE_CLIENT_LinkUpAlpwDataExchangeProfile'

 

Could you please tell me why I get this error ?

 

Best regards

Lahcen

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 27 오후 3:59 as a reply to Lahcen EZZAHED.
Hello Lahcen,

I am always happy to help.

To get more into detail, a High-Level API for the master or in other words central role is currently not available. As such, this BLE role can not be used in an XDK BLE implementation.

Furthermore, this is not related to the used BLE chip EM9301.

Nevertheless you can feel free to implement the central role and you already figured out, with the low-level API of the Alpwise Stack.

An undefined reference indicates that the implementation of the function, you try to call can not be found by the compiler and therefore your build fails.

This may happen if you did not enabled the client API with BLEALPWDATAEXCHANGE_SUPPORT_CLIENT 1

This API may not be enabled in the default state.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 29 오전 11:03 as a reply to Franjo Stjepandic.

Hello Franjo,

Thank you very much for these details.

 

Actualy, I didn't miss to enable the SUPPORT_CLIENT as you can see in the attached capture.

Despite that, I still have the same error.  Really, I don't know what is missing..

 

Best regards

Lahcen

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 29 오후 2:28 as a reply to Lahcen EZZAHED.
Hello Lahcen,

Thank you for providing more information.

Unfortunately, I am currently not able to pinpoint the cause of the compilation error. To do so, I would need access to the source code.

Would it be possible for to you upload your project on Github or to provide the relevant content in this thread here?

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 6. 29 오후 3:53 as a reply to Franjo Stjepandic.

Hi Franjo,

I just created a repository on Github for this project,  here is the link :

https://github.com/EZZAHED/xdk_ble_master

Best regards

Lahcen

0 (0 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 2 오후 3:43 as a reply to Lahcen EZZAHED.
Hello Lahcen,

Thank you for providing your application project on Github.

Could you tell me which XDK-Workbench version you are using?
After looking into the code, I assume you are using the XDK-Workbench 2.0.1 or a lower version, because your project uses a lower version of the BLE Platform API, compared to what is currently implemented in the XDK-Workbench 3.3.1.

As such, I imported your project into the XDK-Workbench 2.0.1. There, I was, unfortunately, not able to solve the issue you are facing regarding the function BLEALPWDATAEXCHANGE_CLIENT_LinkUpAlpwDataExchangeProfile() . I assume this could be caused by an older version of the third party Alpwise library.

But, I was able to solve the issue on the latest XDK-Workbench 3.3.1. Therefore, I recommend that you switch to the latest XDK-Workbench and try to implement the BLE master role there.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 6 오전 12:20 as a reply to Franjo Stjepandic.
ALPWISE Data Exchange Profile CLIENT Implementer’s Guide

Hello Franjo,

Thank you for yoour recommandation  to migrate to Workbench 3.3. Now I successfuly can build project with now problem.

I am trying to implment the Client profile, I am fellowing the official documentation of ALPWISE,  as descibed on the PDF file titled :

ALPWISE Data Exchange Profile CLIENT Implementer’s Guide

I am trying to translate the Seqence Diagram  in pages 20-21 to C code, you take a look at my implementation on github: https://github.com/EZZAHED/xdk_ble_master

But functionaly is not yet OK. I am using my phone as bluetooth device (peripheral) but until now I cannot send  data from XDK  and receive them on my phone.

I would appreciate if you could give me some advices or recommandatons. 

 

Best regards

Lahcen

 

 

0 (0 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 6 오후 1:13 as a reply to Lahcen EZZAHED.
Hello Lahcen,

Thank you for providing your updated code.

From the first glance, everything looks fine, except that you missed to implement the connection between the EM9301 BLE chip and the XDKs MCU.

To get more into detail, your current implementation only covers the Alpwise BLE Central implementation but has no access to the EM9301 BLE chip.

This is necessary because currently your implementation does not have any connection to the target hardware, the EM9301 BLE chip.

In that regard, I recommend including the interface BlePeripheral.h and to call the following three functions, before starting your BLE central implementation:
 
  • BlePeripheral_Initialize()
  • BlePeripheral_Start()
  • BlePeripheral_Wakeup()

The function BlePeripheral_Initialize() will initialize the complete connection between the XDKs MCU and the EM9301 BLE chip and starts some initialization steps in regards to the Alwise BLE stack. As such, the function BLEMGMT_Init() is already called in this context. The function BlePeripheral_Start() enables the BLE chip and BlePeripheral_Wakeup() changes the powermode of the BLE chip from low power to fully operational.

Afterwards, you should be able to proceed with the implementation of the BLE Central functionality.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 9 오후 4:36 as a reply to Franjo Stjepandic.

Dear Franjo,

 

Thank so much for providing this detailed informations..

I just integratted the low level functions for Ble Module as you recommanded, you take a look at my last commit to Github project.

When I flash the firmeware to my XDK device I get this log on the console:

 INFO | XDK DEVICE 1: ................ Ble Central -- Init()  ............. 
 INFO | XDK DEVICE 1: BlePeripheral_Initialize ... OK 
 INFO | XDK DEVICE 1: BlePeripheral_Start ... OK 
 INFO | XDK DEVICE 1: asserted at Filename 3rd-party/FreeRTOS/Source/queue.c , line no  1372 
 INFO | XDK DEVICE 1: BLE powered ON successfully 
 INFO | XDK DEVICE 1: asserted at Filename 3rd-party/FreeRTOS/Source/queue.c , line no  616 

I dont recongnize what is the problem.. I think I need a debugger to make breakpoints to find where is the issue. Since I dont have a Jlink as it's specified on the documation, Can I use an ST-Link or an Atmel-ICE debugger ?

 

Thaks and best regards

Lahcen

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 10 오후 8:59 as a reply to Lahcen EZZAHED.
Hello Lahcen,

The errors you are facing are both pointing to a call of the macro configASSERT(pxQueue) .

This is caused, because you use two semaphores BleStartSyncSemphr and BleWakeUpSyncSemphr without creating the actual semaphore binary with the function xSemaphoreCreateBinary() .

To solve this, I recommend inserting the following code snippet at the beginning of your init() function:

 
BleStartSyncSemphr = xSemaphoreCreateBinary();
BleWakeUpSyncSemphr = xSemaphoreCreateBinary();

Regarding the debugger, unfortunately the debuggers you mention will not work with the XDK. Furthermore, I recommend to use a J-Link Lite for debugging the XDK. If you intend to order the J-Link Lite, please inform the SEGGER sales team that you will use the J-Link Lite for the XDK. The J-Link Lite is not sold otherwise.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 16 오후 3:22 as a reply to Franjo Stjepandic.

Hello Franjo,

Thank you for your help.

I've just committed a new version to the github repo. 

When I run the program, I get this log: 

INFO | XDK DEVICE 1: ................ Ble Central -- Init()  ............. 
 INFO | XDK DEVICE 1: BlePeripheral_Initialize ... OK 
 INFO | XDK DEVICE 1: BlePeripheral_Start ... OK 
 INFO | XDK DEVICE 1: BLE powered ON successfully 
 INFO | XDK DEVICE 1: Device Wake up succceded  : 
 INFO | XDK DEVICE 1: BlePeripheral_Wakeup ... OK 
 INFO | XDK DEVICE 1: Ble Initialization succeded 
 INFO | XDK DEVICE 1: BLEMGMT_Init ... OK 
 INFO | XDK DEVICE 1: BLEMGMT_RegisterHandler ... OK 
 INFO | XDK DEVICE 1: BLEGAP_RegisterDevice ... OK 
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x01, status: 0  
 INFO | XDK DEVICE 1: BLEALPWDATAEXCHANGE_CLIENT_Init ... OK 
 INFO | XDK DEVICE 1: BLEGAP_Connect ... OK 
 INFO | XDK DEVICE 1: Waiting for 10s ... OK 
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x0C, status: 0  
 INFO | XDK DEVICE 1: Sending some data 
 INFO | XDK DEVICE 1: BLEALPWDATAEXCHANGE_CLIENT_SendData returned 1 
 INFO | XDK DEVICE 1: Example_Ble_Master App Initialization failed 

The issue is in this ligne 

 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x0C, status: 0

I dont recognize this event code 0x0C.. I didn't find it in the documentation.

 

Is this what causes the sending data function to return BLESTATUS_FAILED error ?

 

Best regards,

Lahcen

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 17 오후 3:48 as a reply to Lahcen EZZAHED.
Hello Lahcen,

I agree with your assumption that the event you receive from the CORESTACK_BleCallback() might be the cause, why sending data is failing.

Furthermore, the event is pointing to the define ATTPDU_STATUS_INSUFICIENT_KEY_SIZE . To find the explanation for the error, I simply used the file search of the XDK-Workbench you can find at Search > search > File Search in the upper left corner of the XDK-Workbench. There I inserted 0x0C as search parameter and got directed to the header file AttBase.h .

For further events of the same kind, I recommend reproducing the method to find the appropriate explanation for them.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 19 오전 9:02 as a reply to Franjo Stjepandic.

Hello Franjo,

Searching text is good idea to find the meaning.. I did the same procedure and found the same name.

This moorning I did another test with an HM10 arduino module. It s an 4.0 ble device. Here is the log off my XDK device.

INFO | XDK DEVICE 1: ................ Ble Central -- Init()  ............. 
 INFO | XDK DEVICE 1: BlePeripheral_Initialize ... OK 
 INFO | XDK DEVICE 1: BlePeripheral_Start ... OK 
 INFO | XDK DEVICE 1: BLE powered ON successfully 
 INFO | XDK DEVICE 1: Device Wake up succceded  : 
 INFO | XDK DEVICE 1: BlePeripheral_Wakeup ... OK 
 INFO | XDK DEVICE 1: Ble Initialization succeded 
 INFO | XDK DEVICE 1: BLEMGMT_Init ... OK 
 INFO | XDK DEVICE 1: BLEMGMT_RegisterHandler ... OK 
 INFO | XDK DEVICE 1: BLEGAP_RegisterDevice ... OK 
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x01, status: 0  
 INFO | XDK DEVICE 1: BLEALPWDATAEXCHANGE_CLIENT_Init ... OK 
 INFO | XDK DEVICE 1: BLEGAP_Connect ... OK 
 INFO | XDK DEVICE 1: Waiting for 10s ... OK 
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x0C, status: 0  
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x16, status: 0  
 INFO | XDK DEVICE 1: CORESTACK_BleCallback event: 0x18, status: 0  
 INFO | XDK DEVICE 1: Sending some data 
 INFO | XDK DEVICE 1: BLEALPWDATAEXCHANGE_CLIENT_SendData returned 1 
 INFO | XDK DEVICE 1: Example_Ble_Master App Initialization failed 

Furthermore, The status led of my HM10 indecates that the pairing is OK.

As you can see, there is other unknown Events codes 0x0C, 0x16, 0x18 that was captured by CORESTACK_BleCallback.

+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 19 오후 3:03 as a reply to Lahcen EZZAHED.
Hello Lahcen,

Finding the explanations for these errors can also be done using the search function following by looking for specific Alpwise BLE interfaces. The origin and meaning of the shown error 0xC0 , is already explained in the last post. Furthermore, 0x16 points to the define BLEDISCREASON_LOCALHOST from the interface BleTypes.h . 0x18 refers to the define BLEGAPADDATATYPE_RANDOMTARGETADDRESS in the interface BleGap.h .

Additionally, I made some findings in the newest source code you provided on GitHub.

The first one was within the function call of BlePeripheral_Initialize() . Here you are passing the function BiDirectionalServiceRegistryCallback() , which afterwards the function BlePeripheral_Start() succeeds intializes the XDK as BLE peripheral with the bidirectional send/receive service. As such, there might arise incompatibilities with your further execution of the BLE central configuration.

To solve this, I recommend deleting the entire content of the function BiDirectionalServiceRegistryCallback() and only return a RETCODE_OK .

Afterwards, I recommend to proceed with the BLE central intialization after the function BlePeripheral_Wakeup() was called.

Another findings was about how you call the functions BLEGAP_Connect() , BLEALPWDATAEXCHANGE_CLIENT_LinkUpAlpwDataExchangeProfile() and BLESMP_InitiatePairing() . All three functions are using event callbacks to notify when their processes are complete and are nonblocking. That means that other functions during their processes can be called, such as the function BLEALPWDATAEXCHANGE_CLIENT_SendData() .

To solve this issue, you would have to call the function BLESMP_InitiatePairing() after the event BLEALPWDATAEXCHANGECLIENT_EVENT_LINKED was set in the event callback BleAlpwDataExchangeClient_CallBack() . The same procedure has to apply wenn calling the function BLEALPWDATAEXCHANGE_CLIENT_SendData() . This function should first be called after the event BLEEVENT_PAIRING_COMPLETE was set.

Afterwards, you should be able to send out data to the connected device.

Regarding the HC‌-05 Arduino module, this modules does not support the Bluetooth standard 4.0, which includes Bluetooth Low Energy (BLE). As such, there might be an issue that the module itself cannot receive the data from the XDK, even if they are sent successfully.

Here, I recommend using a device, which supports the Bluetooth standard 4.0.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
+1 (1 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 19 오후 3:28 as a reply to Franjo Stjepandic.

Hello guys, sorry for disturbing you,  but I started working this week with XDK, and i have to do a project that uses XDK as a BLE client to send DATA (not sensor DATA), just make it vibrate or display something on a smartwatch. I have been reading all documentation, i did the basics programs to get used to XDK but as i have little time for the project, im here to ask for help , a brief explanation what configurations i have to enable on xdk to make it possible to be a client.  I have been reading this post for last days to try understand a little bit more about it but it has been difficult. And when u make your program work, i would be very please if you upload your code so i could take it as a example or a guide to mine.

Thank you very much

+2 (2 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 20 오전 11:56 as a reply to Pablo Curr.

Hello again, i have been working on the project and i could figure out the configurations for the XDK to work as a client, but now im having the same problems that Lahcen has. Im trying to connect to my phone and i dont think its working yet. Are you sure that you were able to connect?

Thanks

0 (0 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 20 오후 2:33 as a reply to Pablo Curr.
Hello Pablo,

First of all, let me welcome you to the XDK Community.

Unfortunately, this is a more complex implementation regarding enabling the XDK to act as central device. To be more precise, it can currently not be implemented easily by using the high-level API.

But I assume when Lahcen finishes the implementation, he might upload the solution to GitHub too.

Regarding your insight on this topic, did you simply download and tried the project Lahcen uploaded to GitHub, or did you take the hints and recommendations from my previous post into account?

Please note that it might be difficult to understand how to implement the Central role if you are new at programming with the XDK. As such, I strongly recommend going through the First Steps and BLE guide you can find in the Learning Section of the XDK community to get familiar with the XDK programming.

Kind regards,
Franjo
0 (0 투표)
RE: XDK as BLE Master sample project, Bluetooth
응답
18. 7. 20 오후 2:56 as a reply to Franjo Stjepandic.

Hi, before downloading the Project Lahcen uploaded, i went through the first steps and BLE guide. After that, i downloaded the Project and i followed your hints. I was able to configurate XDK, but now im stuck with CORESTACK_BleCallback event: 0x0C . I read your last post about that changes you recommend doing to make it possible to send data but i dont think it is connecting to the device yet. It says it connected but i dont get any notification on my phone or in the smartwatch. Im not sure what is the problem. Maybe i should wait for Lahcen to know if he managed to do it.

Thanks

0 (0 투표)