WKUPCT回调函数

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
14个帖子/ 0新
Last post
DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
WKUPCT回调函数

I would like to change the advertising's last byte of the UUID when I wake up from a GPIO interrupt to indicate which GPIO woke it up. Using the beacon_v_5.40.2_0 project, I'm declaring the callback as follow:

void tilt_wakeup_cb(void)
{
if(getBits16(sys_stat_reg,per_is_down))
{
//从外部唤醒GPIO返回GPIO功能
if (DEVELOPMENT_DEBUG)
gpio_reservations();
periph_init();
}
tilt_wkup_flag = 1;
user_advertise_operation();
}

Is this allowed?
我计划使用标志来确定设备是否通过GPIO中断或从其定时器唤醒,根据我计划编辑user_update_ibeacon_adv_adv_tring的信息,如下所示:

void user_update_ibeacon_adv_string(struct user_i_beacon_config_tag * data,struct user_beacon_config_tag config)
{
.......
/ /一个dded by DL
if(tilt_wkup_flag){
if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_0)){
数据 - > UUID [15] = 1;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_1)){
data->uuid[15] = 2;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_2)){
data->uuid[15] = 3;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_3)){
data->uuid[15] = 4;
}else if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_4)){
数据 - > UUID [15] = 5;
}else if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_5)){
数据- > uuid [15] = 6;
}
tilt_wk_flag = 0;
}别的{
数据 - > UUID [15] = 0;
}
//
.....
}

测试此代码,当GPIO被拉低时似乎没有做任何事情以强制唤醒。

在user_on_init ()
我将此添加到函数:

wkupct_register_callback(tilt_wakeup_cb);
wkupct_enable_irq(0x3F0000,0x3F0000,1,0); // Enable interrupt for P2_0 to P2_5

关键词:
Device:
DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
我修改了回调

我修改了回调follow, but still doesn't seem to work. Tracing with Jlink, I can see it go into the callback function, but it doesn't advertise the new UUID:

