I am making some changes to the CodeLess code to fit the application that I need. I have added a read notify characteristic that I would like to use to monitor when the input of one of the GPIO pins goes high and when it goes back to low. I want to use an IRQ to do this but I am not too sure where the best place to add the IRQ in the CodeLess code is. Where would the best place to add this IRQ be?
Thanks,
Anthony
Device:
Hi ant777222,
This depends on your requirements and it application specific. When do you want to enable the IRQ? When advertising or when in connected state? Can you please share more inputs?
Thanks, PM_Dialog
In the connected state.
Hello,
你可以使IRQ in the user_on_connection() callback function which will be triggered upon connection with a peer device.
Thanks, PM_Dialog
While connected I do not know when the GPIO pin will either go high or low. It sounds like user_on_connection() is only triggered upon connection with a peer device. If the transition of an input to a GPIO pin goes from low to high happens at any time while connected I need the IRQ to happen. I was thinking that user_catch_rest_hndl() would work. But I am not positive.
这听起来像是user_on_connection() is only triggered upon initial connection.
Maybe IRQ is not the right thing to do. I just want to monitor the value of a GPIO input and send that value to a characteristic that I made.
Hi ant777222,
Alright, I assume that you have already implemented a custom service with a notifiable characteristic. You should get the GPIO status by using GPIO_GetPinStatus() from the gpio.h library and then transmit the value though notifications. Please check ble_app_peripheral example of the SDK and app_adcval1_timer_cb_handler() function in order to find how to send data over notifications.
Thanks, PM_Dialog