diff --git a/android/bluetooth.c b/android/bluetooth.c
index 947a83c..ca3dd24 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
-1);
}
+static void handle_read_energy_info(const void *buf, uint16_t len)
+{
+ DBG("");
+
+ /* TODO */
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, HAL_OP_READ_ENERGY_INFO,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_ENABLE */
{ handle_enable_cmd, false, 0 },
/* HAL_OP_GET_CONNECTION_STATE */
{ handle_get_connection_state, false,
sizeof(struct hal_cmd_get_connection_state) },
+ /* HAL_OP_READ_ENERGY_INFO */
+ { handle_read_energy_info, false, 0 },
};
bool bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index defaef1..7be02ed 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
bt_hal_cbacks->le_test_mode_cb(ev->status, ev->num_packets);
}
+static void handle_energy_info(void *buf, uint16_t len, int fd)
+{
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_energy_info *ev = buf;
+ bt_activity_energy_info info;
+
+ DBG("");
+
+ info.ctrl_state = ev->ctrl_state;
+ info.energy_used = ev->energy_used;
+ info.idle_time = ev->idle_time;
+ info.rx_time = ev->rx_time;
+ info.status = ev->status;
+ info.tx_time = ev->status;
+
+ if (bt_hal_cbacks->energy_info_cb)
+ bt_hal_cbacks->energy_info_cb(&info);
+#endif
+}
+
/*
* handlers will be called from notification thread context,
* index in table equals to 'opcode - HAL_MINIMUM_EVENT'
sizeof(struct hal_ev_dut_mode_receive) },
/* HAL_EV_LE_TEST_MODE */
{ handle_le_test_mode, false, sizeof(struct hal_ev_le_test_mode) },
+ /* HAL_EV_ENERGY_INFO */
+ { handle_energy_info, false, sizeof(struct hal_ev_energy_info) },
};
static uint8_t get_mode(void)
{
DBG("");
- /* TODO: implement */
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_READ_ENERGY_INFO, 0,
+ NULL, NULL, NULL, NULL);
}
#endif
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 6a5a81c..9baa2d9 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
int32_t connection_state;
} __attribute__((packed));
+#define HAL_OP_READ_ENERGY_INFO 0x16
+
/* Bluetooth Socket HAL api */
#define HAL_SOCK_RFCOMM 0x01
uint16_t num_packets;
} __attribute__((packed));
+#define HAL_EV_ENERGY_INFO 0x8c
+struct hal_ev_energy_info {
+ uint8_t status;
+ uint8_t ctrl_state;
+ uint64_t tx_time;
+ uint64_t rx_time;
+ uint64_t idle_time;
+ uint64_t energy_used;
+} __attribute__((packed));
+
#define HAL_HIDHOST_STATE_CONNECTED 0x00
#define HAL_HIDHOST_STATE_CONNECTING 0x01
#define HAL_HIDHOST_STATE_DISCONNECTED 0x02