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

sending Schnittstelle (String etc) through ble instead uart?

Hi,

I want send a Data such as string or array, for that i took a look example ble_app_uart from the example we send a data from smartphone through ble but the microcontroller send it to pc via UART  my question is, is it possible to send string direct via ble? i'v read it in another post that we can create our own custom gatt service, can we send such an order via custom service?

because at the end i want to send an order to my device if i need to use uart there must be a long wire connected to my device.

Parents
  • Hi,

    Yes, please take a look at our UART/Serial Port Emulation over BLE example. 

  • hi vidar, yes i tried it but i still need the uart cable to read the message that send to the board

    or i rephrase my question, is it possible send a schnittstelle via custon gatt and get feedback from the board which i can read on terminal i smartphone? like example i send 1 to the board and get feedback like 'Hello' that the board send via ble?

    thanks for your respond

Reply
  • hi vidar, yes i tried it but i still need the uart cable to read the message that send to the board

    or i rephrase my question, is it possible send a schnittstelle via custon gatt and get feedback from the board which i can read on terminal i smartphone? like example i send 1 to the board and get feedback like 'Hello' that the board send via ble?

    thanks for your respond

Children
  • Yes, it shouldn't be a problem. But you need to modify the example code. The documentation I linked to in my previous answer shows where received data is handled, and where the UART data is passed through to BLE. 

  • Hi thanks for your respond but i'm having a hard time finding where the received data stored.

    my idea is using a switch case, example if i send '1' from a phone i want the board gives me 'Hello',

    other microcontroller that i used to work with has a variable or memory called sbuff where all the received data stored in.

    do we have such a variable so i can easily used for my switch case?

    best regard and happy new year

    Andhika

  • Hi Andhika,

    p_evt->params.rx_data.p_data inside nus_data_handler() points to the data buffer where the BLE message is stored.

  • Hi Vidar,

    thanks for your respond yeah i found it, and i tried to  rewrite it in main in the main loop but it doesn't work, is it safe to write my switch case in nus_data_handler instead? because i considering the existence of interrupt in the function.

  • Hi Andhika,

    It's ok to parse/interpret the command input inside the nus_data_handler(), it doesn't require much processing so the ISR will still be short. Other time-consuming or potentially blocking operations can be moved to the main loop.