This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP432P401R: SAP/SNP - Modifying Advertising Interval

Part Number: MSP432P401R
Other Parts Discussed in Thread: CC2640R2F, ENERGYTRACE

Tool/software: Code Composer Studio

Hi all,

I am using the MSP432P401R and the CC2640R2F Launchpads in a Simple Application Processor/Simple Network Processor pair.

My issue is that I am unable to change the advertising interval on the SAP side to 1 sec (1600=1000ms)Steps I have taken:

Changed DEFAULT_ADVERTISING_INTERVAL in application_processor.h to 1600. This did not work as it does in standalone cc2640r2f applications because DEFAULT_ADVERTISING_INTERVAL is never used in the SAP application.

I also tried to update the advertising interval using SAP_setParam. However, this did not work either. 

uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
SAP_setParam(SAP_PARAM_ADV, SAP_GEN_DISC_ADV_INT_MIN, sizeof(advInt), (uint8_t *) advInt);
SAP_setParam(SAP_PARAM_ADV, SAP_GEN_DISC_ADV_INT_MAX, sizeof(advInt), (uint8_t *) advInt);


  • Hi Casey,

    Could you try changing the DEFAULT_ADVERTISING_INTERVAL in simple_np_gap.c in the simple_np example?


    Best Regards,
    Alec

  • Thank you for your response Alec. 

    I modified the Simple_np project and changed the default advertisment interval but it still appears that it hasnt changed.

    This is the power plot from energytrace. every 100ms is a pulse. I would expect this to be every second.

    -Casey

  • Hi Casey,

    As a quick debugging exercise, could you try disabling advertising entirely in the simple_np project and check to see that these pulses go away? The easiest way to do it would be by modifying the lines where you do the following, and make sure advertEnabled is false.

    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertEnabled);

    Let me know what results you see after testing this, and we can work from there.

    Best Regards,
    Alec

  • Hi Alec,

    Thank you for your response. I followed your instructions and disabled advertising. Here is what energytrace shows now.

  • To clarify, I modified this in the application processor firmware on the MSP432 not the cc2640R2F.

  • Casey,

    Awesome, good to see. Additionally, where did you place the SAP_setParam calls you mentioned earlier? I do not currently have the hardware to set up a SAP+SNP due to the WFH situation, so unfortunately this may take a bit of back and forth between us.

    Best Regards,

    Alec

  • Alec,

    This was placed in AP_RESET case in the simple_application_processor project. I just checked the response from the SAP_setParam function and noticed it is returning 0x83, indicating an error... Below is the AP_RESET case:

    case AP_RESET:
                    /* Make sure CC26xx is not in BSL */
                    GPIO_write(Board_RESET, Board_LED_OFF);
                    GPIO_write(Board_MRDY, Board_LED_ON);
    
                    usleep(10000);
    
                    GPIO_write(Board_RESET, Board_LED_ON);
    
                    /* Initialize UART port parameters within SAP parameters */
                    SAP_initParams(SAP_PORT_REMOTE_UART, &sapParams);
    
                    sapParams.port.remote.mrdyPinID = Board_MRDY;
                    sapParams.port.remote.srdyPinID = Board_SRDY;
                    sapParams.port.remote.boardID = Board_UART1;
    
                    /* Setup NP module */
                    SAP_open(&sapParams);
    
                    /* Set Advertising Interval. */
                    uint8_t stat;
                    stat = SAP_setParam(SAP_PARAM_ADV, SAP_GEN_DISC_ADV_INT_MIN, sizeof(advInt), (uint8_t *) &advInt);
                    stat = SAP_setParam(SAP_PARAM_ADV, SAP_GEN_DISC_ADV_INT_MAX, sizeof(advInt), (uint8_t *) &advInt);
    
                    /* Register Application thread's callback to receive
                         asynchronous requests from the NP. */
                    SAP_setAsyncCB(AP_asyncCB);
    
                    /* Reset the NP, and await a power-up indication.
                       Clear any pending power indications received prior to this
                       reset call */
                    clock_gettime(CLOCK_REALTIME, &ts);
                    ts.tv_sec += 1;
    
                    mq_timedreceive(apQueueRec, (void*) &curEvent, sizeof(uint32_t),
                                    &prio, &ts);
    
                    SAP_reset();
    
                    do
                    {
                        curEvent = 0;
                        mq_receive(apQueueRec, (void*) &curEvent, sizeof(uint32_t), &prio);
    
                        if (curEvent != AP_EVT_PUI)
                        {
                            //Display_printf(displayOut, 0, 0,
                            //               "[bleThread] Warning! Unexpected Event %lu",
                            //               curEvent);
                        }
                    }
                    while (curEvent != AP_EVT_PUI);
    
                    if (curEvent == AP_EVT_PUI)
                    {
                        /* Read BD ADDR */
                        SAP_setParam(SAP_PARAM_HCI, SNP_HCI_OPCODE_READ_BDADDR, 0,
                                        NULL);
    
                        /* Setup Services - Service creation is blocking so
                         * no need to pend */
                        AP_initServices();
    
                        state = AP_IDLE;
                    }
                    break;
                
                case AP_START_ADV:

  • Casey,

    Okay, that error indicates that the SNP rejected the command for some reason. Could you try moving those lines into the AP_START_ADV section, shortly before enabling advertising? It's possible that the SNP isn't ready for adv commands by the time you are sending them. 

    Best Regards,
    Alec

  • Alec,

    Im still receiving the 0x83 error, after moving this right before enabling the advertising... Is the format of the command look correct?

    I modeled it off of this command: SAP_setParam(SAP_PARAM_CONN, SAP_CONN_STATE, sizeof(connHandle), (uint8_t *) &connHandle);

    -Casey

     

  • Casey,

    I dug into it a bit, and SAP_setParam has 4 behaviors defined for SAP_ADV_PARAMS, none of which are especially helpful to you. I looked, and inside the SAP_setParam(SAP_PARAM_ADV, SAP_ADV_STATE, 1, &enableAdv); they have the interval hardcoded to 160. So if you go into sap.c and look for the line lReq.interval = 160; If you change this value, and then verify that you are building the local copy of SAP.c, that should resolve your issue.

    Best Regards,
    Alec

  • Alec,

    Thank you for the information. It does look like that value being hardcoded is the issue. I changed this from 160 to 1600 but as you were saying I think I need to include the local copy of SAP.c for the changes to have an affect. How do ensure I am building the local copy of the .c file?

    Thank you,

    Casey

  • Casey,

    One of the easiest ways to determine if that local version is the one being built is to just comment out a variable and see if it throws a build error. If it's not using that local copy, you'll want to mess with the include options such that it includes your local version rather than the original. If you can't get that working, a last resort is just recreating that function in the application source file to give you the granular control over it.

    Let me know how it goes.

    Best Regards,
    Alec

  • Alec,

    As you mentioned, changing the sap.c source file has no affect on the program. I commented out several variables and the program still built without issues.

    This sap.c file is in the msp432 ble sdk. Is there a way to include the entire sdk locally? Or do I need to drag it into the project explorer?

    Thank you,

    Casey

  • Hi Casey,

    In my version, I see sap.c included in the folder ti/sap in the local project directory, so you would likely want to change it there. Let me know if your version is different.

    Best Regards,
    Alec

  • Alec,

    Mine is in the same directory. If I navigate to the includes folder I can see the ble sdk. From there the sap.c file is in ti/sap. I think this is what you see as well. However, changing the interval has no effect on the advertisement interval.

    Thank you,

    Casey gross

  • Casey,

    Okay, I believe I have it all worked out. I can't say for 100% certainty since I do not have access to a MSP432P4 currently, but in my CCS environment it appears to be working. Below were the steps I followed.

    1. Make a "ti" folder in your local project in CCS

    2. Make a "sap" folder in that ti folder

    3. Copy all the .c and .h files from {ble_plugin_location}/source/ti/sap to that new folder in your ccs

    4. Go to project properties -> build -> arm compiler -> include options and bump ${PROJECT_ROOT} to the top
    5. Modify sap.c as needed

    Try this out and let me know what you find.

    Best Regards,
    Alec