zephyr-configurator/snippets/bluetooth/button/code1.txt
H4CK3R-01 a75c2d467c
All checks were successful
Build & Publish / build (push) Successful in 8m17s
Added new bluetooth samples
2023-09-08 13:28:04 +02:00

22 lines
498 B
Plaintext

static void button_callback(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins)
{
int err;
LOG_INF("Button pressed");
if (ble_conn) {
if (notify_enable) {
err = bt_gatt_notify(NULL, &stsensor_svc.attrs[4], &but_val, sizeof(but_val));
if (err) {
LOG_ERR("Notify error: %d", err);
} else {
LOG_INF("Send notify ok");
but_val = (but_val == 0) ? 0x100 : 0;
}
} else {
LOG_INF("Notify not enabled");
}
} else {
LOG_INF("BLE not connected");
}
}