Best way to stream data using serial port service

11 posts / 0 new
Last post
JBaczuk
Offline
Last seen:1 year 3 months ago
加入:2014-12-31 23:41
Best way to stream data using serial port service

I've gone through the code for the serial port service, and since it is set up with pointers that are shared between UART and SPS, I'm not sure the best way to send data from the app to a mobile device. For example, I'd like to send ASCII values from sensors periodically, but what is the best way to do this using the example code, should I be allocating my own pointers in memory and then calling app_uart_push()? Maybe a couple lines example code would help. Thanks!

Keywords:
Device:
MHv_Dialog
Offline
Last seen:2 months 6 days ago
工作人员
加入:2013-12-06 15:10
Hi,

Hi,

我建议实现一个自定义服务sensor data. Your sensor data is, as far as I understand, discreet data sets that gets transmitted periodically. The app notehttp://support.dialog-semiconductor.com/download/file/fid/885covers how to construct your own custom service in a step by step tutorial. The app note also describes how to set up notification allowing for a device to send data to a smrartphone whenever data changes. DSPS is using the same basic methods (Notifications over GATT), and is a great candidate for systems that require streaming data at very high data rates, but it is not the best candidate for periodic transmissions of disceret data packages. Using a custom service also makes it much easire to implement the smartphone side of the application.

JBaczuk
Offline
Last seen:1 year 3 months ago
加入:2014-12-31 23:41
Ok, I will take a look. Yes,

Ok, I will take a look. Yes, you are correct they will be very small, periodic data sets, so high data streaming is not required.

Elvis1991
Offline
Last seen:1 month 2 weeks ago
加入:2014-12-09 08:18
Dear JBaczuk,

Dear JBaczuk,
newbie's question. Do you know where can find the data input from keyboard in SPS project? I notice that uart_rx_callback() can realize the function and its definition showed below

****************************************************************************************
* @brief receive callback function will handle incoming uart data
*
* @param[in] res (status: UART_STATUS_OK, UART_STATUS_ERROR, UART_STATUS_TIMEOUT)
*
* @return没有
****************************************************************************************
*/

static void uart_rx_callback(uint8_t res, uint32_t read_size)
{
//function called from uart receive isr
if(res == UART_STATUS_OK)
{
app_uart_push(rx_read_pointer, RX_CALLBACK_SIZE, rx_state_ptr);
}

//function called from uart timeout isr
else if(res == UART_STATUS_TIMEOUT)
{
app_uart_push(rx_read_pointer, read_size, rx_state_ptr);
}
else
{
while(1); //error: callback called from unknown source
}

//reinitiate callback
uart_sps_read(rx_read_pointer, RX_CALLBACK_SIZE, &rx_state_ptr, &uart_rx_callback);

I traced the uart_sps_read() in uart_rx_callback() and its definition is:
void uart_sps_read(uint8_t *bufptr, uint32_t size, uint8_t *state, void (*callback) (uint8_t, uint32_t))
{
// Sanity check
ASSERT_ERR(bufptr != NULL);
ASSERT_ERR(size != 0);
ASSERT_ERR(uart_sps_env.rx.bufptr == NULL);

// Prepare RX parameters
uart_sps_env.rx.size = size;
uart_sps_env.rx.bufptr = bufptr;
uart_sps_env.rx.state = state;
uart_sps_env.rx.callback = callback;

// Start data transaction
uart_rec_data_avail_setf(1); //=SetBits16(UART_IER_DLH_REG, ETBEI_dlh0, 1);
}

I did not find any input from keyboard..
Since I want to revise this project,using very small, periodic data sets that generate by MCU to replace the data input from keyboard.. (Just generate a signal to simulate the real data), I need to know where the data read by UART..

Could you please give me some hints.? Thanks a lot!

NRenney
Offline
Last seen:2 years 9 months ago
加入:2017-06-26 15:44
If this question could be

If this question could be answered it would be helpful for the project I am working on now.

JBaczuk
Offline
Last seen:1 year 3 months ago
加入:2014-12-31 23:41
Are you talking about the

Are you talking about the keyboard data before it is sent over BLE or after? This might be a better question for Dialog as I haven't spent much time with the SPS, I created a custom profile instead for my application.

NRenney
Offline
Last seen:2 years 9 months ago
加入:2017-06-26 15:44
Sorry man meant to direct

Sorry man meant to direct this more to Dialog. I've started a topic of my own considering a had a lot more questions for them!
And yeah I was just wondering where the keyboard data was received in the code as I couldn't find it in their example, not something we directly need in the project but something I was curious about.

MT_dialog
Offline
Last seen:3 weeks 3 days ago
工作人员
加入:2015-06-08 11:34
Hi NRenney,

Hi NRenney,

If i understand the question properly, since apparently there is a bit of a mix up. You would like to know where the data that are received from the UART in the DSPS are stored ? The data received from the UART are placed in the periph_to_ble_buffer Ring buffer (at the address pointing the data_ptr member).

Thanks MT_dialog

BlueSDK18
Offline
Last seen:2 years 8 months ago
加入:2018-02-13 11:25
Hi JBaczuk,

Hi JBaczuk,

The resource link for the application note cannot be found!
Do you know the name of the relevant application note?
That would help me a lot!

Thanks in advance.

BlueSDK18

MT_dialog
Offline
Last seen:3 weeks 3 days ago
工作人员
加入:2015-06-08 11:34
Hi BlueSDK18,

Hi BlueSDK18,

I suppose that you are interested in having a demo that will send data using notification to a central, in that case the ble_app_peripheral is allready demonstrating that, just write a 0x01 to the control point characteristic and enable the notifications on the ADC 1 value in order to start getting data. Also there a is a tutorial in the "Tutorials" section Building custom profiles that will help you on customising the allready existing custom profiles. The link that you are refering to its quite old and the document that links to most probably is obsolete and removed from the support site.

Thanks MT_dialog

BlueSDK18
Offline
Last seen:2 years 8 months ago
加入:2018-02-13 11:25
Hi MT_Dialog,

Hi MT_Dialog,

Thanks for your reply on my question!
The answer is what I need to know.

BlueSDK18