About the callback function "onConnection"

Ask, and ye shall receive.
harry617
Posts: 1
Joined: 02:38, 05 Jun 2015

About the callback function "onConnection"

Postby harry617 » 02:49, 05 Jun 2015

Hello everybody,

When I walk through this tutorial "How to turn a Nordic Semiconductor nRF51-DK into a discoverable beacon using mbed (http://evothings.com/how-to-turn-a-nordic-semiconductor-nrf51-dk-into-a-discoverable-beacon-using-mbed/)"

There is a callback function "onConnection" in main code as below:

Code: Select all

void onConnection(Gap::Handle_t handle,
                             Gap::addr_type_t peerAddrType,
                             const Gap::address_t peerAddr,
                             const Gap::ConnectionParams_t * connectionParams)
 {
      set the initial values of the characteristics (for every session) led_value = 0;       
      onLedDataWritten(&led_value, 1);
      force LED's to be in off state
}
...
...
ble.onConnection(onConnection);
...

Then the compiler generate an error 167:

Code: Select all

Error: Argument of type "void (*)(Gap::Handle_t, Gap::addr_type_t, const std::uint8_t *, const Gap::ConnectionParams_t *)" is incompatible with parameter of type "Gap::ConnectionEventCallback_t" in "main.cpp", Line: 198, Col: 24

Please tell me how to remove it? :? :? :?
Thank you for your help!!

naqqash13
Posts: 1
Joined: 23:19, 13 Jun 2015

Re: About the callback function "onConnection"

Postby naqqash13 » 23:22, 13 Jun 2015

Hi harry617,

I also have the same problem. Did you solve the issue. Anybody ??

I actually commented out that line of the code and went through the whole process as described in the tutorial. The LEDs are working fine but the button is not working. Any help will be appreciated.

Regards,
Naqqash

ardiri
Posts: 58
Joined: 16:13, 28 May 2014

Re: About the callback function "onConnection"

Postby ardiri » 02:37, 23 Jun 2015

Hi guys

I originally wrote the blog post with the nRF51-DK; it seems that the mbed development team has turned around and changed the underlying BLE libraries and some of their naming conventions on us since the blog post was written. so unfortunately; the code doesn't work as expected - here are some modifications to reflect against the latest version of the libraries that are available within mbed development environment:

Code: Select all

-void onDataWritten(const GattCharacteristicWriteCBParams *context)
+void onDataWritten(const GattWriteCallbackParams *context)
{
  // was the characteristic being written to nRF51_GATT_CHAR_LED?
-  if (context -> charHandle ==
+  if (context -> handle ==
      gatt_characteristics[CHARACTERISTIC_LED] -> getValueHandle())
  {
    onLedDataWritten(context -> data, context -> len);
  }
}


and

OLD

Code: Select all

-void onConnection(Gap::Handle_t handle,
-                  Gap::addr_type_t peerAddrType,
-                  const Gap::address_t peerAddr,
-                  const Gap::ConnectionParams_t * connectionParams)
+void onConnection(const Gap::ConnectionCallbackParams_t *params)
{
  INFO_NL(">> connected");

  // set the initial values of the characteristics (for every session)
  led_value = 0;
  onLedDataWritten(&led_value, 1); // force LED's to be in off state
}


the code should technically still be the similar in structure; but after investigation it looks like the ARM team has finally started to look at adding central mode support within the BLE libraries which opens up a number of opportunities for developers once the soft devices can be flashed to the devices.. i've been a little out of sync with the developments lately; but it looks like it is time to get right back into it!
// Aaron
Chief Technology Officer
Evothings AB http://www.evothings.com/

katphlab
Posts: 1
Joined: 07:18, 29 Aug 2015

Re: About the callback function "onConnection"

Postby katphlab » 07:22, 29 Aug 2015

Hi,
I think the libraries have been changed again, when I try to compile the code it says
Error: Identifier "GattCharacteristicWriteCBParams" is undefined in "main.cpp", Line: 83, Col: 27
I tried to find GattCharacteristicWriteCBParams and indeed it is missing or i might be looking at the wrong places. Anyway, can you tell me a workaround it? Thanks in advance for help :)

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: About the callback function "onConnection"

Postby micke » 12:03, 29 Aug 2015

What worked for me, for another example, is that I imported the example and check the checkbox for updating libraries. Perhaps this is what you have already tried?


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 17 guests