9 posts / 0 new
Last post
comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
DA14580休眠问题

请问一下DA14580休眠的流程是怎么样的,我的工程是在ble_app_peripheral的基础上修改的,然后进行了一些休眠模式的配置,具体如下:

user_confog.h中修改:

const static sleep_state_t app_default_sleep_mode =ARCH_EXT_SLEEP_ON;

user_peripheral.c中修改:

void user_app_adv_start(void)
{
// Schedule the next advertising data update
app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); //定时器60sec后停止广播

struct gapm_start_advertise_cmd* cmd;
cmd = app_easy_gap_undirected_advertise_get_active();

// add manufacturer specific data dynamically
mnf_data_update();
app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure));

// Set extended sleep during advertising
arch_set_extended_sleep();


app_easy_gap_undirected_advertise_start();
}

void user_app_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
{
if (app_env[connection_idx].conidx != GAP_INVALID_CONIDX)
{
user_gattc_exc_mtu_cmd(connection_idx);
app_connection_idx = connection_idx;

// Stop the advertising data update timer
app_easy_timer_cancel(app_adv_data_update_timer_used);

// Check if the parameters of the established connection are the preferred ones.
// If not then schedule a connection parameter update request.
if ((param->con_interval < user_connection_param_conf.intv_min) ||
(param->con_interval > user_connection_param_conf.intv_max) ||
(param->con_latency != user_connection_param_conf.latency) ||
(param->sup_to != user_connection_param_conf.time_out))
{
// Connection params are not these that we expect
app_param_update_request_timer_used = app_easy_timer(APP_PARAM_UPDATE_REQUEST_TO, param_update_request_timer_cb);
}
}
else
{
// No connection has been established, restart advertising
user_app_adv_start();
}

default_app_on_connection(connection_idx, param);
arch_set_extended_sleep();
}

void user_app_adv_undirect_complete(uint8_t status) //停止广播后调用
{
// If advertising was canceled then update advertising data and start advertising again
如果(= = GAP_ERR_CA地位NCELED)
{
// user_app_adv_start();
arch_ble_ext_wakeup_on(); //使能外部唤醒,定时器触发无效,睡眠后直到下次重新上电,将不再唤醒

}
}

da1458x_config_basic.h中修改

#define CFG_MEM_MAP_EXT_SLEEP
#undef CFG_MEM_MAP_DEEP_SLEEP

运行程序烧写进去后,可以确定程序是正常运行的,在断开蓝牙连接1分钟后,广播信号消失,是符合程序设定的。我想要达到的目的很简单,就是上电蓝牙正常运行,连接读写完毕后,断开蓝牙,1分钟后,蓝牙进入休眠,且只能用外部唤醒。

目前按上面的程序在广播信号消失后,蓝牙并未进入设置的扩展休眠模式。

请问还有哪里需要修改的吗,还是说我理解的哪里有问题。sleepmode例子里设置的是深度休眠,其他设置好像与我上面的设置没有区别,另外我在.app_on_system_powered = user_scan_sda_flag,是有添加函数的,是否有影响呢

Device:
comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
我好像知道问题在哪了,他进休眠前需要判断app_on

我好像知道问题在哪了,他进休眠前需要判断app_on_system_powered是否为null,我在这里有放执行函数。请问怎么在使用完这个时候,将该位置设置为null呢?

qifang
Offline
Last seen:15 hours 39 min ago
Staff
加入:2019-12-30 09:02
Hi Comprends,

Hi Comprends,

已收到你的问题,我们会在内部讨论后和您联系。

Best regards,

Qifan

comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
好的,期待您的回复。

好的,期待您的回复。

实际测试中,我将app_on_system_powered恢复为null后,在user_app_adv_undirect_complete函数中增加arch_set_extended_sleep();arch_ble_ext_wakeup_on();即可实现休眠,最初的config.h里的休眠可以关闭,在广播结束后再开启休眠也可以。

唯一的问题就是我使用了app_on_system_powered里的函数,要进休眠就得恢复null,不知道怎么处理。休眠流程我大致明白了

comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
还没有答复吗

还没有答复吗

qifang
Offline
Last seen:15 hours 39 min ago
Staff
加入:2019-12-30 09:02
Hi comprends,

Hi comprends,

在.app_on_ble_powered= user_scan_sda_flag 这个函数中是否有返回到 GOTO_SLEEP来进入休眠模式?

Best regards,

Qifan

comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
并没有,需要怎么做呢?在.app_on_ble

并没有,需要怎么做呢?在.app_on_ble_powered= user_scan_sda_flag 添加哪些可以实现 函数运行完后回归正常休眠模式,arch_goto_sleep(sleep_mode);是添加这个函数吗? 在arch_main里面的while (app_asynch_proc() != GOTO_SLEEP);判断的话,是需要 .app_on_ble_powered= null时才会return GOTO_SLEEP;

qifang
Offline
Last seen:15 hours 39 min ago
Staff
加入:2019-12-30 09:02
Hi comprends,

Hi comprends,

可以在调用的 app_on_ble_powered 函数里直接return GOTO_SLEEP ,休眠过程是一个组合流程, GOTO_SLEEP 只是通过了其中的一个,剩下的让程序自己完成就可以了。

Best regards,

Qifan

comprends
Offline
Last seen:1 month 1 week ago
加入:2019-06-21 07:31
在user_scan_sda_flag

在user_scan_sda_flag 里面直接return GOTO_SLEEP ? 但是在主函数循环里,判断的是if (app_asynch_trm() != GOTO_SLEEP);app_asynch_proc() != GOTO_SLEEP;这两个,我需要去修改arch_main.c里这两个函数的内容吗,直接让他return GOTO_SLEEP?