ble connection

how can i create  communicate between by ble connection between two modules securely da14531evz i want to use one gpio with button  on one module and second module with led and i want when i press button on first module  and led will glow on second module

Parents Reply Children
  • I have connected both central and peripheral when connection 
    i want to button press on the central device triggers an LED to glow on the peripheral device via Bluetooth Low Energy (BLE) please give me example

  • firmware in first module :-    ble-sdk6-examples-main\ble-sdk6-examples-main\connectivity\central
    what i have to change or send value to my peripheral for glow led on module in my central firmware

  • Hi Mani,

    Thank you for the replies.
    On the peripheral side you should have a custom Characteristic and change the value.
    The central device should read this characteristic and depending on the value it has read it should open or close the LED.
    Please refer on DA1453x / DA1458x Tutorial Create a Custom GATT Profile — DA145XX Tutorial Create a Custom GATT Profile

    Best Regards,
    OV_Renesas

  • I think you don't understand my question

    I don't want to use app I'm creating communication between two  modules so   I'm  want to control led  on one module from second module I want to use one gpio as button on Central ble example and led on my peripheral example module 

    For this wht I have to. Changes in firmware.

    I have enabled  gpio as button on Central and gpio led on peripheral 

    No wht I have to change in firmware please give me proper example or code 

     Or suggest me wht example  of firmware from SDK  for this type of communication 

  • Hi Mani,

    Thank you for the reply.
    I have understood your question. 
    For Button press and interrupt please refer here: 
    ble-sdk6-examples/interfaces/simple_button at main · renesas/ble-sdk6-examples
    The above example implementation for GPIO button interrupt can work only in Active mode without any Sleep mode enabled.
    The best approach would be to follow the GPIO button press implementation from here:
    ble-sdk6-examples/interfaces/wakeup-button/src/user_wakeup.c at main · renesas/ble-sdk6-examples
    You will use the Wake up controller driver to configure a GPIO as a button.
    When the button is pressed, it will trigger the callback function you had declared via the wkupct_register_callback API.
    Inside that callback you will need to use the following API to Write on a specific Characteristic on the Peripheral side:

    /**
     ****************************************************************************************
     * @brief Perform a gatt write
     * @param[in] con_idx - connection identifier
     * @param[in] handle - attribute handle to write 
     * @param[in] data - data to write
     * @param[in] data_len - data len
     * @return void
     ****************************************************************************************
     */
    void user_ble_gatt_write(uint8_t op, uint8_t con_idx, uint16_t handle, uint8_t *data, uint16_t data_len)
    {
    	struct gattc_write_cmd *cmd  = KE_MSG_ALLOC_DYN(GATTC_WRITE_CMD,
    																									 KE_BUILD_ID(TASK_GATTC, con_idx),
    																									 TASK_APP,
    																									 gattc_write_cmd,
    																									 sizeof(struct gattc_write_cmd) + data_len);
    
    	cmd->operation = op;
    	cmd->auto_execute = 1;
    	cmd->seq_num = 0;
    	cmd->offset = 0;
    	cmd->length = data_len;
    	cmd->cursor = 0;
    	cmd->handle = handle;
    	memcpy(&cmd->value[0], data, data_len);
    
    	ke_msg_send(cmd);
    	
    }
    

    On the peripheral side this will trigger the CUSTS1_VAL_WRITE_IND handler for this characteristic inside the user_catch_rest_hndl function.
    For instance from the ble_app_peripheral example:
    void user_catch_rest_hndl(ke_msg_id_t const msgid,
                              void const *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
    {
        switch(msgid)
        {
            case CUSTS1_VAL_WRITE_IND:
            {
                struct custs1_val_write_ind const *msg_param = (struct custs1_val_write_ind const *)(param);
    
                switch (msg_param->handle)
                {
                    case SVC1_IDX_CONTROL_POINT_VAL:
                        user_svc1_ctrl_wr_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_LED_STATE_VAL:
                        user_svc1_led_wr_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_ADC_VAL_1_NTF_CFG:
                        user_svc1_adc_val_1_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_BUTTON_STATE_NTF_CFG:
                        user_svc1_button_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_INDICATEABLE_IND_CFG:
                        user_svc1_long_val_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_LONG_VALUE_NTF_CFG:
                        user_svc1_long_val_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    case SVC1_IDX_LONG_VALUE_VAL:
                        user_svc1_long_val_wr_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    
                    default:
                        break;
                }
            } break;

    For instance, let's say that you wrote on the SVC1_IDX_LED_STATE_VAL characteristic. Then the user_svc1_led_wr_ind_handler function will be executed in the user_custs1_impl.c file.
    void user_svc1_led_wr_ind_handler(ke_msg_id_t const msgid,
                                         struct custs1_val_write_ind const *param,
                                         ke_task_id_t const dest_id,
                                         ke_task_id_t const src_id)
    {
        uint8_t val = 0;
        memcpy(&val, &param->value[0], param->length);
    
        if (val == CUSTS1_LED_ON)
        {
            GPIO_SetActive(GPIO_LED_PORT, GPIO_LED_PIN);
        }
        else if (val == CUSTS1_LED_OFF)
        {
            GPIO_SetInactive(GPIO_LED_PORT, GPIO_LED_PIN);
        }
    }
    

    It depends on the value that you have written in order to turn ON/OFF the LED.

    Best Regards,
    OV_Renesas


  • firmware in first module :-    ble-sdk6-examples-main\ble-sdk6-examples-main\connectivity\central

    in this firmware what i have to putt in  this user_ble_gatt_write in my central firmware 


    to change state of led on my peripheral side please can u provide me central example code which will be completable with this(  DA145xx_SDK\6.0.22.1401\projects\target_apps\ble_examples\ble_app_peripheral)
     firmware 


    please provide me firmware  for my central so when i change value of variable  led state will change in my peripheral module


  • please provide me firmware  for my central so when i change value of variable  led state will change in my peripheral module

  • hie please can u provide me firmware for central or tell me in which  function  i have to change for connection and how to make custom characteristics in central example