Working on BLE rf modem sleep feature - continued
This commit is contained in:
parent
54a22beaf7
commit
fe879e300a
@ -12,6 +12,23 @@
|
||||
#include "wm_wifi.h"
|
||||
|
||||
static bool _ble_modem_is_sleeping = false;
|
||||
static bool _ble_modem_wakeup_order = false;
|
||||
|
||||
static void _ble_modem_sleep_enter_cb(uint32_t sleep_duration_ms)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void _ble_modem_sleep_exit_cb(void)
|
||||
{
|
||||
if(_ble_modem_wakeup_order)
|
||||
{
|
||||
tls_bt_ctrl_sleep(false);
|
||||
tls_bt_ctrl_wakeup();
|
||||
_ble_modem_wakeup_order = false;
|
||||
_ble_modem_is_sleeping = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ble_modem_on(bool bluetoothOnly, bool startService)
|
||||
{
|
||||
@ -29,6 +46,10 @@ bool ble_modem_on(bool bluetoothOnly, bool startService)
|
||||
TLS_BT_APPL_TRACE_DEBUG("ble modem running, uart_no=%d, log_level=%d"NEW_LINE, uart_no,
|
||||
tls_appl_trace_level);
|
||||
status = tls_bt_init(uart_no);
|
||||
if(tls_bt_register_sleep_callback(_ble_modem_sleep_enter_cb, _ble_modem_sleep_exit_cb) != TLS_BT_STATUS_SUCCESS)
|
||||
{
|
||||
TLS_BT_APPL_TRACE_ERROR("%s, failed to register rf modem sleep callbacks"NEW_LINE, __FUNCTION__);
|
||||
}
|
||||
|
||||
if((status != BLE_HS_ENOERR) && (status != BLE_HS_EALREADY))
|
||||
{
|
||||
@ -130,7 +151,7 @@ bool ble_modem_sleep(void)
|
||||
|
||||
bool ble_modem_wake(void)
|
||||
{
|
||||
tls_bt_status_t status = tls_bt_ctrl_sleep(false);
|
||||
/*tls_bt_status_t status = tls_bt_ctrl_sleep(false);
|
||||
if(status == TLS_BT_STATUS_SUCCESS)
|
||||
{
|
||||
if(tls_bt_ctrl_wakeup() == TLS_BT_STATUS_SUCCESS)
|
||||
@ -141,7 +162,9 @@ bool ble_modem_wake(void)
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;*/
|
||||
_ble_modem_wakeup_order = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ble_modem_is_sleeping(void)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "services/gap/ble_svc_gap.h"
|
||||
#include "wm_bt_util.h"
|
||||
#include "bluetooth_sig_values.h"
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#define USABLE_DEFAULT_MTU (20) //23 - 3 of header bytes
|
||||
|
||||
@ -734,7 +735,7 @@ static int ble_gap_event_cb(struct ble_gap_event *event, void *arg)
|
||||
break;
|
||||
case BLE_GAP_EVENT_NOTIFY_TX:
|
||||
if(event->notify_tx.indication == 0) // Notification
|
||||
{
|
||||
{
|
||||
TLS_BT_APPL_TRACE_VERBOSE("Type : notification"NEW_LINE);
|
||||
if(event->notify_tx.status != BLE_HS_ENOERR)
|
||||
{
|
||||
|
@ -652,16 +652,6 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tls_bt_controller_sleep_enter_cb(uint32_t sleep_duration_ms)
|
||||
{
|
||||
//shell_printf("BT CTRL sleep for %u"NEW_LINE, sleep_duration_ms);
|
||||
}
|
||||
|
||||
void tls_bt_controller_sleep_exit_cb(void)
|
||||
{
|
||||
//shell_printf("BT CTRL wakeup"NEW_LINE);
|
||||
}
|
||||
|
||||
static void demo_timer_irq(void *arg)
|
||||
{
|
||||
bool *sleeping = arg;
|
||||
@ -690,7 +680,6 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||
ble_service_set_pairing_passkey(123456);
|
||||
|
||||
if(!ble_modem_is_sleeping())ble_modem_sleep();
|
||||
tls_bt_register_sleep_callback(tls_bt_controller_sleep_enter_cb, tls_bt_controller_sleep_exit_cb);
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1], "disable") == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user