Regarding receiving epoch value

I have a doubt regarding receiving characteristics from peripheral to my central. I want to get two characteristics from my peripheral first one is an ADC value the next is its timestamp (as epoch) both are different characteristics in my peripheral Iam able to receive ADC value but not getting the epoch

Where's the Arduino code?

we are using a custom board. And I'm posting the code of characteristic created. And how I'm trying to send the value.



static const uint8_t SVC1_IDX_EPOCH_RETURN_UUID_128[ATT_UUID_128_LEN]   = DEF_SVC1_EPOCH_RETURN_128;


  //epoch value return
    [SVC1_IDX_EPOCH_RETURN_CHAR]        = {(uint8_t*)&att_decl_char, ATT_UUID_16_LEN, PERM(RD, ENABLE), 0, 0, NULL},


    // Read 1 Characteristic Value
                                                       DEF_SVC1_EPOCH_RETURN_CHAR_LEN, 0, NULL},


    // Read 1 Client Characteristic Configuration Descriptor
                                               sizeof(uint16_t), 0, NULL},


   // Read 1 Characteristic User Description
   [SVC1_IDX_EPOCH_RETURN_USER_DESC]    = {(uint8_t*)&att_desc_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE),
                                               sizeof( DEF_SVC1_EPOCH_RETURN_USER_DESC) - 1, sizeof( DEF_SVC1_EPOCH_RETURN_USER_DESC) - 1,
                                               (uint8_t *)  DEF_SVC1_EPOCH_RETURN_USER_DESC},

uint64_t epoch_time_RETURN = rtc_to_epoch(&time_data);
struct custs1_val_ntf_ind_req *req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ,prf_get_task_from_id(TASK_ID_CUSTS1),TASK_APP,
// Provide the attribute index.
req->handle = SVC1_IDX_EPOCH_RETURN_VAL;
// Force current length to zero.
req->notification = true;
// Copy value
memcpy(req->value, &epoch_time_RETURN,DEF_SVC1_EPOCH_RETURN_CHAR_LEN);
// Send message

Sorry, just noticed this:

You can't store components in TinyDB.

You can store the .Text value of the component.

If you want to collect the values over time, start a list as empty and store it in TinyDB.

As new values arrive, retrieve the list from TinyDB, add the incoming value(s) to it, and put the list back into TinyDB.

thanks for the reply, can you explain is this the correct way of code for receiving the epoch time to our app both epoch and ADC are two different characteristics

Please understand that I am a novice at BLE, though I have read many threads where people solved BLE problems and curated some BLE FAQs based on this board's BLE expert posts.

I have also not ever actually used a BLE device in AI2.

Before going further, I have seen people helped along in their development using this diagnostic app:

It is by a BLE manufacturer, so no pesky ads or ulterior motives, and there's support by a real vendor.

Given that, here are my concerns with your code.

  • Your BLE_operations procedure starts scanning and sets BLE_connected false, yet you call it in the BLE BytesReceived event. I would imagine once you have received bytes, you would have no more need to go scanning for devices, assuming you are just dealing with a single device. Such a procedure might be called from Screen1.Initialize, just once.

  • you do not show what that epoch procedure does.

  • Looking at your C (?) code, I am guessing the epoch is a uint64 (Unsigned 64 bit integer.) You are receiving bytes (uint8) and Integers (uint32) because that's what you registered for, so there will need to be some type conversion to build that 64 bit epoch value from the incoming byte list or integer list (I don't know which one will bring the epoch.)

  • Understand that the incoming intValues and byteValues will be lists, so you should be testing for list length as you reconstruct the epoch value from the input stream. This is a good place to try that nRFConnect app to see how many bytes/integers arrive.

  • In case you have not encountered it yet, there might some permissions that need to be granted to the app. Here's some general purpose advice on that:

(Canned Reply ABG - BLE FAQ with Latest Versions for Permissions)

yeah, thanks for the reply and also can you assist me with how can we implement scrolling graph in ADC as we receive the values from peripheral device.(using BLE)

This is an example of a scrolling graph driven by a Clock Timer and a random number generator:

(from FAQ Section: Charts and Graphs)

The basic idea is to check the number of graph entries each time you add a new entry, and once you pass the minimum number you want to keep, remove the oldest.

For BLE, instead of a Clock Timer you would drive this by the Received event(s) for your ADC data, in a FOR EACH loop to traverse the incoming list of ADC readings.

hi thanks for the reply,so i tried out by using this code

but what my requirement is my device is sending ADC value every one minute so I need the graph plot only at that instant and my device wakes up from sleep after one minute and send the next ADC value then the graph needs to plot that particular point instead Iam getting continuous plotting from the first value to the next value which is not good to see
can you assist me with correct method

HI could you consider my question

Sorry, I am not coversant in long sleep intervals in apps. Maybe others can help?