From 34ad38d34a9c88f6562a5dc54bf6d8ad7fed23de Mon Sep 17 00:00:00 2001 From: anschrammh Date: Wed, 5 Apr 2023 08:03:58 +0200 Subject: [PATCH] Started to write the module used to interact/communicate with the gadget bridge Android app. The API will contain functions to send data to the app as well as a parser used to decode and extract data sent from the app. It will internally use/access the NUS BLE service exposed by the ble_service.c file --- app/ble/gadget_bridge.c | 11 ++++++ app/ble/gadget_bridge.h | 76 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 app/ble/gadget_bridge.c create mode 100644 app/ble/gadget_bridge.h diff --git a/app/ble/gadget_bridge.c b/app/ble/gadget_bridge.c new file mode 100644 index 0000000..9f50236 --- /dev/null +++ b/app/ble/gadget_bridge.c @@ -0,0 +1,11 @@ +/** + * @file gadget_bridge.c + * @author Anatole SCHRAMM-HENRY + * @brief Source file implementing the API used to communicate/interact with the GadgetBridge Android application + * over BLE. + * @version 0.1 + * @date 2023-04-05 + * + * @copyright Copyright (c) 2023 + * + */ \ No newline at end of file diff --git a/app/ble/gadget_bridge.h b/app/ble/gadget_bridge.h new file mode 100644 index 0000000..74d37e5 --- /dev/null +++ b/app/ble/gadget_bridge.h @@ -0,0 +1,76 @@ +/** + * @file gadget_bridge.h + * @author Anatole SCHRAMM-HENRY + * @brief Header file exposing the API used to communicate/interact with the GadgetBridge Android application + * over BLE. + * @version 0.1 + * @date 2023-04-04 + * + * @copyright MIT + * + */ + +#ifndef GADGET_BRIDGE_H +#define GADGET_BRIDGE_H + +#include "wm_type_def.h" + +typedef enum +{ + GADGET_BRIDGE_TOAST_TYPE_INFO = 0, + GADGET_BRIDGE_TOAST_TYPE_WARN, + GADGET_BRIDGE_TOAST_TYPE_ERROR, +} GADGET_BRIDGE_TOAST_TYPE_e; + +typedef enum +{ + GADGET_BRIDGE_MUSIC_CONTROL_PLAY = 0, + GADGET_BRIDGE_MUSIC_CONTROL_PAUSE, + GADGET_BRIDGE_MUSIC_CONTROL_PLAYPAUSE, + GADGET_BRIDGE_MUSIC_CONTROL_NEXT, + GADGET_BRIDGE_MUSIC_CONTROL_PREVIOUS, + GADGET_BRIDGE_MUSIC_CONTROL_VOLUMEUP, + GADGET_BRIDGE_MUSIC_CONTROL_VOLUMEDOWN, + GADGET_BRIDGE_MUSIC_CONTROL_FORWARD, + GADGET_BRIDGE_MUSIC_CONTROL_REWIND, +} GADGET_BRIDGE_MUSIC_CONTROL_e; + +typedef enum +{ + GADGET_BRIDGE_CALL_ACTION_ACCEPT = 0, + GADGET_BRIDGE_CALL_ACTION_END, + GADGET_BRIDGE_CALL_ACTION_INCOMING, + GADGET_BRIDGE_CALL_ACTION_OUTGOING, + GADGET_BRIDGE_CALL_ACTION_REJECT, + GADGET_BRIDGE_CALL_ACTION_START, + GADGET_BRIDGE_CALL_ACTION_IGNORE, +} GADGET_BRIDGE_CALL_ACTION_e; + +typedef enum +{ + GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS = 0, + GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS_ALL, + GADGET_BRIDGE_NOTIFICATION_ACTION_OPEN, + GADGET_BRIDGE_NOTIFICATION_ACTION_MUTE, + GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY, +} GADGET_BRIDGE_NOTIFICATION_ACTION_e; + +bool gadget_bridge_send_toast(GADGET_BRIDGE_TOAST_TYPE_e toast_type, const char *message); + +bool gadget_bridge_send_firmware_version(const char *fw1, const char *fw2); + +bool gadget_bridge_send_battery_status(uint8_t battery_level_in_percent, float battery_level_in_mV, bool is_charging); + +bool gadget_bridge_send_find_phone(bool find_phone); + +bool gadget_bridge_send_music_control(GADGET_BRIDGE_MUSIC_CONTROL_e music_control); + +bool gadget_bridge_handle_call(GADGET_BRIDGE_CALL_ACTION_e call_action); + +bool gadget_bridge_handle_notification(GADGET_BRIDGE_NOTIFICATION_ACTION_e notification_action, uint64_t handle, const char *phone_number, const char *message); + +bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_count); + +bool gadget_bridge_send_http_request(); + +#endif //GADGET_BRIDGE_H \ No newline at end of file