偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.
全部博文(1748)
分类: 其他平台
2019-09-10 19:16:41
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
int dwm_pos_set(dwm_pos_t* p_pos); 设置node所在默认位置 |
Example: dwm_pos_t pos; pos.qf = 100; pos.x = 121; pos.y = 50; pos.z = 251; dwm_pos_set(&pos); |
|
|
int dwm_pos_set(dwm_pos_t* p_pos); 获取自己node的位置 |
dwm_pos_t pos; dwm_pos_get(&pos) |
|
|
int dwm_upd_rate_set(uint16_t ur, uint16 urs); 设置更新率和静止更新率. 单位: 100ms. 静止更新率 必须>=更新率 此操作需要些internal flash,尽量少调用 ur: 位置发布周期 urs:静止时的位置发布周期, 最大2分钟. |
dwm_upd_rate_set(10, 50); // update rate 1 second. 5 seconds stationary |
|
|
int dwm_upd_rate_get(uint16_t* p_ur, uint16_t* p_urs); 获取更新率 |
uint16_t ur, urs; dwm_upd_rate_get(&ur, &urs); |
|
|
int dwm_cfg_tag_set(dwm_cfg_tag_t* p_cfg); 把一个节点配置成 Tag. dwm_cfg_tag_t 16-bit integer. 各个bit的意义看上面的描述 |
dwm_cfg_tag_t cfg; cfg.stnry_en = 1; cfg.meas_mode = DWM_MEAS_MODE_TWR; cfg.low_power_en = 0; cfg.loc_engine_en = 1; cfg.common.enc_en = 1; cfg.common.led_en = 1; cfg.common.ble_en = 0; cfg.common.fw_update_en = 0; cfg.common.uwb_mode = DWM_UWB_MODE_ACTIVE; dwm_cfg_tag_set(&cfg); |
|
|
int dwm_cfg_anchor_set(dwm_cfg_anchor_t* p_cfg) 把一个node 配置成 anchor dwm_cfg_anchor_t = 8-bit integer |
dwm_cfg_anchor_t cfg; int rv; cfg.initiator = 1; cfg.bridge = 0; cfg.common.enc_en = 1; cfg.common.led_en = 1; cfg.common.ble_en = 1; cfg.common.fw_update_en = 1; cfg.common.uwb_mode = DWM_UWB_MODE_OFF; rv = dwm_cfg_anchor_set(&cfg); if (rv == DWM_ERR_PERM) printf(“Error: either encryption or BLE can be enabled, encryption can be enabled only if encryption key is set\n”); dwm_reset(); |
|
|
int dwm_cfg_get(dwm_cfg_t* p_cfg); 获取node的当前配置 dwm_cfg_t = 16 bit integer |
dwm_cfg_t cfg; dwm_cfg_get(&cfg); printf(“mode %u \n”, cfg.mode); printf(“initiator %u \n”, cfg.initiator); printf(“bridge %u \n”, cfg.bridge); printf(“motion detection enabled %u \n”, cfg.stnry_en); printf(“measurement mode %u \n”, cfg.meas_mode); printf(“low power enabled %u \n”, cfg.low_power_en); printf(“internal location engine enabled %u \n”, cfg.loc_engine_en); printf(“encryption enabled %u \n”, cfg.common.enc_en); printf(“LED enabled %u \n”, cfg.common.led_en); printf(“BLE enabled %u \n”, cfg.common.ble_en); printf(“firmware update enabled %u \n”, cfg.common.fw_update_en); printf(“UWB mode %u \n”, cfg.common.uwb_mode); |
|
|
int dwm_sleep(void); 在LowPower使能的情况下, 让node进入sleep mode. |
/* THREAD 1: sleep and block*/ dwm_sleep(); /*do something*/ ... /*THREAD 2: wait until event */ dwm_evt_wait(&evt); /*unblock dwm_sleep()*/ dwm_wake_up(); |
|
|
int dwm_anchor_list_get(dwm_anchor_list_t* p_list); 只能用于anchor节点. 得到周边anchors列表. 包括自己网络以及其他相邻网络. |
dwm_anchor_list_t list; int i; dwm_anchor_list_get(&list); for (i = 0; i < list.cnt; ++i) { printf("%d. id=0x%04X pos=[%ld,%ld,%ld] rssi=%d seat=%u neighbor=%d\n", i, list.v[i].node_id, list.v[i].x, list.v[i].y, list.v[i].z, list.v[i].rssi, list.v[i].seat, list.v[i].neighbor_network); } |
|
|
int dwm_loc_get(dwm_loc_data_t* p_loc); 适用于 tag low-power 以及 responsive 节点(在auto-position时, 部署时不用手动测量). 获取最近一次的距离和计算的位置. 在所有的TWR完成并且定位引擎LocationEngnine计算结束后(如果定位引擎LocationEngnine被禁用, 那么只输出距离信息) |
dwm_loc_data_t loc; int rv, i; /* if pos_available is false, position data are not read and function returns without error */ rv = dwm_loc_get(&loc); if (0 == rv) { if (loc.pos_available) { printf("[%ld,%ld,%ld,%u] ", loc.pos.x, loc.pos.y, loc.pos.z, loc.pos.qf); } for (i = 0; i < loc.anchors.dist.cnt; ++i) { printf("%u)", i); printf("0x%04x", loc.anchors.dist.addr[i]); if (i < loc.anchors.an_pos.cnt) { printf("[%ld,%ld,%ld,%u]", loc.anchors.an_pos.pos[i].x, loc.anchors.an_pos.pos[i].y, loc.anchors.an_pos.pos[i].z, loc.anchors.an_pos.pos[i].qf); } printf("=%lu,%u ", loc.anchors.dist.dist[i], loc.anchors.dist.qf[i]); } printf("\n"); } else { printf("err code: %d\n", rv); } |
|
|
int dwm_baddr_set(dwm_baddr_t* p_baddr); 设置Bluetooth的地址, 地址需要模块复位reset生效. |
dwm_baddr_t baddr; baddr.byte[0] = 1; baddr.byte[1] = 2; baddr.byte[2] = 3; baddr.byte[3] = 4; baddr.byte[4] = 5; baddr.byte[5] = 6; dwm_baddr_set(&baddr); |
|
|
int dwm_baddr_get(dwm_baddr_t* p_baddr); 获取 bluetooth的地址. |
dwm_baddr_t baddr; int i; if (DWM_OK == dwm_baddr_get(&baddr)) { printf("addr="); for (i = DWM_BLE_ADDR_LEN - 1; i >= 0; --i) { printf("%02x%s", baddr.byte[i], (i > 0) ? ":" : ""); } printf("\n"); } else { printf("FAILED"); } |
|
|
int dwm_stnry_cfg_set(dwm_stnry_sensitivity_t sensitivity); 适用于 Tag. 配置Tag静止模式 dwm_stnry_sensitivity_t 8-bit integer = 0, 1, 2 |
dwm_stnry_cfg_set(DWM_STNRY_SENSITIVITY_HIGH); |
|
|
int dwm_stnry_cfg_get(dwm_stnry_sensitivity_t* p_sensitivity); |
dwm_stnry_sensitivity_t sensitivity; dwm_stnry_cfg_get(&sensitivity); |
|
|
int dwm_factory_reset(void); 恢复出厂设置. |
dwm_factory_reset(); |
|
|
int dwm_reset(void); 模块复位重启 |
dwm_reset(); |
|
|
int dwm_ver_get(dwm_ver_t* p_ver); 获取版本信息 |
dwm_ver_t ver; dwm_ver_get(&ver); |
|
|
int dwm_uwb_cfg_set(dwm_uwb_cfg_t *p_cfg); 设置UWB参数. |
dwm_uwb_cfg_t cfg; cfg.pg_delay = 197; cfg.tx_power = 0xD0252525; dwm_uwb_cfg_set(&cfg); |
|
|
int dwm_uwb_cfg_get(dwm_uwb_cfg_t *p_cfg); |
dwm_uwb_cfg_t uwb_cfg; dwm_uwb_cfg_get(&uwb_cfg); printf("delay=%x, power=%lx compensated(%x,%lx)\n", uwb_cfg.pg_delay, uwb_cfg.tx_power, uwb_cfg.compensated.pg_delay, uwb_cfg.compensated.tx_power); |
|
|
int dwm_usr_data_read(uint8_t* p_data, uint8_t* p_len); 读取下行的用户数据 downlink user data. 数据需要设定状态标识并且通过 dwm_evt_listener_register 设置了事件. p_data 最大34 字节. |
uint8_t data[DWM_USR_DATA_LEN_MAX]; uint8_t len; len = DWM_USR_DATA_LEN_MAX; dwm_usr_data_read(data, &len); |
|
|
int dwm_usr_data_write(uint8_t* p_data, uint8_t len, bool overwrite); 发送用户数据. overwrite 是否覆盖尚未发送完毕的数据. |
uint8_t len, data[DWM_USR_DATA_LEN_MAX]; len = DWM_USR_DATA_LEN_MAX; dwm_usr_data_write(data, len, false); |
|
|
int dwm_label_read(uint8_t* p_label, uint8_t* p_len); 读取node的标签 p_label 最长 16字节. |
uint8_t label[DWM_LABEL_LEN_MAX]; uint8_t len; len = DWM_LABEL_LEN_MAX; dwm_label_read(label, &len); |
|
|
int dwm_label_write(uint8_t* p_label, uint8_t len); |
uint8_t len, label[DWM_LABEL_LEN_MAX]; len = DWM_LABEL_LEN_MAX; rv = dwm_label_write(label, len); if ( len == rv ) printf(“ok\n”); else printf(“error, %d”, rv); |
|
|
int dwm_gpio_cfg_output(dwm_gpio_idx_t idx, bool value); 把GPIO设置成 output, 并置高低电平 |
dwm_gpio_cfg_output(DWM_GPIO_IDX_13, 1); // set pin 13 as output and to 1 (high voltage) |
|
|
int dwm_gpio_cfg_input(dwm_gpio_idx_t idx, dwm_gpio_pin_pull_t pull_mode); 把 GPIO 设置为input 模式, 并配置 PULL. |
dwm_gpio_cfg_input(DWM_GPIO_IDX_13, DWM_GPIO_PIN_PULLUP); dwm_gpio_cfg_input(DWM_GPIO_IDX_9, DWM_GPIO_PIN_NOPULL); dwm_gpio_cfg_input(DWM_GPIO_IDX_31, DWM_GPIO_PIN_PULLDOWN); |
|
|
int dwm_gpio_value_set(dwm_gpio_idx_t idx, bool value); |
dwm_gpio_value_set(DWM_GPIO_IDX_13, 1); |
|
|
int dwm_gpio_value_get(dwm_gpio_idx_t idx, bool* p_value); |
uint8_t value; dwm_gpio_value_get(DWM_GPIO_IDX_13, &value); printf(“DWM_GPIO_IDX_13 value = %u\n”, value); |
|
|
int dwm_gpio_value_toggle(dwm_gpio_idx_t idx); |
dwm_gpio_value_toggle(DWM_GPIO_IDX_13); |
|
|
int dwm_panid_set(uint16_t panid); |
dwm_panid_set(0xABCD); |
|
|
int dwm_panid_get(uint16_t *p_panid); |
uint16_t panid; if (DWM_OK == dwm_panid_get(&panid)) { printf("panid=%u\n"); } else { printf("FAILED\n"); } |
|
|