Hi,
我正在使用对话框的IoS开发套件。我正在尝试检测加密狗是否已在某个时间间隔内移动并将标志放入广告数据。这样做的最佳方式是什么?是否有中断我可以为加密狗移动时可以写一个处理程序?如果是这样,我怎样才能将其设置为?或者有一个功能,我可以打电话给我会告诉我如果加密狗是否已经移动(每次读取它之后我可以重置)
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_SFL项目。
Thanks,
Jeremy
设备:
嗨jeremynwong,
IOT项目在广告完成后,在广告完成后,IOT项目会发生任何类型的运动,在广告完整的回调中user_bmi160_config_anymotion_Intr()函数在该模式下设置加速度计,因此当加速度计感测任何类型的运动触发到583中断时触发WKUP_INTR_NON_CONNECTED_CB()触发,以便设备再次启动广告,因此您可以在该中断处理程序处放置一个标志,或者由于设备每次移动时,它开始它开始广告您甚至可以设置设备的标志在user_adv_start()函数中移动并相应地修改广告字符串。如果您想在广告时计算您可以使用此配置,以便随时可用,并在任何移动时触发中断。
Also be aware that the space of writing extra code in the sfl project is quite limited if not non existent, and the problem is the limitation of keil since it wont compile additional code over the 32K so i would suggest to work with teh raw project unless you would like sensor fusion functionallity.
Thanks MT_dialog
嗨mt_dialog!你提到了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.
Thanks,
Michael
嗨michaelmeng998,
如果您想一直启用中断,那么您必须配置传感器,从设备运行的时间和在获得中断后,您可以将其视为一个运动,也是您要将的考虑作为依赖于在IMU上配置中断的运动,BMI中断在永久性,暂时或不锁存模式下运行(请检查BMI160数据表以获取更多信息)。
Regarding the how you can do this please advise the sensor's datasheet, the module it self provides a series of configurations and interrupts that are triggered under certain conditions so you should check what suits you and enable the corresponding function in the BMI module. Regarding the writing a flag in the user_adv_start_function, what i ve mentioned is that if you would like to advertise that the device is being moved, since the device enables the interrupt when it falls in permanent sleep and advertises when wake up you could set up a counter or a flag as an indication that the device is moved and advertise that.
Thanks MT_dialog
嗨mt_dialog:
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?
嗨michaelmeng998,
There is no interrupt when the code starts to run on the device, if you are wondering where you could set the interrupt in order to be triggered, you can place it either in the .app_on_init callback or you can even place it when the advertising starts.
IOT源代码使设备在设备停止广告时,请在user_app_on_adv_undirect_complete中,如果检查user_init_bmi_nc()函数,您将能够找到一个示例如何使用任何运动中断设置BMI,更具体地说是user_bmi160_config_anymotion_intr()是设置要触发中断的函数。您可以检查该功能并应用您想要的配置。关于中断的处理,在IOT上,此中断连接到唤醒定时器(设备在睡眠状态时可用的中断),以便为该中断分配ISR,有WKUPCT_REGISTER_CALLBACK()API例如,在ACotion中断和IMU配置的IOT中,调用函数Config_DA1458X_PIN_INTR_NON_CONNETed(),该函数将WKUP_INTR_NON_CONNECTED_CB注册到唤醒定时器,并设置通过WKUPCT_ENABLE_IRQ()函数的中断的引脚。
Thanks MT_dialog
嘿mt_dialog。谢谢你的意思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?
嗨michaelmeng998,
不仅是user_init_bmi_nc(),那就是只在传感器结束时设置配置,您还可以在583的侧面配置中断,也在user_app_on_adv_undirect_complete中,有一些额外的配置代码为配置IMU设备,请阅读并尝试了解代码。如果您只是将User_Init_Bmi_nc()放置它,它只是工作。
关于您的第二个问题,您将能够在IMU的数据表中找到答案和更多信息,尽管如此,当设备读取设备读取某些寄存器的WKUP_INTR_NON_CONNECTED_CB()时,您可以在WKUP_INTR_NON_CONNECTE_CB()中找到答案和更多信息(INT_STATUS_寄存器 - 0x1c,0x1d,0x1e)为了确定已触发的中断是什么。
Thanks MT_dialog
嗨mt_dialog,
我们设置了随机移动时触发的中断。这部分有效。我们希望运行另一个类似但不同的函数,而不是执行user_adv_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.
Thanks,
Jeremy
// in user_platform.c
void wkup_intr_non_connected_cb(void)//当加密狗移动时成功调用
{
restart_adv();
}
// in user_wrbl.c
void user_adv_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);
}
// the function that starts advertising, we added an extra parameter for the user data we want to advertise
static void user_easy_gap_undirected_advertise_start(uint16_t adv_intv, uint8_t user_data)
{
struct gapm_start_advertise_cmd* cmd;
timer_hnd app_add_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);//修改我们用于广告数据的字节
app_easy_gap_undircated_advertise_start();
// We are now connectable
ke_state_set(TASK_APP, APP_CONNECTABLE);
}
uint8_t user_add_accel_info(uint8_t * padv,uint8_t user_data){
padv[7] = user_data;
return 0;
}
嗨mt_dialog,
We figured out what our problem is. Thanks!
Jeremy
嗨jeremynwong,
谢谢你的指示,请接受任何的the answers above if you found them usefull or even feel free to share your solution in order for others to get help in a similar issue.
Thanks MT_dialog