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

many n00b questions about NAN-36 example project

Hi Developers,

I'm using an nRF51822 and finally beginning to understand BLE. I want to learn by example so I downloaded NAN-36.

Im at a point where the Application Note is a bit vague and I need some help:

  1. 4.3.1 step 1: Do I need to replace BLE_BAS with BLE_LBS or is ble_lbs also fine?

  2. 4.3.1 step 1: Do I need to replace p_bas with p_lbs also in the .h file?

  3.   4.3.1 step 2:     Where do I need te place the methods in the code?
    
  4.    4.3.2                 Can I safely delete everything in the init struct and replace it?
    
  5. 4.3.2 What do I need to do with "The signature used for this function" ?

  6. 4.3.2 Where can I find "The battery service event declarations in the ble_lbs.h file", is it?void ble_lbs_on_ble_evt(ble_lbs_t * p_bas, ble_evt_t * p_ble_evt);

  7.    4.3.3.1               I can't find evt_handler in the service struct, where is it?
    
  8.  4.3.3.1                            My generated Base-UUID doesn't look like the 16 hex numbers in de example. it looks      like this: C11Cxxxx-C1AD-13CD-06FC-C9BEF61C942E. how is this possible?
    
  9. 4.3.3.1                  step 3:  Where do I put the code snippet for the empty service?
    
  10.    4.3.3.2    step 2:  Do they mean the if-statement just below:       " // Add Battery Level characteristic" ?
    
  11. 4.3.3.2                              Where do I paste the security macro code snippet on page 20?
    
  12.  4.3.3.2                             How do I memset a structure?
    
  13. 4.3.3.2                              Where do I paste the second code snippet on page 20?
    
  14.  4.3.3.2                             "The initial value is not important, so you can pass a NULL for the p_initial_value", What value? Where? 
    
  15.      4.3.3.2                         I put the #Endif in the header file, wasn't that the purpose? 
    

As expected with this questions: Compiling was a disaster. This BLE looks way out of my legue right now. I don't understand the simpelest instruction in de NAN-36. I included my .h file and .c files.

ble_lbs.c

ble_lbs.h

Parents
    1. As the document says, you should only need to replace the lower letters. These are only names, so please see what the defines are used for and decide for your self.

    2. Yes, do that. lbs (LED BLE service I presume) and bas (battery service) are just names, but for better structure and readability change them.

    3. The prototypes in an .h file, presumably ble_bas.h (formarly ble_lbs.h). This is quite standard for whatever project you are working on. Function prototypes in the header files so that other files can reach them, the function implementation in a .c-file. Do whatever suits you the best.

    4. Yes. Look at the resulting code.

    5. Read up on function pointers. It is used to pass a function as a parameter in another function call. I know this is hard to get your first grasp on, but you need to follow the code and see where and how it is used.

    6. Look at the implementation of the function in the .c file. By the name: what to do on an event on the LED Battery Service

    7. Its the write handler. The event is a write.

    8. Where do you read it in that format?

    9. As it says, in the service initialization.

    10. "Remove the if-sentence checking the is_notification_supportedparameter, but leave the code inside. ", this is really self-explanatory.

    11. We are still in the init, read some examples and you will see where they are used.

    12. memset(&_your_struct, 0, sizeof(_your_struct)); // That is shown in the NAN.

    13. char_md.char_props.read   = 1;
      

      char_md.char_props.write = 1; char_md.p_char_user_desc = NULL; char_md.p_char_pf = NULL; char_md.p_user_desc_md = NULL; char_md.p_cccd_md = NULL; char_md.p_sccd_md = NULL;

    // <<<---- HERE --->>> ble_uuid.type = p_lbs->uuid_type; ble_uuid.uuid = LBS_UUID_LED_CHAR

    1. hmm, dunno :\ Don't worry about it.

    2. Yepp.

    I myself is a beginner of BLE, and know this can be quite hard to grasp if you don't have much experience with programming C. A lot of your questions could be answered if you look at similiar projects and trying to understand the flow of it. You should also get a good understanding on where to place different set of codes (.h/.c) and the use of structures.

    Also, the compiling errors you are getting; please do some more changes to your code and paste the errors you don't understand in your question.

  • Thanks to you I got it compiling (and some help of another intern).

    I am currently at 4.3.4 and I think the hard part is over.

    about Question 8: The conversion to an array of bytes of the UUID confused me. nRFgo-Studio generates a random UUID that looks like this: 006Fxxxx-68C4-CAD2-2181-DDAC760BE6A3

    it needs to be converted to look like this: {0x24, 0x8F, 0x00, 0x00, 0xBF, 0xA2, 0x69, 0x8B, 0x15, 0x58, 0x73, 0xA6, 0x82, 0x8A, 0x4A, 0x1D} The xxxx in the UUID I assumed where 0000 so the 3rd and 4th hex is 0x00.

    about question 12: What confused me there was the use of the verb "Memset", I Memset, He Memsets, We are Memsetting

    Thank you again very much for your endless dedication of answering my questions.

Reply
  • Thanks to you I got it compiling (and some help of another intern).

    I am currently at 4.3.4 and I think the hard part is over.

    about Question 8: The conversion to an array of bytes of the UUID confused me. nRFgo-Studio generates a random UUID that looks like this: 006Fxxxx-68C4-CAD2-2181-DDAC760BE6A3

    it needs to be converted to look like this: {0x24, 0x8F, 0x00, 0x00, 0xBF, 0xA2, 0x69, 0x8B, 0x15, 0x58, 0x73, 0xA6, 0x82, 0x8A, 0x4A, 0x1D} The xxxx in the UUID I assumed where 0000 so the 3rd and 4th hex is 0x00.

    about question 12: What confused me there was the use of the verb "Memset", I Memset, He Memsets, We are Memsetting

    Thank you again very much for your endless dedication of answering my questions.

Children
No Data
Related