void tilt_wakeup_cb(void) { if (GetBits16(SYS_STAT_REG, PER_IS_DOWN)) { // Return GPIO functionality from external wakeup GPIO if (DEVELOPMENT_DEBUG) GPIO_reservations(); periph_init(); } if (arch_ble_ext_wakeup_get()) { arch_set_sleep_mode(ARCH_SLEEP_OFF); //disable the sleep mode arch_ble_force_wakeup(); //force the BLE to wake up arch_ble_ext_wakeup_off(); //disable the external wake up (if you have set the arch_ble_ext_wakeup_on() function before going to permanent sleep) //LED } tilt_wkup_flag = 1; user_advertise_operation(); wkupct_enable_irq(0x003F0000,0x003F0000,1,0); // Enable interrupt for P2_0 to P2_5 }

MT_dialog
离线
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
嗨dio,

嗨dio,

如果发生唤醒中断,则需要调试此操作,可以在User_update_ibeacon_add()中放置一个断点,并检查代码是否通过该函数,并且如果满足条件以更改广告字符串。

Thanks MT_dialog

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
好的,所以不应该有任何

好的,所以不应该有任何problem in calling user_advertise_operation(); inside the callback right? The radio and everything should be on and it should advertise when set up the way I have it?

只是确保我没有违反一些规则,从GPIO中断唤醒后我们无法宣传。

谢谢,

MT_dialog
离线
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
好吧,它没有建议

嗯,它没有建议直接从唤醒开始广告操作虽然这应该工作,可以在BLE_APP_SLEEMODE中找到一个动作的正确方法,检查app_button_press_cb(),但即使没有跟随你的设备应该能够开始广告。例如,如果可以直接从app_button_press_cb()和删除app_easy_wakeup()设备将宣传的App_easy_wakeUp()将用户调用user_app_adv_start()(我假设是与已实现的user_advertise_operation相同。但是使用app_easy_wakeup()API的建议方式。

Thanks MT_dialog

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
It seems every so often the

当没有发生GPIO中断并且设备在定时间隔上唤醒时,在手机上的灯架扫描应用上看到所有广告活动。

当GPIO中断确实发生时,踩到代码时,似乎代码会做它应该是什么,但我从未在扫描仪应用中看到正确的值......

Somehow I don't think the data is being advertised in this scenario. The app_easy_gap_non_connectable_advertise_start() is used for both scenario. For the GPIO interrupt case I changed the cmd->intv_min and cmd->intv_max to 0. or leave those two blank, no luck either way.

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
Here is the code.

Here is the code.

MT_dialog
离线
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi dlo,

Hi dlo,

如果代码确实假设要做什么,并且您可以获得中断和您想要的数据,您可以看到设备仍然是广告,但与旧值有关您将如何在广告中放置数据细绳。通过新值更新广告字符串之后,我假设您停止使用新值的广告更新广告字符串,然后使用user_advertise_operation重新启动广告。你调用app_easy_gap_non_connectable_advertise_get_active()函数才能填写一个新消息,然后在广告字符串中添加自定义数据,您可以做些什么来调试这是为了逐步在代码中查看携带广告命令的CMD指针包括您想要放置的广告数据的代码中的某个点(检查CMD-> host.adv_data阵列并检查您的数据是否在此阵列中附加)。

Thanks MT_dialog

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
所以我测试了你的样子

所以我测试了你建议的东西,发现了一些奇怪的行为。

When using timer wakeup interval and disabling the wkupct, the GPIO is polled in user_update_ibeacon_adv_string and the UUID last byte is updated accordingly. I can see these changes in the scanner app, everything works as it should.

然后我启用wkupct:
wkupct_register_callback(tilt_wakeup_cb);
wkupct_enable_irq(0x3F0000,0x3F0000,1,0); // Enable interrupt for P2_0 to P2_5

在此之后,我不再看到扫描仪应用程序中的UUID更改的最后一个字节。由于使用相同的代码来更新广告字符串并进行通告,因此我将假设这两个功能正常工作。现在弄清楚为什么启用wkupct并调用user_advertise_operation不再适用。

我尝试追踪CMD->信息 - >主机 - > ADV_DATA,但没有一个值似乎匹配UUID或任何识别的任何识别。

The code only uses the dialog code user_advertise_operation(); no modifications to it.
I modified the dialog provided code user_update_ibeacon_adv_string

void user_update_ibeacon_adv_string(struct user_i_beacon_config_tag * data,struct user_beacon_config_tag config)
{
memcpy (data->adv_header, ADV_HEADER_iBEACON,2);
数据 - >雷电竞下载app company_id [0] =(UINT8_T)(CONFIG.COMPANY_ID&0xFF);
data->company_id[1] = (uint8_t) (config.company_id>>8);
data-> data_type = ibeacon_data_type;
data->beacon_length = ADV_DATA_LENGTH;

memcpy (data->uuid, config.uuid, 16);
/ /一个dded by DL
if(tilt_wkup_flag){
if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_0)){
数据 - > UUID [15] = 1;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_1)){
data->uuid[15] = 2;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_2)){
data->uuid[15] = 3;
}如果(!gpio_getpinstatus(gpio_port_2,gpio_pin_3)){
data->uuid[15] = 4;
}else if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_4)){
数据 - > UUID [15] = 5;
}else if(!GPIO_GetPinStatus(GPIO_PORT_2, GPIO_PIN_5)){
数据- > uuid [15] = 6;
}
tilt_wkup_flag = 0;
}别的{
数据 - > UUID [15] = 0;
}
//
data-> tx_power = config.power;
}

Wrote the wkupct callback:

void tilt_wakeup_cb(void)
{
if(getBits16(sys_stat_reg,per_is_down))
{
//从外部唤醒GPIO返回GPIO功能
if (DEVELOPMENT_DEBUG)
gpio_reservations();
periph_init();
}
if (arch_ble_ext_wakeup_get())
{
arch_set_sleep_mode(app_default_sleep_mode); //set default sleep mode
arch_ble_force_wakeup(); //force the BLE to wake up
ARCH_BLE_EXT_WAKEUP_OFF();//禁用外部唤醒
}
tilt_wkup_flag = 1;
user_advertise_operation();
wkupct_enable_irq(0x003f0000,0x003f0000,10);//为p2_0启用中断到p2_5
}

Thanks for your continued support!

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
发现有点信息。

发现有点信息。
我删除了对user_advertise_operation()的调用;在tilt_wakeup_cb()中,现在看到扫描仪应用程序中的预期更改。问题是它稍后最终记录了大约5-10个广告间隔。(我在5秒钟内设置广告间隔,我在GPIO被拉低后在大约55秒内收到更改的数据包)。

