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

nRFGO services.c files with nRF8001 Arduino SDK

Hi, I have been using the nRF8001 Arduino SDK with nRF8001 chip. I wanted to set the data for the different services I'm using and thought I would go ahead and use the services.c file generated by nRFGO Studio. But the file that nRFGO Studio generates (and I have the latest 1.16.1 version) won't work with the Arduino SDK. The function calls in services.c to lib_aci.h functions are wrong. Is there any version of nRFGO Studio that could be used to generate a working services.c file?

  • Hi,

    For the Arduino SDK there is a .bat file in the example project folders, you should use one of these to generate the Service.c file. By default the service files are generated with some functions that we do not want/need for the Aduino SDK, so we added several generating options for the studio to support both the new and the old SDK.

    To generate the service file: "%NRFGOSTUDIOPATH%\nrfgostudio.exe" -nrf8001 -g UART_over_BLE.xml -codeGenVersion 1 -o

    Best regards,

  • Hello Runar, I tried running nrfgostudio using the bat file as you suggest. If I use codeGenVersion 1 as you show I only get a services.h file. And I have been using that services.h with my Arduino SDK code for a few months now. But I am adding code to set up other things like Device Information. And rather than writing my own functions to send data to the nRF8001 I thought I would use the functions that nrfstudio can generate and store in a services.c file when you use the codeGenVersion 2 option. But the problem is, the code in the services.c file does not work with the Arduino SDK. And there is no nrfgostudio option I could find to fix it. An example of the problems is that calls to lib_aci_set_local_data() need an aci_state pointer in the Arduino SDK version but not the non Arduino SDK version.

    For now I have renamed services.c to services.cpp (so that things like the bool variables work), added a function that can be called to pass in a pointer to the aci_state structure, and changed the function calls that require an aci_state pointer to have them. I can get the services code to compile and work that way.

    Is there some undocumented option to nrfgostudio to really generate a services.cpp file that would work with the Arduino SDK?

  • I’m sorry; nRFgo studio do not have an option to generate a services.cpp file for Arduino. We moved away from the services_update_pipes interface when working with the Arduino SDK as we didn’t really need it after we added a proper command queue.

  • We recommend that only the services.h generated with the nRFgo studio be used with the nRF8001 for new designs.

  • Runar & Star Destroyer, Thank you for your answers. I understand that the Arduino version of the ACI library uses a circular queue to allow multiple nRF8001 commands to be saved on the local processor and sent out only as the radio is ready to handle more commands. That is good but does not replace the old services_update_pipes interface in applications like mine that support multiple services between my device and the remote device. Even with simple devices and few services the queue approach will often have problems. The reason is that you can only make the queue so big in the hal_aci_tl.cpp file in the BLE library directory. Each queue entry takes 30-40 bytes so large queues can take a lot of bytes. And the default queue size as delivered is only 2 buffers. And once the queue is full with commands waiting to be sent all later commands fail until the radio accepts more data and the queue empties some.

    I notice your examples seem to assume commands will always be accepted and queued up. But I have found that in real use things can "get dropped on the floor" because of full queue conditions. I need reliable operation in my application so can't allow commands to silently disappear. What I liked about the services.c implementation of sending data is that it allowed things to be saved until they could be sent successfully and made it explicit with the "is_freshest" flags how you wanted overrun conditions handled. I edited the services.c file that nRFGO Studio generates to work with the Arduino version of lib_aci and think I will use it for my application. Maybe others can make the hal_aci_tl command queue big enough to never have data get dropped. Or maybe their applications can handle dropped data. But for me I think the mix of the queue's and services.c approach is best.

    I would think it would be nice to add another format option to nRFGO Studio so it could generate a services.c (well, actually, services.cpp) file that could work with the Arduino SDK. It wouldn't take many changes to the code generator. And then people could have a choice of how they wanted to handle their communication with the nRF8001. But that is just my suggestion. I will stick with my hand edited file for now so this issue could be closed I guess.

Related