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

Adapting ble_app_blinky_c to work with nRF52840 Dongle

Using this \nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_blinky and nRF5_SDK_17.0.2_d674dde\examples\ble_central\ble_app_blinky_c

As described in \examples\ble_central\ble_app_blinky_c 

I am using win 10, VS Code and a Dongle!!!

The \examples\ble_peripheral\ble_app_blinky works fine and I can use the Android app BlinkyTest to flash the dongle (using nrfutil, not nrfjprog) to test it and it works ok, so I assume I have a working toolchain.

Basically I want to make one dongle (the server, aka ble_app_blinky) turn the light on and off on the other dongle (the client akak ble_app_blinky_c)  (and for the server to recognise that a button was pressed on the client dongle). At least that is how I read the documentation says it should work.

I realise that I will have to make adjustments to at least main.c to re-assign the leds and buttons, but first I need to get the thing to build.

Because you don't have a dongle version of the examples\ble_central\ble_app_blinky_c I am trying to adapt it to work with the dongle pca10059. To do this I have copied over the code from the pca10056 folder. I have adjusted the Makefile and c_cpp_properties.json which tells the compiler where to look for the include files. (I am a bit of a noob with C, but I'm getting there).

So my first problem is that I am getting problems with intellisense telling me that in main.c


90  NRF_BLE_SCAN_DEF(m_scan);
and some other stuff isn't defined.        
So if I go to the definition I locate nrf_ble_scan.h   I have referenced this in my include files
However, at about line 137 I am getting a strange error where it is saying it doesn't like a "const"!!!
typedef struct
{
    ble_gap_scan_params_t const * p_scan_param;    
And at this point I'm stuck.
I'm assuming that ble_gap_scan_params_t
 is defined somewhere, but the IDE is telling me that it is defined in 17 out of 20 files. I'm thinking I'm on a lost trail here.
Any ideas please.
By the way any thoughts on what else I might need to look at (like removing any Segger stuff) that I should consider?
Of course the ideal solution for me would be for Nordic to provide an actual version for the dongle!!!!! I mean, you sell it after all Slight smile
Thanks
Gordon.

  • Well, would you believe it. I went and built it anyway just for a laugh and it compiled with no errors, so I flashed it and man it works. 

    However, I'd still like to know what is causing the red squiggle problems! 

  • Okay, so I'm trying to track down these errors which to my understanding are possibly down to header files not being found. A main one was to make sure that sdk_config.h was referenced. Bit I think it was already. BTW I am open to the suggestion that the VS Code intellisense may be at fault here???

    Anyhow, let's look at one that is odd: If I can solve this one then a majority of errors disappear and should be straightforward:

    In main.c it is reported that 

    function "LOCAL_ERR_CODE" may not be initialized  (line 146)

    line 146 

        APP_ERROR_CHECK(err_code);
    So I right click and look at the definition: it's in app_error.h   (Can I assume that if VS Code can find the definition then it's in the include path?)
    Then after a time while the intellisense scans I get
    a function type is not allowed here (line 82)
    And here is the kicker.
    typedef struct
    {
        uint32_t        line_num;    /**< The line number where the error occurred. */
        uint8_t const * p_file_name; /**< The file in which the error occurred. */
        uint32_t        err_code;    /**< The error code representing the error that occurred. */
    error_info_t;
    line_num and err_code have squiggles under them? I mean they are just variable names, aren't they? They aren't functions? Are they?
    The file has a <stdint.h> include, so I can't see it being uint32_t
    The only other message apart from duplicates of above is
    identifier "NRF_BLE_GQ_DATAPOOL_ELEMENT_SIZE" is undefined
    Yet it is defined in sdk_config.h and I added that to my include list as an absolute path to make sure.
    Anyone got any ideas?
  • Oooh that's interesting. If I change uint32_t to uint8_t the error goes away!!! Now what could possibly be wrong with uint32_t - that's pretty fundamental isn't it? <stdint.h>

    Actually if I right click the uint32_t and "Goto definition" it doesn't go anywhere, however the uint8_t goes to C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major\arm-none-eabi\include\sys\_stdint.h - note the underscore _stdint.h. Mind this doesn't define uint32_t or any other unint anyway.

    I have no idea why the code is structured this way????

  • I think the uint32_t error may be a distraction. I turned them to uint16_t temporarily that got rid of that squiggle, but the error in main.c is still there:

    function "LOCAL_ERR_CODE" may not be initialized

    So I'm off hunting for this.

  • So I went and checked the ble_blinky app that is set up for the dongle and now I see that there were problems with that code in main.c as well that I'd never noticed. So there must be something wrong with my VS Code setup. I have no idea what. This is driving me nuts! Disappointed   Yet it builds and runs!!!!

    For example in main.c pn the ble_blinky, similar to ble_blinky_c

Related