state = HCI_PACKET_START;
// disable BT UART?
// mabye UCA1CTL1 = UCSWRST ?
+
pdata = EHCILL_GO_TO_SLEEP_ACK;
mw_bt_uart_tx(&pdata, 0x01);
- BT_IO_POUT |= BT_IO_RTS; // pull RTS -> stop data
+ // pull RTS -> stop data
+ BT_IO_POUT |= BT_IO_RTS;
+
+ // enable IRQ on CTS
P1IFG &= ~BT_IO_CTS;
P1IE |= BT_IO_CTS;
{
bt_hci_cmd_t packet;
+ // refuse any HCI if interface is not enabled
+ if (mw_bt_is_enabled() == 0)
+ return;
+
if (state == EHCILL_SLEEPING) {
uint8_t ehcill_p = EHCILL_WAKE_UP_IND;
- debug_uart_tx("HCILL wakeup\n");
+ debug_uart_tx("wakeup HCILL\n");
state = HCI_PACKET_START;
mw_bt_uart_tx(&ehcill_p, 1);
__delay_cycles(300000);
mw_bt_uart_tx(data, data_len);
}
+typedef struct {
+ uint16_t acl_handle;
+ uint16_t max_interval;
+ uint16_t min_interval;
+ uint16_t sniff_attempt;
+ uint16_t sniff_timeout;
+} __attribute__((packed)) bt_hci_sniff_cmd_t;
+
+void bt_hci_set_sniff_mode(const uint16_t acl_handle, const uint16_t max_interval, const uint16_t min_interval, const uint16_t sniff_attempt, const uint16_t sniff_timeout)
+{
+ bt_hci_sniff_cmd_t sniff_cmd;
+
+ sniff_cmd.acl_handle = acl_handle;
+ sniff_cmd.max_interval = max_interval;
+ sniff_cmd.min_interval = min_interval;
+ sniff_cmd.sniff_attempt = sniff_attempt;
+ sniff_cmd.sniff_timeout = sniff_timeout;
+
+ bt_hci_cmd(HCI_LINK_POLICY_OGF, HCI_SNIFF_MODE_OCF, sizeof(sniff_cmd), &sniff_cmd);
+}
+
typedef struct {
uint8_t type;
uint16_t handle;
{
bt_hci_acl_t packet;
+ // refuse any HCI if interface is not enabled
+ if (mw_bt_is_enabled() == 0)
+ return;
+
packet.type = HCI_ACL_DATA_PACKET;
packet.handle = handle | ((PB & 0x03) << 12) | ((BC & 0x03) << 14);
packet.total_length = dlen + 4;
void bt_hci_ehcill_wake(void)
{
- uint8_t ehcill_p = EHCILL_WAKE_UP_ACK;
+ const uint8_t ehcill_p = EHCILL_WAKE_UP_ACK;
debug_uart_tx("HCILL wakeup\n");
P1IE &= ~BT_IO_CTS;
+ P1IFG &= ~BT_IO_CTS;
state = HCI_PACKET_START;
BT_IO_POUT &= ~BT_IO_RTS; // drop RTS -> start data