在广告模式下访问物联网加密狗传感器数据

11 posts / 0 new
Last post
杰里米王
Offline
Last seen:4 years 1 week ago
Joined:2017-01-16 14:09
在广告模式下访问物联网加密狗传感器数据

Hi,

我正在使用Dialog IoT开发工具包。我试图检测加密狗是否已经移动了一定的时间间隔,并在广告数据中放置一个标志。最好的办法是什么?是否有一个中断,我可以写一个处理程序,每次狗移动?如果是这样,我该怎么设置?或者是否有一个我可以调用的函数来告诉我加密狗是否移动了(我每次读到它后都可以重置)

I've tried calling the bmo160_get_any_motion_stat() and bmi160_get_step_counter() functions to try to detect motion but this doesn't seem to work. Is there another function that I can use or is there any other setup required for me to use these functions while in advertising mode?

我正在进行wrbl\U sfl项目。

谢谢,
杰里米

设备:
MT_dialog
Offline
Last seen:2个月2周前
Staff
Joined:2015-06-08 11:34
嗨,杰里米王,

嗨,杰里米王,

IoT项目在广告结束后立即得到任何形式的移动中断,在广告完成回调中,user\u bmi160\u config\u anymotion\u intr()函数将加速计设置为该模式,因此,当加速计感测到任何类型的运动时,都会触发583的中断,并且会触发wkup\u intr\u non\u connected\u cb(),以便设备再次开始广告,因此您可以在中断处理程序处放置一个标志,或者,由于设备每次移动时都会启动播发,因此您甚至可以在user\u adv\u start()函数中设置设备移动的标志,并相应地修改播发字符串。如果您想在广告时计数,您可以使用此配置,以便随时可用,并在任何移动时触发中断。

另请注意,如果不存在,SFL项目中的写入额外代码的空间非常有限,问题是keil的限制,因为它不会通过32k编译额外的代码,所以我建议除非原始项目您希望传感器融合功能。

Thanks MT_dialog

michaelmeng998
Offline
Last seen:4 years 1 month ago
Joined:2017-01-11 07:46
嗨,MT\u对话!你提到

嗨,MT\u对话!你提到that the IOT project gets a interrupt of any kind of movement right after the advertising is finished, so if there is motion detected the interrupt handler gets triggered in order for the device to start advertising again. What if we want to have the interrupt to be enabled all the time and not only after the 14583 has gone to sleep? We currently disabled our 14583's sleep mode.

Also, you mentioned we could write a flag in the user_adv_start function. How would we use the anymotion or stepcounter functions available to help us achieve our goal. We have tried writing a flag in the user_app_adv_undirect_complete function using the read_step_counter statement but it's not working at all.

谢谢,

Michael

MT_dialog
Offline
Last seen:2个月2周前
Staff
Joined:2015-06-08 11:34
你好michaelmeng998,

你好michaelmeng998,

如果您想一直启用中断,则必须配置传感器,以便从设备运行时开始提供中断,在获得中断后,您可以将其视为移动,另外,您要考虑的移动取决于您如何配置IMU上的中断,BMI中断在永久、临时或非锁存模式下运行(请查看BMI160数据表了解更多信息)。

关于如何执行此操作,请告知传感器的数据表,该模块IT Self提供了一系列配置和中断,这些配置和中断在某些情况下触发,因此您应该检查什么适合您并启用BMI模块中的相应功能。关于user_adv_start_function中的写作标志,我提到的是,如果您想宣传设备正在移动,因为设备在永久睡眠状态下落下时,设备可以启用中断,并且可以设置a计数器或标志作为设备移动和宣传的指示。

Thanks MT_dialog

michaelmeng998
Offline
Last seen:4 years 1 month ago
Joined:2017-01-11 07:46
Hi MT\ U对话框:

Hi MT\ U对话框:

I am still a bit confused. I checked the datasheet.h source file and it has some specific IRQn's like the Wakeup from low power interrupt, receipt interrupt at end of each received packet, and the end of advertising interrupt, but there is no interrupt corresponding to when we first start the device.

同时,bmi160在线数据表,它说其他e is a anymotion interrupt register (INT_MOTION, 0x5F-0x62). I am trying to find out how to enable this interrupt. Also, do we need to write an individual interrupt handler, or can we call one of the pre-written interrupt handlers like the wkup_intr_non_connected_cb?

MT_dialog
Offline
Last seen:2个月2周前
Staff
Joined:2015-06-08 11:34
你好michaelmeng998,

你好michaelmeng998,

当代码开始在设备上运行时,没有中断,如果您想知道您可以在哪里设置中断以便触发,则可以将其放在.app_on_init回调中,或者您甚至可以将其放置在广告启动时。

IoT源代码在设备停止广告时启用该中断,在用户app\u on\u adv\u undirect\u complete中,如果您检查user\u init\u bmi\u nc()函数,您将能够找到一个如何使用任何运动中断设置bmi的示例,更具体地说,user\u bmi160\u config\u anymotion\u intr()是设置要触发的中断的函数。您可以检查该函数并将您想要的配置应用于您的项目。关于中断的处理,在IoT上,此中断连接到唤醒计时器(设备处于睡眠状态时可用的中断),为了将ISR分配给该中断,wkupct\u register\u callback()api会执行此操作,例如,在IoT中,配置了anymotion中断和IMU后,调用函数config\u da1458x\u pin\u intr\u non\u connected(),该函数将wkup\u intr\u non\u connected\u cb注册到唤醒计时器,并通过wkupct\u enable\u irq()函数设置期望中断的pin。

