你好,
I am working with the Dialog IoT development kit. I am trying to detect whether or not the dongle has moved over a certain time interval and place a flag into the advertisement data. What would be the best way of doing this? Is there an interrupt that I can write a handler for each time the dongle moves? If so, how can I set this up? Or is there a function that I can call that will tell me if the dongle has moved or not (which I can reset after each time I read it)
我尝试过致电BMO160_Get_Any_Motion_Stat()和BMI160_Get_Step_Counter()函数来尝试检测运动,但似乎没有工作。是否有另一种功能可以使用或在广告模式下使用这些功能所需的其他设置?
I am working off the wrbl_sfl project.
谢谢,
杰里米
Device:
Hi jeremynwong,
The IoT project gets a interrupt of any kind of movement right after the advertising is finished, in the advertising complete callback the user_bmi160_config_anymotion_intr() function sets the accelerometer in that mode, so when the accelerometer senses any kind of motion triggers an interrupt to the 583 and the wkup_intr_non_connected_cb() gets triggered in order for the device to start advertising again, so you could place a flag at that interrupt handler, or since the device every time it gets moved it starts the advertising you can even set a flag that the device is moved in the user_adv_start() function and modify your advertising string accordingly. If you would like to count while you are advertising you can use this configuration in order to be available at all times and trigger an interrupt at any movement.
另请注意,如果不存在,SFL项目中的写入额外代码的空间非常有限,问题是keil的限制,因为它不会通过32k编译额外的代码,所以我建议除非原始项目您希望传感器融合功能。
谢谢mt_dialog.
嗨mt_dialog!您提到IOT项目在广告完成后,IOT项目会导致任何类型的移动,因此如果存在动作检测到中断处理程序,以便设备再次启动广告。如果我们想要一直在启用中断,那么不仅在14583睡觉后启用中断?我们目前禁用了我们的14583年的睡眠模式。
此外,您提到我们可以在user_adv_start函数中编写一个标志。我们将如何使用可用的任何函数来帮助我们实现目标。我们尝试使用read_step_counter语句在user_app_add_undirect_complete函数中编写标志,但它根本无法工作。
谢谢,
迈克尔
Hi michaelmeng998,
If you would like to have the interrupt enabled all the time then you will have to configure the sensor to provide an interrupt from the time that the device operates and after getting that interrupt you can consider it as a movement, also what you are going to consider as a movement that depends on how you have configured the interrupts on the IMU, the BMI interrupts operate under permanently, temporarily or not latched mode (please check the BMI160 datasheet for more info on this).
关于如何执行此操作,请告知传感器的数据表,该模块IT Self提供了一系列配置和中断,这些配置和中断在某些情况下触发,因此您应该检查什么适合您并启用BMI模块中的相应功能。关于user_adv_start_function中的写作标志,我提到的是,如果您想宣传设备正在移动,因为设备在永久睡眠状态下落下时,设备可以启用中断,并且可以设置a计数器或标志作为设备移动和宣传的指示。
谢谢mt_dialog.
Hi MT_dialog:
我仍然有点困惑。我检查了Datasheet.h源文件,它有一些特定的IRQN,就像从低功耗中断的唤醒一样,每个接收的数据包结束的收据中断,以及广告中断结束,但没有中断对应于我们首次启动时对应设备。
此外,在BMI160 Datasheet Online中,它说有一个AnyMotion中断寄存器(int_motion,0x5f-0x62)。我试图了解如何启用此中断。此外,我们还需要编写一个单独的中断处理程序,还是我们可以调用一个像wkup_intr_non_connected_cb这样的预先写的中断处理程序之一?
Hi michaelmeng998,
当代码开始在设备上运行时,没有中断,如果您想知道您可以在哪里设置中断以便触发,则可以将其放在.app_on_init回调中,或者您甚至可以将其放置在广告启动时。
The IoT source code enables that interrupt when the device stops advertising, in the user_app_on_adv_undirect_complete, if you check the user_init_bmi_nc() function you will be able to find an example how to set the BMI with the any motion interrupt, more specifically the user_bmi160_config_anymotion_intr() is the function that sets the interrupt to be triggered. You can check that function and apply the configuration that you would like to your project. Regarding the handling of the interrupt, on the IoT this interrupt is connected to the wakeup timer (the interrupt that is available when the device is in sleep), in order to assign an ISR to that interrupt there is the wkupct_register_callback() api that does that, for example in the IoT after the anymotion interrupt and the IMU has been configured the function config_da1458x_pin_intr_non_connected() is invoked, that function registers the wkup_intr_non_connected_cb to the wakeup timer and sets the pin that expects the interrupt via the wkupct_enable_irq() function.
谢谢mt_dialog.
嘿mt_dialog。谢谢你的回应。我还有一些问题。您提到user_init_bmi_nc()函数是将BMI与任何运动中断设置的函数?当我检查user_wrbl.c文件时,在广告完成后,user_init_bmi_nc()函数调用user_app_on_add_undirect_complete函数中。因此,如果我们想在广告启动时设置中断,我们会只是将user_init_bmi_nc()函数移动到user_adv_start()函数?
另外,由于我想访问加密乐动作状态(无论是移动还是不移动),然后配置我们的广告数据包以携带它是否移动,(我们已经有能力修改广告的数据包大小,我们只需要访问运动状态信息正确)运动状态在BMI160检测到运动之后存储运动状态在哪里存储?是否有特定的队列保存我们可以访问的这些信息?
Hi michaelmeng998,
不仅user_init_bmi_nc(),这集的有限公司nfiguration only at the sensors end, you will have also to configure the interrupt on the 583's side also in the user_app_on_adv_undirect_complete, there are some additional configurations that the code does for configuring the IMU device, please read and try to understand the code. If you just place the user_init_bmi_nc() it simply wont work.
Regarding your second question you will be able to find the answer and more information in the datasheet of the IMU, nevertheless when the interrupt gets triggered you can see at the wkup_intr_non_connected_cb() that the devices reads some registers (the INT_STATUS_ registers - 0x1C, 0x1D, 0x1E) in order to determine what is the interrupt that got triggered.
谢谢mt_dialog.
Hi MT_Dialog,
We've set up our interrupt that gets triggered when the dongle moves. This part works. Instead of executing the default operation of user_adv_start, we want to run another similar but different function.
原因是我们设置了user_adv_start函数来开始广告,其中0x00的标志,从程序初始化调用,因为“未移动”应该是我们的初始状态。
但是,中断表示发生的动作,我们希望开始广告,但有一个0x01的标志。我们创建了一个名为RESTART_ADV的单独函数,并从我们的中断处理程序中称为如下所示。但是,即使这个函数被称为(我们在调试器中验证了这个功能),加密狗即使我们将0x01传递为我们的启动广告函数的参数,即使我们传递0x00,加密狗也会重新启动。
相关代码包含在下面。
谢谢,
杰里米
//在user_platform.c.中
void wkup_intr_non_connected_cb( void ) // this function successfully gets called when the dongle moves
{
RESTART_ADV();
}
//在user_wrbl.c.中
void user_adv_start( void ) { // this is what is called on program initialization, advertise with 0x00
user_easy_gap_undircated_advertise_start(fast_adv_interval,0x00);
}
void restart_adv(void){//这是我们想要从中断处理程序调用的,应该用0x01宣传
user_easy_gap_undirected_advertise_start(fast_adv_interval,0x01);
}
//启动广告的功能,我们为我们要宣传的用户数据添加了额外参数
static void user_easy_gap_undircated_advertise_start(uint16_t adv_intv,uint8_t user_data)
{
struct gapm_start_advertise_cmd * cmd;
timer_hnd app_adv_data_update_timer_used = app_easy_timer(1000, adv_data_update_timer_cb);
cmd = app_easy_gap_undirected_advertise_get_active();
cmd-> intv_max = adv_intv;
cmd-> intv_min = adv_intv;
user_add_adv_info(cmd->info.host.scan_rsp_data, 10 );
user_add_accel_info(cmd->info.host.scan_rsp_data, user_data); // modifies the byte we are using for advertising data
app_easy_gap_undirected_advertise_start();
//我们现在是可连接的
ke_state_set(task_app,app_connectable);
}
uint8_t user_add_accel_info( uint8_t *padv, uint8_t user_data){
padv [7] = user_data;
返回0;
}
Hi MT_Dialog,
我们弄清楚了我们的问题是什么。谢谢!
杰里米
Hi jeremynwong,
感谢您的表明,如果您发现它们有用或甚至随意分享您的解决方案,请接受上述任何答案以便其他人在类似的问题中获得帮助。
谢谢mt_dialog.