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

how to send mac address as characteristic value?

hello! i want to send mac address of my bluetooth device. i have written function

uint32_t get_address(void)
{
    uint32_t err_code;
    ble_gap_addr_t  ble_gap_addr;
    memset(&ble_gap_addr, 0, sizeof(ble_gap_addr));
    ble_gap_addr.addr_type= BLE_GAP_ADDR_TYPE_PUBLIC;
    err_code = sd_ble_gap_address_get(&ble_gap_addr);
    return(err_code);
}

but i can't store data into array. can you help me?

Parents
  • hello i declared ble_gap_addr outside function and write function as below

    uint8_t get_address(void)
    {
        uint8_t err_code;
        memset(&ble_gap_addr, 0, sizeof(ble_gap_addr));
        ble_gap_addr.addr_type= BLE_GAP_ADDR_TYPE_RANDOM_STATIC;//BLE_GAP_ADDR_TYPE_PUBLIC;
        err_code = sd_ble_gap_address_get(&ble_gap_addr);
        return(err_code);
    } 
    

    and then i write main code as below

    int main(void)
    { 
        uint32_t err_code;
        uint8_t		char2_data[CHARACTERISTIC_SIZE];
        uint8_t i=0;
        // Initialize
        timers_init();
        ble_stack_init();
        scheduler_init();
        gap_params_init();
        advertising_init();
        conn_params_init();
        sec_params_init();
    
        // Start execution
        advertising_start();
        get_address();
        services_init();
    
     while(1)
     {
            char2_data[8] = get_address();//{0x10,0x20,};
            err_code = custom_service_update_data(m_conn_handle,char2_data);
            APP_ERROR_CHECK(err_code);
            app_sched_execute();
            power_manage();
        }
    }
    

    but in master control panel i am getting like this

    AttributeHandleschanged Value:BD-9D-01-00-A8-2C-00-20-00-00-00-00-ED-84-01
    

    can you tell me what should i return?

Reply
  • hello i declared ble_gap_addr outside function and write function as below

    uint8_t get_address(void)
    {
        uint8_t err_code;
        memset(&ble_gap_addr, 0, sizeof(ble_gap_addr));
        ble_gap_addr.addr_type= BLE_GAP_ADDR_TYPE_RANDOM_STATIC;//BLE_GAP_ADDR_TYPE_PUBLIC;
        err_code = sd_ble_gap_address_get(&ble_gap_addr);
        return(err_code);
    } 
    

    and then i write main code as below

    int main(void)
    { 
        uint32_t err_code;
        uint8_t		char2_data[CHARACTERISTIC_SIZE];
        uint8_t i=0;
        // Initialize
        timers_init();
        ble_stack_init();
        scheduler_init();
        gap_params_init();
        advertising_init();
        conn_params_init();
        sec_params_init();
    
        // Start execution
        advertising_start();
        get_address();
        services_init();
    
     while(1)
     {
            char2_data[8] = get_address();//{0x10,0x20,};
            err_code = custom_service_update_data(m_conn_handle,char2_data);
            APP_ERROR_CHECK(err_code);
            app_sched_execute();
            power_manage();
        }
    }
    

    but in master control panel i am getting like this

    AttributeHandleschanged Value:BD-9D-01-00-A8-2C-00-20-00-00-00-00-ED-84-01
    

    can you tell me what should i return?

Children
No Data
Related