Compare commits

..

No commits in common. "34ad38d34a9c88f6562a5dc54bf6d8ad7fed23de" and "1faa5b3c84decc4c93c15ceca00e8e377c6e4191" have entirely different histories.

4 changed files with 19 additions and 141 deletions

View File

@ -1,11 +0,0 @@
/**
* @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
*
*/

View File

@ -1,76 +0,0 @@
/**
* @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

View File

@ -99,7 +99,7 @@ static void tls_rtc_irq_cb(void *arg)
static void nus_data_rx_cb(const uint8_t *data, uint16_t length) static void nus_data_rx_cb(const uint8_t *data, uint16_t length)
{ {
//shell_printf("%s, received data : "NEW_LINE"#", __FUNCTION__); shell_printf("%s, received data : "NEW_LINE"#", __FUNCTION__);
for (uint16_t i = 0; i < length; i++) for (uint16_t i = 0; i < length; i++)
{ {
@ -108,7 +108,7 @@ static void nus_data_rx_cb(const uint8_t *data, uint16_t length)
else else
shell_putc(data[i]); shell_putc(data[i]);
} }
//shell_puts("#"NEW_LINE); shell_puts("#"NEW_LINE);
} }
int _system(const shell_cmd_t *pcmd, int argc, char *const argv[]) int _system(const shell_cmd_t *pcmd, int argc, char *const argv[])
@ -581,16 +581,20 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
{ {
if(argc > 1) if(argc > 1)
{ {
if(strcmp(argv[1], "enable") == 0 && argc == 4) if(strcmp(argv[1], "enable") == 0)
{ {
bool btOnly = atoi(argv[2]) == 1; if(argc == 3)
bool service = atoi(argv[3]) == 1; {
bool result = ble_modem_on(true);
bool result = ble_modem_on(btOnly, service); shell_printf("Enabling bluetooth modem with ble service : %d"NEW_LINE, result);
shell_printf("Enabling bluetooth : %d with bt only : %d and service : %d"NEW_LINE, result, btOnly, service);
if(result) if(result)
ble_service_register_nus_data_rx_cb(&(nus_data_rx_cb)); ble_service_register_nus_data_rx_cb(&(nus_data_rx_cb));
}
else
{
shell_printf("Enabling bluetooth modem only : %d"NEW_LINE, ble_modem_on(false));
}
} }
else if(strcmp(argv[1], "disable") == 0) else if(strcmp(argv[1], "disable") == 0)
{ {
@ -628,9 +632,9 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
sprintf(cmd, "{\"t\":\"status\",\"bat\":%s,\"chg\":%s,\"volt\":%s} \n", argv[3], argv[4], argv[5]); sprintf(cmd, "{\"t\":\"status\",\"bat\":%s,\"chg\":%s,\"volt\":%s} \n", argv[3], argv[4], argv[5]);
found = true; found = true;
} }
else if(strcmp(argv[2], "find_phone") == 0) else if(strcmp(argv[2], "findPhone") == 0)
{ {
sprintf(cmd, "{\"t\":\"findPhone\",\"n\":%s} \n", argv[3]); strcpy(cmd, "{\"t\":\"findPhone\",\"n\":true} \n");
found = true; found = true;
} }
else if(strcmp(argv[2], "music") == 0) else if(strcmp(argv[2], "music") == 0)
@ -643,11 +647,6 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
sprintf(cmd, "{\"t\":\"notify\",\"n\":\"%s\",\"id\":%s,\"tel\":\"%s\",\"msg\":\"%s\"} \n", argv[3], argv[4], argv[5], argv[6]); sprintf(cmd, "{\"t\":\"notify\",\"n\":\"%s\",\"id\":%s,\"tel\":\"%s\",\"msg\":\"%s\"} \n", argv[3], argv[4], argv[5], argv[6]);
found = true; found = true;
} }
else if(strcmp(argv[2], "act") == 0)
{
sprintf(cmd, "{\"t\":\"act\",\"hrm\":%s,\"stp\":%s} \n", argv[3], argv[4]);
found = true;
}
if(found) if(found)
{ {
@ -655,8 +654,7 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
} }
else else
{ {
shell_printf("Unknown %s action, list of send_ble_notif actions :"NEW_LINE"toast \"msg\""NEW_LINE"bat \"XX%%\" 1|0 X.X"NEW_LINE"find_phone true|false"NEW_LINE"music play|pause|previous|next"NEW_LINE"notify reply|dismiss_all id \"tel\" \"msg\""NEW_LINE shell_printf("Unknown %s action, list of send_ble_notif actions :"NEW_LINE"toast \"msg\""NEW_LINE"bat \"XX%%\" 1|0 X.X"NEW_LINE"findPhone"NEW_LINE"music play|pause|previous|next"NEW_LINE"notify reply|dismiss_all id \"tel\" \"msg\""NEW_LINE, argv[2]);
"act hrm steps"NEW_LINE, argv[2]);
} }
} }
else if(strcmp(argv[1], "up_conn_param") == 0) else if(strcmp(argv[1], "up_conn_param") == 0)

View File

@ -51,6 +51,7 @@ typedef unsigned char INT8U;
#endif #endif
typedef signed char INT8S; typedef signed char INT8S;
//typedef unsigned char bool;
typedef unsigned char u8; typedef unsigned char u8;
typedef signed char s8; typedef signed char s8;
typedef unsigned short u16; typedef unsigned short u16;
@ -77,55 +78,25 @@ typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif #endif
#ifdef int64
#undef int64
#endif
typedef long long int64;
#ifdef int64_t
#undef int64_t
#endif
typedef long long int64_t;
#ifdef uint64
#undef uint64
#endif
typedef unsigned long long uint64;
#ifdef uint64_t
#undef uint64_t
#endif
typedef unsigned long long uint64_t;
#ifdef int32 #ifdef int32
#undef int32 #undef int32
#endif #endif
typedef int int32; typedef int int32;
#ifdef int32_t
#undef int32_t
#endif
typedef int int32_t;
#ifdef uint32 #ifdef uint32
#undef uint32 #undef uint32
#endif #endif
typedef unsigned int uint32; typedef unsigned int uint32;
#ifdef uint32_t
#undef uint32_t
#endif
typedef unsigned int uint32_t;
#ifdef int16 #ifdef int16
#undef int16 #undef int16
#endif #endif
typedef short int16; typedef short int16;
#ifdef uint16 #ifdef uint16
#undef uint16 #undef uint16
#endif #endif
typedef unsigned short uint16; typedef unsigned short uint16;
#ifdef ULONG #ifdef ULONG
#undef ULONG #undef ULONG
@ -137,11 +108,6 @@ typedef unsigned long ULONG;
#endif #endif
typedef unsigned char u8_t; typedef unsigned char u8_t;
#ifdef int8_t
#undef int8_t
#endif
typedef signed char int8_t;
#ifdef uint8_t #ifdef uint8_t
#undef uint8_t #undef uint8_t
#endif #endif
@ -162,6 +128,7 @@ typedef unsigned short uint16_t;
#endif #endif
typedef unsigned int u32_t; typedef unsigned int u32_t;
#ifdef s8_t #ifdef s8_t
#undef s8_t #undef s8_t
#endif #endif