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

Best way for save project

Hi,

I would like to save my project and add something like a version number to it. I use an example from nordic SDK. So in my case I use solution from ...\examples\ble_peripheral\ble_app_uart.

If I press "save all" in SES, only main.c is saved.

But I modify also files such as ble_nus.c, which is saved in folder ...\components\ble\ble_services\ble_nus

Is it possible, to create a folder with all "used and customized files" (.c and .h) in it?

  • simon1516 said:

    My opinion is, that I then have a very small project folder with just my needed files in it and not a big folder with every libraries from SKD in it.

    Isn´t that the normal way for developing?

    The normal (at least from what I've seen) and the easiest way of creating a project with the nRF5 SDK is to do it from within the SDK. E.g. inside <..>\examples\ble_peripheral. This is because all the paths in the example projects are relative from the location they are placed.

    Then you can run git init from e.g. <..>\examples\ble_peripheral\my_ble_project, upload my_ble_project to Github, and you can share it with other people. The folder/repo my_ble_project will also contain all your custom libraries. Then they can easily test it, by downloading the appropriate SDK and place it correctly within it.

    What are your main reasons for building it outside the SDK? The end result will not be any different (the compiler will only include the software that is actually being used by the project), and there are no practical differences except for the location of the project and all the paths it's using.

    Are your reason due to preference, and that it is a cleaner approach?

    If you would still like to build it outside the SDK I can help you with that.

    Best regards,

    Simon

  • The folder/repo my_ble_project will also contain all your custom libraries.

    Can you explain me that? I can´t see such folder when I create a copy of example project in  <..>\examples\ble_peripheral\my_ble_project


    However, to your question. One approach is is to put your custom libraries inside e.g. examples\ble_peripheral\ble_app_uart

    If I for example customize a few libraries (e.g.  <..>\components\ble\ble_services\ble_nus). Where should i save the copy? And where do I have to change the path to it?

    It´s okay for me, developing in the SDK environment, but maybe it´s neccessary to seperate the modified files. For example if I would like to upload the project with all modified files. How can I extract them?

    Is there a way, to delete unused .h and .c files from project? There are much included .h files in one project. I don´t know if I need them all.

  • simon1516 said:
    Can you explain me that? I can´t see such folder when I create a copy of example project in  <..>\examples\ble_peripheral\my_ble_project

    The folder my_ble_project was just an imaginary folder I made up, e.g. you copy the folder examples\ble_peripheral\ble_app_uart, rename it to e.g. examples\ble_peripheral\my_ble_project, and modify it according to your needs.

    The reason you don't see any other .c/.h files in the default projects in the SDK is that nearly all drivers and libraries (source (.c) and header files (.h)) they're using are already present in the SDK. There are some exceptions, like the examples\ble_peripheral\ble_app_gatts_c example, which has created some custom files for that project (app_adv.c, app_adv.h and app_bsp.c). 

    simon1516 said:
    If I for example customize a few libraries (e.g.  <..>\components\ble\ble_services\ble_nus). Where should i save the copy? And where do I have to change the path to it?
    simon1516 said:
    It´s okay for me, developing in the SDK environment, but maybe it´s neccessary to seperate the modified files. For example if I would like to upload the project with all modified files. How can I extract them?

    While writing this, a "better" approach all the sudden popped into my head. Jump down to the arrows (⇒⇒⇒⇒⇒⇒) to go straight to it. Pick the approach that suits you best.

    You could rename folder components\ble\ble_services\ble_nus and it's subfiles and copy it into e.g. examples\ble_peripheral\my_ble_project. It will then look like this:

    Then you have to add #include "ble_nus_modified/ble_nus.h" to main.c in addition to adding examples\ble_peripheral\ble_app_uart\ble_nus_modified to the path's and the file examples\ble_peripheral\ble_app_uart\ble_nus_modified\ble_nus_modified.c in Project Explorer (https://www.youtube.com/watch?v=t-kh1EbesvI). It might be easier to add the files right into examples\ble_peripheral\my_ble_project since it is in the same folder as main.c and don't you don't need to add the path and the source file.

    Remember to remove all references to ble_nus.c and ble_nus.h in your project, so there won't be any collisions.

    Now your project is very portable, and you can upload examples\ble_peripheral\ble_app_uart\ble_nus_modified to e.g. GitHub and other people can easily test your project without modifying the SDK itself.

    ⇒⇒⇒⇒⇒⇒

    Another approach I just thought about, which actually allows you to modify the libraries directly, is to run git init inside e.g. nRF5_SDK_16.0.0_98a08e2, then create a branch my_ble_project_branch which is only intended to be used with your project (jump back to master when building other projects in the SDK). 

    Then you can modify the files you want, create a patch file, and you can simply share the patch files, which only includes the changes instead of the whole SDK and people can easily test your project by running git apply inside a fresh nRF5_SDK_16.0.0_98a08e2.

     

    simon1516 said:
    Is there a way, to delete unused .h and .c files from project? There are much included .h files in one project. I don´t know if I need them all.

    If there are header (.h) files included at the top of main.c in a default project, you should not delete it, since all of the .h files are included for a reason. Functions or variables or both from the included header files will be used somewhere in the project. However, if you remove all the functions/variables from the project, declared in a specific header file, you can remove the header file as well as the associated .c file. I don't think you should worry too much about unused .h and .c since the compiler will only include stuff that is actually used. Don't take my words for this, as I'm not an expert in compilers. There may be exceptions.

    If you are referring to all the source files in the Project Explorer window or all the included paths. This will not affect the size of the project unless it is used in the actual project. Like in main.c, or indirectly by functions called in main.c.

    Best regards,

    Simon

Related