How to notify when I push the button?

2 posts / 0 new
Last post
okmegi
Offline
Last seen:3 years 11 months ago
Joined:2016-03-04 06:18
How to notify when I push the button?

Hi, I'm developing a device in Korea.

I'm using the DA14580 Development Kit - Pro.
I developed the device based on "SDK5, ble_app_peripheral example"

My device needs the function that the device sends(or notifies) the value to the smart phone "when I push the button".
The value is updated by "app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY, app_adcval1_timer_cb_handler)"
Isn't it? (If you see the example, 'user_custs1_impl.c' , you can get it)

And I add the button source code to use it at the

user_periph_setup.c ----> RESERVE_GPIO( PUSH_BUTTON, GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, PID_GPIO);
user_periph_setup.c ----> GPIO_ConfigurePin(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, INPUT_PULLUP, PID_GPIO, false );

user_periph_setup.h ---->
#define GPIO_BUTTON_PORT GPIO_PORT_1
#define GPIO_BUTTON_PIN GPIO_PIN_1

user_custs1_impl.c ---->
void app_adcval1_timer_cb_handler()
{
..
...
if (!GPIO_GetPinStatus( GPIO_BUTTON_PORT, GPIO_BUTTON_PIN )) // When the button is pushed, send a message(=notify)
{
ke_msg_send(req);
}
}
This function use "CUSTS1_VAL_NTF_REQ : Set/update characteristic value and trigger a notification"

Did you catch my thinking?

It worked well before I changed the "APP_PERIPHERAL_CTRL_TIMER_DELAY".

I need "APP_PERIPHERAL_CTRL_TIMER_DELAY = 1" instead of "100"(<--default value)
Because the device needs to read the value sampled from ADC very very quickly (ASAP)

I changed the DELAY value '1' instead of '100' and executed the program on the DK board, and then I connected it using smart phone.
When I wrote '01' at the "control point value", The system was halted.

The debugger pointed here.

/**
****************************************************************************************
* @brief Wrapper of the platform reset. It will be invoked before a software reset
* is issued from the stack. Possible reasons will be included in the error field
* @param[in] error The reason for the reset. It will be one of:
*RESET_NO_ERROR,RESET_MEM_ALLOC_FAIL,RESET_TO_ROM,RESET_AND_LOAD_FW
* @return Returns nothing.
****************************************************************************************
*/
void wrap_platform_reset(uint32_t error)
{
ASSERT_WARNING(error==RESET_AFTER_SPOTA_UPDATE); //do not break in case of a SPOTA reset
platform_reset_func(error);
}

当我使用“APP_PERIPHERAL_CTRL_TIMER_DELAY =50" it worked well.
当我使用“APP_PERIPHERAL_CTRL_TIMER_DELAY =30" it worked not well.
When I pushed the button, sometimes the system was halted. T_T...

I need a fastest ADC sampling value, and I want to notify the value when I pushed the button.

How can I send the sampled value when I push the button?
Please help me !

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi okmegi,

Hi okmegi,

This happens because you generate more messages that you can consume, so your heap fills up and the platform_reset gets invoked. If i understand correctly you would like every time you press the button your device to start sending data to the client via a timer. Try to change (decrease) your connection interval in order for the notification messages to be consumed frequently.

Thanks MT_dialog

Topic locked