Buffered ADC samples, transmit on app request.,

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
ksrgopinath
Offline
Last seen:4 years 5 months ago
加入:2016-12-10 08:01
Buffered ADC samples, transmit on app request.,

Dear Support,

I am working on DA14580 Basic kit.SO far I have been working on the ble_app_perpheral project. I was able to send ADC data on request from light-blue IOS app.
We have a requirement for setting up a timer to take adc value for every 5 min and storing in a buffer of fixed length 12. The The idea is at every given point of time we will have ADC samples for last 60 min spread at 5 min interval.

Can you please point me a similar example so that I can start looking and achieve this. Alternatively, if I were to do this without any example code, can you point me which file should I start with?.

This is what we want.
1.Set up a timer to trigger ADC measurement for 5 min.
2. Take ADC measurement
3.Update buffer
4.MILD Sleep but keep timer going.
All these has to happen with/without the mobile app being connected.
5.IF app requests for data, the device has to send all the buffered packets.

Please help me.
Cheers,
Sri.

Keywords:
Device:
JK_Dialog
Offline
Last seen:3 months 3 weeks ago
工作人员
加入:2016-08-22 23:07
Hi Sri,

Hi Sri,

希望I can help point you in the right direction:

1) Setting up a timer - a timer can be set up using: timer_hnd app_easy_timer( const uint16_t delay, timer_callback fn);

我们幸运的例子(包括外围的例子you are using) starts one of these timers on connection

2) ADC measurement - it seems that you have already figured out how to do this. However, there is document that helps wiht the ADC functionality UM-B-004 and also an example the peripheral examples of the SDK

3) Please use any ble example - if this is a standard profile you can include this in your user_profiles_config.h, if it is not, please use a custom profile. The ble examples and documentation should direct you properly (Tutorial 4: Building a custom profile)

4) The timers can run in sleep mode. In user_config.h, set app_default_sleep_mode = ARCH_EXT_SLEEP_ON

5) This logic should be worked out based on a standard profile or a custom profile. Create a characteristic that has the 'write' property (as in the ble examples).

ksrgopinath
Offline
Last seen:4 years 5 months ago
加入:2016-12-10 08:01
Thanks for your quick reply,

Thanks for your quick reply,

This cleared some of the grey area I have. One quick question where do I set up timer_hnd app_easy_timer( const uint16_t delay, timer_callback fn); ? in arch_main file @ while(1) ?

JK_Dialog
Offline
Last seen:3 months 3 weeks ago
工作人员
加入:2016-08-22 23:07
Is SDK 5.0.4, it is advised

Is SDK 5.0.4, it is advised to not write code in the app_main file. The SDK has is built on the principal of using the 'user' space: user_config, user_custom_profile, user_platform, user_app are typical folder structures you would use in your application.

This creates an event driven application. In user_callback_config, you can point the sdk to your handlers for certain events or use default handlers. I'll give three examples:

1) If you wanted to start the timer on a connection event - in user_callback_config.h -> user_app_callbacks , you place the pointer to a user function here, say user_app_connection. Create your prototype in a header file. Now the SDK will call this function during a connection event. In your 'user function' you could start the timer.

2) If you wanted to create the timer on initilization, you could start this from the main loop, by setting up a similar pointer as above in user_callback_config.h -> .app_on_init.

3) If you wanted to start from a write of a custom characterstic, you would catch this from a catch_rest_hndlr (app_process_catch_rest_cb) in user_callback_config.h. To 'catch' this write, this is illustrated in the ble examples (in particular, ble_peripheral) with the user_catch_rest_handl.

I hope this clarifies things.

//Jon

ksrgopinath
Offline
Last seen:4 years 5 months ago
加入:2016-12-10 08:01
Thank you,

Thank you,
Will try this out and come back to you.

ksrgopinath
Offline
Last seen:4 years 5 months ago
加入:2016-12-10 08:01
Dear JK_Dialog,

Dear JK_Dialog,

Thank you so much for your help. I could able to get this working. Thanks a lot for your help.

Sri.

MT_dialog
Offline
Last seen:1 year 1 week ago
工作人员
加入:2015-06-08 11:34
Hi ksrgopinath,

Hi ksrgopinath,

If you found the above answer helpful, please hit the Accept answer option in order to verify the answer.

Thanks MT_dialog