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

S120 Central to RFDuino (S110??)

I am building a Central BLE app using the Rigado BMD-200 but my current peripherals are running RFDuino code. The peripherals all work with the IOS and Android Apps but I cannot get the RFDUINOs to respond to the BLE Central. I CAN connect to the RFDuinos successfully but CANNOT Send them data.

main.c can be viewed here: main.c

I am using the code below on the Central. I started with the HRS code and modified it for my purpose; primarily switching out the UUIDs to the RFDuino ones 0x2220. I believe that my connection handle and characteristic handles are valid. They are 0 and 15 respectively. I am trying to call our to the Peripheral from the hrs_c_evt_handler function by creating a simple function called SendCommndtoDevice(p_hrs_c); Code below:

/
**@brief Heart Rate Collector Handler.
 */
static void hrs_c_evt_handler(ble_hrs_c_t * p_hrs_c, ble_hrs_c_evt_t * p_hrs_c_evt)
{
    uint32_t err_code;

    switch (p_hrs_c_evt->evt_type)
    {
        case BLE_HRS_C_EVT_DISCOVERY_COMPLETE:
            // Initiate bonding.
            err_code = dm_security_setup_req(&m_dm_device_handle);
            APP_ERROR_CHECK(err_code);

            // Heart rate service discovered. Send Soft Button Command

            err_code = SendCommndtoDevice(p_hrs_c);

            //err_code = ble_hrs_c_hrm_notif_enable(p_hrs_c);
            APP_ERROR_CHECK(err_code);

            printf("QIQI-Heart rate service discovered \r\n");
            break;

        case BLE_HRS_C_EVT_HRM_NOTIFICATION:
        {
            APPL_LOG("[APPL]: HR Measurement received %d \r\n", p_hrs_c_evt->params.hrm.hr_value);

            printf("Heart Rate = %d\r\n", p_hrs_c_evt->params.hrm.hr_value);
            break;
        }

        default:
            break;
    }
}

static uint32_t SendCommndtoDevice(ble_hrs_c_t * p_ble_hrs_c)
{
	uint32_t err_code;

	ble_gattc_write_params_t write_params;

	//printf("CCCD Handle = %d, Conn Handle = %d\r\n", handle_cccd, conn_handle);

	printf("Transmit\n");

	memset(&write_params, 0, sizeof(write_params));

	write_params.write_op = BLE_GATT_OP_WRITE_CMD;
	write_params.handle   = p_ble_hrs_c->hrm_cccd_handle;
	write_params.len	  = 0x05;
	write_params.offset   = 0;
	write_params.p_value  = soft_button_cmd;

	err_code =  sd_ble_gattc_write(p_ble_hrs_c->conn_handle, &write_params);
    APP_ERROR_CHECK(err_code);

	//printf("Error: %lu\n", err_code);
    return err_code;
}

The RFDuino never receives the message and err_code = 0 every time. Is the RFDuino compatible with S120, S130?

Any insight would be appreciated.

Parents
  • Hi!

    Where are those p_ble_hrs_c->hrm_cccd_handle set? I have a suspicion that these handles are pointing to the handles in your internal database and not the peer database. That means you might be writing to some handle that does not exist or that reacts differently to writes.

    Are you doing a discovery where you fill out these handles? Try replacing the write commands with a write request, and see what the write response is (either the event or by using any kind of sniffer, e.g. the nRF sniffer)

Reply
  • Hi!

    Where are those p_ble_hrs_c->hrm_cccd_handle set? I have a suspicion that these handles are pointing to the handles in your internal database and not the peer database. That means you might be writing to some handle that does not exist or that reacts differently to writes.

    Are you doing a discovery where you fill out these handles? Try replacing the write commands with a write request, and see what the write response is (either the event or by using any kind of sniffer, e.g. the nRF sniffer)

Children
  • I can confirm that the device connects because in device_manager_event_handler() I get DM_EVT_CONNECTION. From this handler ble_db_discovery_start() is called which I believe finds my peripherals services?? Are these handles from my "internal database"? If so you may be right. If this is the problem, how do I correct this? I have attached main.c to the original post for full context.

    Thank you!

  • static void db_discover_evt_handler(ble_db_discovery_evt_t * p_evt) { // Check if the Heart Rate Service was discovered. if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE && p_evt->params.discovered_db.srv_uuid.uuid == RFD_UUID_SERVICE && p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE) { mp_ble_hrs_c->conn_handle = p_evt->conn_handle;

                        // Find the CCCD Handle of the Heart Rate Measurement characteristic.
                
                        uint32_t i;
                
                        for (i = 0; i < p_evt->params.discovered_db.char_count; i++)
                        {
                	    printf("Char: %x\n", p_evt->params.discovered_db.charateristics[i].characteristic.uuid.uuid); 
                	    nrf_delay_ms(50);
                	
                            if (p_evt->params.discovered_db.charateristics[i].characteristic.uuid.uuid == RFD_UUID_BUTTON_CHAR)
                            {
                                // Found Heart Rate characteristic. Store CCCD handle and break.
                
                                mp_ble_hrs_c->hrm_cccd_handle = p_evt->params.discovered_db.charateristics[i].cccd_handle;
                
                                mp_ble_hrs_c->hrm_handle = p_evt->params.discovered_db.charateristics[i].characteristic.handle_value;
                                break;
                            }
                        }
                
                        ble_hrs_c_evt_t evt;
                
                        evt.evt_type = BLE_HRS_C_EVT_DISCOVERY_COMPLETE;
                
                        mp_ble_hrs_c->evt_handler(mp_ble_hrs_c, &evt);
                    }
    }
    

    The handles are set in this function which is in ble_hrs_c.c, so it seems that these would be the right handles but I am admittedly new on the platform. Thanks i advance for your help!

Related