This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

S120 softdevice, ble_app_hrs_c how to exit from scan_start() to main

main.cI'm using S120 softdevice with nrf51822, I want to use S120 as central and peripheral devices. When I received my beacon data then switch to peripheral for advertise. When I got received beacon data from on_ble_evt then want to exit to main then run advertise. How to exit from scan_start() to main? I suceed to run central and peripheral device using S120 separately.

  • right now I put S130 softdevice to nRF51822 chip then run examples "ble_app_hrs_c_s130_pca10028" and "ble_app_beacon_s130_pca10028" then successfully work separately. how can I switch over both central and peripheral?

  • Using the S130 and S120 should be very similar. The main difference is that the S120 can't be peripheral and central at the same time. So where you get beacon's RSSI, peer address and UUID should be implemented very similarly, if not equal to the way you have done with S120.

    With S130 you don't need to switch, just start advertising after you have started scanning, if you only want to advertise stop scanning first.

    I will not make sample code for this. It doesn't seem to me that you have actually tried yourself. If you have, please include what exactly isn't working, where you are stuck, and I will try to help you.

    You don't need to "switch", just do them both at the same time.

  • I have modified examples "ble_app_hrs_c_s130_pca10028" and add code for advertise and test it. I added advertise command to scan_start() and it works fine but one problem is that after advertise, it's system_reset and send one character only to UART port. is there any missing command? I don't know how to attach code here so I put my added code here.

    Added code in scan_start();

        err_code = sd_ble_gap_scan_start(&m_scan_param);
        APP_ERROR_CHECK(err_code);
    
    //yoo added to check return
    		if(beacon_ready==1)
    		{
    			//yoo
    			//start ch='-', 0x2D
    			printf("-");
    			for(uint8_t i=0;i<32;i++)
    			{
    				printf("%c",beacon_buffer[i]);
    			}
    			printf("\r");	// end ch=0x0D
    			beacon_ready=0;
    
    			
    //yoo added here for Beacon Transmit once
        advertising_init();
        // Start execution.
        advertising_start();
    //yoo end
    
  • I have attached main.c file into my question.

  • If you get a reset APP_ERROR_CHECK() is probably called with an error somewhere, you need to figure out from where. See this for more information.

Related