stm32/rfcore: Leave txpower level as default when initialising rfcore.

And provide a convenient API function to change it (currently unused).

Fixes issue #5985.

Signed-off-by: Damien George <damien@micropython.org>
v1.13-wasp-os
Damien George 2020-06-16 12:29:02 +10:00
parent 289be6b352
commit 4b5dd012e0
2 changed files with 7 additions and 1 deletions

View File

@ -416,8 +416,13 @@ void rfcore_ble_check_msg(int (*cb)(void *, const uint8_t *, size_t), void *env)
SWAP_UINT8(buf[3], buf[6]);
SWAP_UINT8(buf[4], buf[5]);
tl_ble_hci_cmd_resp(HCI_OPCODE(OGF_VENDOR, OCF_WRITE_CONFIG), 8, buf); // set BDADDR
tl_ble_hci_cmd_resp(HCI_OPCODE(OGF_VENDOR, OCF_SET_TX_POWER), 2, (const uint8_t *)"\x00\x06"); // 0 dBm
}
}
// "level" is 0x00-0x1f, ranging from -40 dBm to +6 dBm (not linear).
void rfcore_ble_set_txpower(uint8_t level) {
uint8_t buf[2] = { 0x00, level };
tl_ble_hci_cmd_resp(HCI_OPCODE(OGF_VENDOR, OCF_SET_TX_POWER), 2, buf);
}
#endif // defined(STM32WB)

View File

@ -33,5 +33,6 @@ void rfcore_init(void);
void rfcore_ble_init(void);
void rfcore_ble_hci_cmd(size_t len, const uint8_t *src);
void rfcore_ble_check_msg(int (*cb)(void *, const uint8_t *, size_t), void *env);
void rfcore_ble_set_txpower(uint8_t level);
#endif // MICROPY_INCLUDED_STM32_RFCORE_H