This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Best structure for BLE application

I was working my way through the app note nAN-36, where it says you should have a seperate source and header file for each service. However in many of the newer SDK examples the service is included in the source file. This made it a little difficult to follow the app note tutorial since I think the BAS example was in the newer format (service files included in main.c).

What is the best approach in terms of structure when creating a new BLE application?

I've decided to start from scratch and create my own project in order to understand things better.

  • Hi,

    I'm not sure that I'm understanding your question correctly, but I think you're asking about general code structure.

    For your own sanity it is always a good idea to think carefully about where you put the different elements of your code. It is a lot easier to add a header file to main.c to include your service, than to put an extra 1000 lines of code in there alongside your initialization code.

    The reason many of the examples will include services in the main.c file is that these are small services, and it is arguably easier to see what is going on if everything is in the same place. You are however right, for a larger project you will want to keep them separate.

    Best regards,

    Øyvind

Related