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

Hi , is there any example code to send the data directly from nrf5_SDK through BLE to app..??

can anyone please say..??

  • int main(void) { bool erase_bonds; // uint16_t err_code; static char PrintBuffer[40] = {0}; uint16_t length = 0 ; uint16_t counter = 0; uint32_t err_code;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();
    
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    printf("\r\nUART Start!\r\n");
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    
    // Enter main loop.
    for (;;)
    {
        memset(PrintBuffer, 0x00, sizeof(PrintBuffer));
        sprintf(PrintBuffer, "Hello,%d\r\n",counter++);
        length = strlen(PrintBuffer);
        err_code = ble_nus_string_send(&m_nus, PrintBuffer, length);
         APP_ERROR_CHECK(err_code);
        nrf_delay_ms(100);
        power_manage();
    }
    

    }

  • i have tried the following code but it throws an error , when am compiling, am newbie to this platfrom ..can anyone please say..??

  • these are the errors am getting , eventhough i have did the typecasting and all , but it throws the same thing.

    Compiling file: main.c ../../../main.c: In function 'main': ../../../main.c:649:48: error: pointer targets in passing argument 2 of 'ble_nus_string_send' differ in signedness [-Werror=pointer-sign] err_code = ble_nus_string_send(&m_nus, PrintBuffer, length); ^~~~~~~~~~~ In file included from ../../../main.c:35:0: ../../../../../../components/ble/ble_services/ble_nus/ble_nus.h:118:10: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *' uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t length); ^~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ../../../../../../components/toolchain/gcc/Makefile.common:134: recipe for target '_build/nrf52832_xxaa_main.c.o' failed make: *** [_build/nrf52832_xxaa_main.c.o] Error 1

Related