problems with forwarding read rssi values to the wifi module through serial port

Hello. I am using nrf52832 for Ble-based positioning. currently i am tackling with establishment of an anchor measuring rssi values and sending them to a central center (a PC) through an additional wifi module. i am sending data from nrf52832 to the wifi module through serial (UART) connection. to this end, i combined a simple UART example with a blincky-c example of nrf5sdk. doing so, i receive a couple of rssi values and then the transmission to pc stocks. i tried chaning the priority of the UART transmission from lowest to highest and it seems to work. i wonder to know whether my job was ok or this change of priority may cause other problems...

Moreover, i have tried combining the libuarte example to the ble central blincky which is expected to handle my above problem, but it did not work (send data on serial) due to an unkown reason. 

best regards, 

Parents Reply Children
  • i am using pins 6 and 8 as tx and rx respectively. i handle it inside the scan_evt_handler function:

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
    ret_code_t err_code;
    char cip_cmd[32];
    char rssi_msg[32];
    char rssi_msg2[64];

    switch(p_scan_evt->scan_evt_id)
    {
    case NRF_BLE_SCAN_EVT_FILTER_MATCH:
    {
    nrf_gpio_pin_set(CUSTOM_PIN);

    ble_gap_evt_adv_report_t const * p_adv_report = p_scan_evt->params.filter_match.p_adv_report;

    //ble_gap_addr_t addr1= p_adv_report->peer_addr;
    NRF_LOG_INFO("Beacon detected! Address: %02X:%02X:%02X:%02X:%02X:%02X",
    p_adv_report->peer_addr.addr[0],
    p_adv_report->peer_addr.addr[1],
    p_adv_report->peer_addr.addr[2],
    p_adv_report->peer_addr.addr[3],
    p_adv_report->peer_addr.addr[4],
    p_adv_report->peer_addr.addr[5]);
    NRF_LOG_INFO("signal recieved from bluetooth channel: %d " ,p_adv_report->ch_index);
    NRF_LOG_INFO("its RSSI is: %d dBm" ,p_adv_report->rssi);


    //uart_send("HelloESP01\r\n");
    //nrf_delay_ms(100);
    int8_t rssi = p_adv_report->rssi;

    snprintf(rssi_msg, sizeof(rssi_msg), "RSSI: %d dBm\r\n", rssi);
    int len =strlen(rssi_msg);

    snprintf(rssi_msg2, sizeof(rssi_msg2), "Beacon Address: %02X:%02X:%02X:%02X:%02X:%02X",
    p_adv_report->peer_addr.addr[0],
    p_adv_report->peer_addr.addr[1],
    p_adv_report->peer_addr.addr[2],
    p_adv_report->peer_addr.addr[3],
    p_adv_report->peer_addr.addr[4],
    p_adv_report->peer_addr.addr[5]);
    int len2 =strlen(rssi_msg2);

    snprintf(cip_cmd, sizeof(cip_cmd), "AT+CIPSEND=%d\r\n", len+len2);


    uart_send(cip_cmd);
    nrf_delay_ms(40);
    uart_send(rssi_msg2);
    nrf_delay_ms(40);
    uart_send(rssi_msg);
    nrf_delay_ms(40);

    }
    break;

    case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
    err_code = p_scan_evt->params.connecting_err.err_code;
    APP_ERROR_CHECK(err_code);
    break;
    default:
    break;
    }
    }

    and this is my "main" function if needed:

    int main(void)
    {
    // Initialize.
    nrf_gpio_cfg_output(CUSTOM_PIN);
    nrf_gpio_pin_clear(CUSTOM_PIN);
    log_init();
    timer_init();
    leds_init();
    buttons_init();
    power_management_init();
    ble_stack_init();

    gatt_init();
    db_discovery_init();
    lbs_c_init();

    // Start execution.
    NRF_LOG_INFO("Blinky CENTRAL example started.");

    uart_init();
    // Turn on the LED to signal scanning.
    bsp_board_led_on(CENTRAL_SCANNING_LED);
    char td[][6]= {{0xD5, 0x2A, 0x9D, 0x99, 0xE3, 0xDA},{0xD2, 0xE8, 0x6B, 0x15, 0xD0, 0xD6}};

    //uart_send("HelloESP01\r\n");
    nrf_delay_ms(3000);

    uart_send("AT\r\n");
    nrf_delay_ms(2000);
    uart_send("AT+CIPSTART=\"TCP\",\"192.168.182.50\",8888\r\n");
    nrf_delay_ms(7000);

    uart_send("AT+CIPSEND=10\r\n");
    nrf_delay_ms(100);
    uart_send("HelloESP01\r\n");
    nrf_delay_ms(100);

    // Enter main loop.
    for (;;)
    {
    scan_init(td[0]);
    scan_start();

    //gatt_init();
    //db_discovery_init();
    idle_state_handle();
    scan_init(td[1]);
    scan_start();

    //gatt_init();
    //db_discovery_init();
    idle_state_handle();

    }
    }

Related