Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Swapping Client and Server roles in the MTU example

I am developing a multi-link application where several Peripherals take turns transmitting real-time samples to a Central, generally about a 156 byte payload per transmission.  A typical case would be 8 Server peripherals sending to 1 Client Central with the event length of each transmission just a bit longer than the packet duration and a relatively short Connection Interval.  The Central would manage the timing and request the transfer from each Peripheral in turn, first from 1, then 2, ..., then 8, then back to 1, 2, ....8, 1, 2 .... and so on. 

To make the development as easy as possible I bought a whole bunch of nRF52840 Preview kits and I plan to modify application examples for the nRF52840 in SDK 15.0.0 - basically merge the multi-link Central example with the experimental MTU Central&Peripheral example.  My theory is that adaption to a multi-link application is a small extension of the Central functionality, so start with the more complex MTU example as a baseline and modify it to multi-link capability, rather than the other way around.  I noticed however, that unfortunately the MTU example has the client/server roles around the other way to my application - it has the Central as the Server sending data to the Peripheral as Client.  It is not clear to me how, or how easily, these roles can be reversed. 

How hard is this MTU example to adapt?  Are the client and server source code files (amtc.c, amts.c, amt.h) agnostic about whether the client is a Central or Peripheral? and about whether the Server is a Central or Peripheral?  are those roles assigned outside of these components in main.c only?

I am not sure what has to be done to reverse the roles - I can't see where the Central is assigned the role of Server and where the Peripheral is assigned the role of Client.  Is is only in one place and it can easily be reversed?  or is a lot of the code dependent upon the current arrangement and roles cannot be easily swapped without a major rewrite? 

Many thanks in advance for your help.

cheers

Jeff

  • Hello,

    There should be no dependency between GAP role and GATT configuration. The common scenario is that a peripheral device have the GATT server/database (e.g. a sensor) and the central device is a GATT client (e.g. mobile). However the GATT configuration can be swapped, or both peripheral and central may have a GATT server/database (and thereby also can be GATT clients). A device can always do a GATT database discovery of the peer device after connection to check what services the peer provide in their GATT database, this works independent of GAP role. I don't see any real problem here other than the time to put it all together, which of course is always time consuming.

    Best regards,
    Kenneth

Related