Thanks MT_dialog

michaelmeng998
Offline
Last seen:4 years 1 month ago
Joined:2017-01-11 07:46
嘿,MT\u对话。谢谢你的邀请

嘿,MT\u对话。谢谢你的邀请response. I still have a few questions. You mentioned that the user_init_bmi_nc() function is the function that sets the BMI with the any motion interrupt? When I checked the user_wrbl.c file, the user_init_bmi_nc() function was called in the user_app_on_adv_undirect_complete function after advertising was finished. So if we wanted to set the interrupt when the advertising starts, would we just move the user_init_bmi_nc() function to the user_adv_start() function?

Also, since I want to access the dongles motion status (whether it moved or not) and then configure our advertising packets to carry whether or not it moved, (we already have the ability to modify the advertised packets size, we just need to access the motion status information properly) where does the motion status get stored after the bmi160 detects motion? Is there a specific queue that holds this information that we can access?

MT_dialog
Offline
Last seen:2个月2周前
Staff
Joined:2015-06-08 11:34
你好michaelmeng998,

你好michaelmeng998,

不仅是用户\初始化\ bmi \ nc(),即只在传感器端设置配置,您还必须在583端配置中断。同样,在用户\应用程序\上\ adv \ u undirect \ u complete中,还有一些额外的配置,代码用于配置IMU设备,请阅读并尝试理解代码。如果您只是将用户\u init \u bmi \u nc()放在这里,它根本不起作用。

关于第二个问题,您可以在IMU的数据表中找到答案和更多信息,但是当触发中断时,您可以在wkup\u intr\u non\u connected\u cb()上看到设备读取一些寄存器(INT\u STATUS\u registers-0x1C,0x1D,0x1E)以确定触发的中断是什么。

Thanks MT_dialog

杰里米王
Offline
Last seen:4 years 1 week ago
Joined:2017-01-16 14:09
嗨,MT\u Dialog,

嗨,MT\u Dialog,

我们设置了当加密狗移动时触发的中断。这部分起作用。我们希望运行另一个类似但不同的函数,而不是执行user\u adv\u start的默认操作。

The reason is that we set the user_adv_start function to start advertising with a flag of 0x00 which gets called on program initialization since "not moved" should be our initial state.

However, the interrupt signifies that motion has occurred and we want to start advertising but with a flag of 0x01. We created a separate function called restart_adv and called this from within our interrupt handler as seen below. However, even though this function is getting called (we verified this in the debugger), the dongle restarts advertising with 0x00 even though we are passing in 0x01 as an argument to our start advertising function.

The relevant code is included below.

谢谢,
杰里米

// in user_platform.c
void wkup\u intr\u non\u connected\u cb(void)//当加密狗移动时,成功调用此函数
{
restart_adv();
}

// in user_wrbl.c
void user\u adv\u start(void){//这是在程序初始化时调用的,用0x00播发
user_easy_gap_undirected_advertise_start( FAST_ADV_INTERVAL, 0x00);
}

void restart_adv( void ) { // this is what we want to be called from the interrupt handler, should advertise with 0x01
user_easy_gap_undirected_advertise_start( FAST_ADV_INTERVAL, 0x01);
}

//启动广告的功能,我们为我们要宣传的用户数据添加了额外参数
static void user_easy_gap_undirected_advertise_start(uint16_t adv_intv, uint8_t user_data)
{
struct gapm_start_advertise_cmd* cmd;
timer\u hnd app\u adv\u data\u update\u timer\u used=app\u easy\u timer(1000,adv\u data\u update\u timer\u cb);

cmd = app_easy_gap_undirected_advertise_get_active();
cmd->intv_max = adv_intv;
cmd->intv_min = adv_intv;
用户添加高级信息(cmd->info.host.scan\u rsp\u data,10);
user_add_accel_info(cmd->info.host.scan_rsp_data,user_data);//修改我们用于广告数据的字节

app_easy_gap_undirected_advertise_start();

// We are now connectable
ke_state_set(TASK_APP, APP_CONNECTABLE);
}

uint8\u t用户添加加速信息(uint8\u t*padv,uint8\u t用户数据){
padv[7] = user_data;
return 0;
}

杰里米王
Offline
Last seen:4 years 1 week ago
Joined:2017-01-16 14:09
嗨,MT\u Dialog,

嗨,MT\u Dialog,

We figured out what our problem is. Thanks!

杰里米

MT_dialog
Offline
Last seen:2个月2周前
Staff
Joined:2015-06-08 11:34
嗨,杰里米王,

嗨,杰里米王,

感谢您的表明,如果您发现它们有用或甚至随意分享您的解决方案,请接受上述任何答案以便其他人在类似的问题中获得帮助。

Thanks MT_dialog