cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with BlueNRG-MS after waking up the SPI Master (Application Processor)

Muhammad Waseem Abbas
Associate II
Posted on April 25, 2017 at 16:22

Hi All,

I am running BLE peripheral profile application on Mentor Graphics' Nucleus RTOS using STM32 MCU interfaced with BlueNRG-MS module. The application runs successfully and I can connect to the heart rate monitor profile using Android app by ST named 'STM32 BLE Profiles'. One of our requirements is that the BLE module should keep on advertising after we disconnect from it and we shutdown the MCU (Application Processor) and then we should be able to connect to it after MCU shutdown and it should wake up the MCU and start communicating with it normally. We are using SPI_IRQ line of BlueNRG-MS to send the wake up signal to MCU. As the profile has already been initialized on BlueNRG-MS before MCU went to shutdown state, we do not re-initialize the profile on BlueNRG-MS and only local objects used by the application are initialized again after MCU wake-up. The Android app connects to the BLE successfully and BueNRG-MS wakes up the MCU via SPI_IRQ pin. We set the device state in our application as APPL_CONNECTED and then we execute the main application process given in the source code by ST shown below:

/* Start the main processes */

while(1){

HCI_Process();

profileApplContext.profileStateMachineFunc();

if (Profile_Process_Q() == 0x00)

{

      if (low_power_enabled)

      {

                if (profileApplContext.profileApplicationProcessFunc() != 0) {

                        LPM_Mode_Request(eLPM_MAIN_LOOP_PROCESSES, eLPM_Mode_RUN);

                 }

                 else{

                         LPM_Mode_Request(eLPM_MAIN_LOOP_PROCESSES, eLPM_Mode_LP_Stop);

                 }

      }

      else

      {

            profileApplContext.profileApplicationProcessFunc();

      }

}

LPM_Enter_Mode();

} /* end while(1) */

When we execute this loop, the function Profile_Process_Q() returns 0x00 in the first iteration but in all other iterations it returns 0x01 and prints below message on the console:

'Error While Initializing main profile.'

Due to this it cannot call the profile application process function pointed to by '

profileApplContext.profileApplicationProcessFunc()

'. 

We do not know in detail what this Profile_Process_Q() function is doing as it has been provided in binary form and very little information is given about it in the documentation. 

We have also tried to skip its call after the first iteration of while loop using control statement and calling profile application process function forcefully but when we try to write the heart rate value using 'HRProfile_Send_HRM_Value(tHeartRateMeasure heartRateVal)' function in HR_Application_Process(), it returns 0x41 and we don't see any data on Android app. 

It would be helpful if someone can provide information on what exactly the Profile_Process_Q() function is doing and any other insight that might help in this regard.

#bluenrg-ms
1 ACCEPTED SOLUTION

Accepted Solutions
Antonio Vilei
Senior III
Posted on April 26, 2017 at 11:12

Dear Muhammad Waseem Abbas,

after MCU wake-up, it seems that for some reason the variables of the profile have lost their previous value. When the Profile_Process_Q() function checks if the profile has been correctly initialized, it will stop and won't continue executing its state machine because it isn't initialized. Unfortunately, you can't re-init the profile or you will lose the incoming connection from the phone/tablet.

I understand that debugging this issue with a binary file is not easy, and so, as an alternative, I would suggest you to take a look at this application, instead:

Projects\Multi\Applications\SensorDemo_DMA_LowPower

In this application the source code is fully available, so you can try implementing your changes and see what happens.

The SensorDemo_DMA_LowPower application is using custom services and characteristics, but you can still change it to use the UUIDs of the standard HRM service and characteristics.

Hope that helps,

Antonio

View solution in original post

1 REPLY 1
Antonio Vilei
Senior III
Posted on April 26, 2017 at 11:12

Dear Muhammad Waseem Abbas,

after MCU wake-up, it seems that for some reason the variables of the profile have lost their previous value. When the Profile_Process_Q() function checks if the profile has been correctly initialized, it will stop and won't continue executing its state machine because it isn't initialized. Unfortunately, you can't re-init the profile or you will lose the incoming connection from the phone/tablet.

I understand that debugging this issue with a binary file is not easy, and so, as an alternative, I would suggest you to take a look at this application, instead:

Projects\Multi\Applications\SensorDemo_DMA_LowPower

In this application the source code is fully available, so you can try implementing your changes and see what happens.

The SensorDemo_DMA_LowPower application is using custom services and characteristics, but you can still change it to use the UUIDs of the standard HRM service and characteristics.

Hope that helps,

Antonio