Finished to define the API, started to implement some of it
This commit is contained in:
parent
34ad38d34a
commit
74b90f9fee
@ -8,4 +8,41 @@
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "gadget_bridge.h"
|
||||
#include <string.h>
|
||||
#include "ble_service.h"
|
||||
|
||||
/* Internal function definition */
|
||||
const char *_gadget_bridge_toast_type_2_str(gadget_bridge_toast_type_e toast_type);
|
||||
|
||||
bool gadget_bridge_send_toast(gadget_bridge_toast_type_e toast_type, const char *message)
|
||||
{
|
||||
if(!message || !strlen(message))
|
||||
return true;
|
||||
|
||||
bool to_return = true;
|
||||
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"", 6);
|
||||
to_return &= ble_service_send_nus_data((const uint8_t *)_gadget_bridge_toast_type_2_str(toast_type), strlen(_gadget_bridge_toast_type_2_str(toast_type)));
|
||||
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"msg\",\"", 9);
|
||||
to_return &= ble_service_send_nus_data((const uint8_t *)message, strlen(message));
|
||||
to_return &= ble_service_send_nus_data((const uint8_t *)"\"}\n", 3);
|
||||
|
||||
return to_return;
|
||||
}
|
||||
|
||||
/* Internal function declaration */
|
||||
const char *_gadget_bridge_toast_type_2_str(gadget_bridge_toast_type_e toast_type)
|
||||
{
|
||||
switch(toast_type)
|
||||
{
|
||||
case GADGET_BRIDGE_TOAST_TYPE_ERROR:
|
||||
return "error";
|
||||
case GADGET_BRIDGE_TOAST_TYPE_WARN:
|
||||
return "warn";
|
||||
case GADGET_BRIDGE_TOAST_TYPE_INFO:
|
||||
default:
|
||||
return "info";
|
||||
}
|
||||
}
|
@ -15,14 +15,14 @@
|
||||
|
||||
#include "wm_type_def.h"
|
||||
|
||||
typedef enum
|
||||
typedef enum gadget_bridge_toast_type
|
||||
{
|
||||
GADGET_BRIDGE_TOAST_TYPE_INFO = 0,
|
||||
GADGET_BRIDGE_TOAST_TYPE_WARN,
|
||||
GADGET_BRIDGE_TOAST_TYPE_ERROR,
|
||||
} GADGET_BRIDGE_TOAST_TYPE_e;
|
||||
} gadget_bridge_toast_type_e;
|
||||
|
||||
typedef enum
|
||||
typedef enum gadget_bridge_music_control
|
||||
{
|
||||
GADGET_BRIDGE_MUSIC_CONTROL_PLAY = 0,
|
||||
GADGET_BRIDGE_MUSIC_CONTROL_PAUSE,
|
||||
@ -33,9 +33,9 @@ typedef enum
|
||||
GADGET_BRIDGE_MUSIC_CONTROL_VOLUMEDOWN,
|
||||
GADGET_BRIDGE_MUSIC_CONTROL_FORWARD,
|
||||
GADGET_BRIDGE_MUSIC_CONTROL_REWIND,
|
||||
} GADGET_BRIDGE_MUSIC_CONTROL_e;
|
||||
} gadget_bridge_music_control_e;
|
||||
|
||||
typedef enum
|
||||
typedef enum gadget_bridge_call_action
|
||||
{
|
||||
GADGET_BRIDGE_CALL_ACTION_ACCEPT = 0,
|
||||
GADGET_BRIDGE_CALL_ACTION_END,
|
||||
@ -44,18 +44,35 @@ typedef enum
|
||||
GADGET_BRIDGE_CALL_ACTION_REJECT,
|
||||
GADGET_BRIDGE_CALL_ACTION_START,
|
||||
GADGET_BRIDGE_CALL_ACTION_IGNORE,
|
||||
} GADGET_BRIDGE_CALL_ACTION_e;
|
||||
} gadget_bridge_call_action_e;
|
||||
|
||||
typedef enum
|
||||
typedef enum gadget_bridge_notification_action
|
||||
{
|
||||
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;
|
||||
} gadget_bridge_notification_action_e;
|
||||
|
||||
bool gadget_bridge_send_toast(GADGET_BRIDGE_TOAST_TYPE_e toast_type, const char *message);
|
||||
typedef enum gadget_bridge_http_request_method
|
||||
{
|
||||
GADGET_BRIDGE_HTTP_REQUEST_GET = 0,
|
||||
GADGET_BRIDGE_HTTP_REQUEST_POST,
|
||||
GADGET_BRIDGE_HTTP_REQUEST_HEAD,
|
||||
GADGET_BRIDGE_HTTP_REQUEST_PUT,
|
||||
GADGET_BRIDGE_HTTP_REQUEST_PATCH,
|
||||
GADGET_BRIDGE_HTTP_REQUEST_DELETE,
|
||||
|
||||
} gadget_bridge_http_request_method_e;
|
||||
|
||||
typedef struct http_header
|
||||
{
|
||||
const char *key;
|
||||
const char *value;
|
||||
} http_header_t;
|
||||
|
||||
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);
|
||||
|
||||
@ -63,14 +80,14 @@ bool gadget_bridge_send_battery_status(uint8_t battery_level_in_percent, float b
|
||||
|
||||
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_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_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_handle_notification(gadget_bridge_call_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();
|
||||
bool gadget_bridge_send_http_request(uint32_t id, const char *url, gadget_bridge_http_request_method_e http_request_method, const char *http_body, const http_header_t *http_headers);
|
||||
|
||||
#endif //GADGET_BRIDGE_H
|
Loading…
Reference in New Issue
Block a user