这似乎表明,在将实际事件放在队列中之前需要刷新的广告数据的缓冲区?这似乎是对吗?

You mentioned I should stop the advertising, update the advertising string and then restart the advertising. Am I interpreting this correctly if I do the following?

app_easy_gap_advertise_stop();
user_advertise_operation();

The code for user_advertise_operation(); is the default Dialog one:

void user_advertise_operation(void)
{
struct gapm_start_advertise_cmd * cmd;
current_advertising_string = next_advertising_string;
current_advertising_mode = next_advertising_mode;
if(current_advertising_mode == non_connectable_mode)
{
//获取指向BLE数据包的指针
cmd = app_easy_gap_non_connectable_advertise_get_active();

user_adv_restarted = true;
cmd-> info.host.adv_data_len = user_load_beacon_config(cmd);

//开始为非可连接外设进行广告。
if(app_connected == ke_state_get(task_app))
{
//不要在连接状态广告不可连接的广告
}
别的
{
if(user_flash_beacon_config_loaded)
{
cmd->intv_min = MS_TO_BLESLOTS(user_beacon_config.adv_int);
cmd->intv_max = MS_TO_BLESLOTS(user_beacon_config.adv_int);
}

app_easy_gap_non_connectable_advertise_start();

}
}
否则if(current_advertising_mode ==未向连接_mode)
{
//获取指向BLE数据包的指针
cmd = app_easy_gap_undirected_advertise_get_active();

user_adv_restarted = true;
cmd-> info.host.adv_data_len = user_load_beacon_config(cmd);

if (current_advertising_string == SUOTA_ADVERTISING_STRING)
{
update_advertising_data(user_advertise_suota,user_advertise_suota_len);
user_update_adv_string(cmd,(void *)dynamic_adv_string,suota_advertising_string,user_advertise_suota_len);
}
//启动广告以获得未确定的外设。
app_easy_gap_undircated_advertise_start();
}

}

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
我正在尝试的背景

关于我想做的事情的背景,请告诉我是否有可能。

当GPIO2_0变为低电平时,我想用uuid结尾发出一个广告,以0.手机应用程序将记录它收到广告的时间。当另一个GPIO变低时,让我们说GPIO2_1,我想用uuid结尾发出一个广告。手机将记录它收到的时间并计算两个广告之间的时间差。时间差对我正在尝试与数据进行操作至关重要。这是实现这一目标的可靠方法吗?或者是否有一些类型的限制,不允许我完成这一目标?

Thanks again for your continued support.

MT_dialog
离线
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi dlo,

Hi dlo,

关于在580上更新广告字符串,为了正确地停止,更新广告字符串并再次启动广告,您将不得不发出停止,然后等待堆栈回复广告确实停止了(SDK Will通知您广告已停止使用APP_ONC_ADV_UNDIRECT为无向广告,对于不可连接的广告,还有CORRSPONDING回调 - 请检查鞍骨灯,以便具有比标识更简单的引用)。因此,当堆栈通知您广告已完成并发生回调时,从该回调开始,您可以调用您将更新的新广告字符串的启动。您无法调用停止广告,然后将函数拨打函数开始。我想这是你的主要问题。

Regarding what you are trying to implement and time the difference between two advertising data, be aware that the advertising is not a reliable way to send data, that means that there is no guarantee that the data that you will send will reach the scanner at that particular time, since there will be collisions between other advertising devices and protocols emmiting at that time in general interierence to the mean, so with the advertising procedure there is no assurance that whatever the peripheral will send the scanner will most definatelly receive. So please be aware of that.

Thanks MT_dialog

DLO.
离线
Last seen:2 weeks 2 days ago
加入:2017-05-26 16:21
Thank you for the continued

谢谢你继续支持。我尝试在鞍骨项目中实现示例,但它仍然没有工作。我不知道还有什么要尝试,但是因为你提到没有保证到达扫描仪的数据,我们需要解决其他问题。

MT_dialog
离线
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
Hi dlo,

Hi dlo,

是的,没有保证广告字符串将要达到中央,由于一个拥挤的平均值,范围或噪音,协议没有机制,以便核心adcied广告串的外围设备收到,这仅在连接期间发生。

Thanks MT_dialog