From f2ef5863315a6e3916a1d6e730ac6bd13af82708 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 29 Jun 2021 11:54:15 -0700 Subject: [PATCH] clean up --- ports/nrf/bluetooth/ble_drv.c | 2 -- ports/nrf/common-hal/_bleio/Connection.c | 1 - ports/nrf/common-hal/_bleio/Service.c | 1 - supervisor/shared/bluetooth/bluetooth.c | 26 ++++++++++-------------- supervisor/shared/bluetooth/serial.h | 2 +- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 29b2844736..9596e45fbb 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -38,8 +38,6 @@ #include "py/misc.h" #include "py/mpstate.h" -// #include "supervisor/shared/bluetooth.h" - nrf_nvic_state_t nrf_nvic_state = { 0 }; // Flag indicating progress of internal flash operation. diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 0e7c6a3c54..b94ad09e6a 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -311,7 +311,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // Did an sd_ble_gatts_sys_attr_set() with the stored sys_attr values. // Indicate ATTR table change because we may have reloaded since the peer last // connected. - mp_printf(&mp_plat_print, "restore sys attrs\n"); sd_ble_gatts_service_changed(self->conn_handle, 0xC, 0xFFFF); } else { // No matching bonding found, so use fresh system attributes. diff --git a/ports/nrf/common-hal/_bleio/Service.c b/ports/nrf/common-hal/_bleio/Service.c index 0c4ded2d1b..4980b70fe1 100644 --- a/ports/nrf/common-hal/_bleio/Service.c +++ b/ports/nrf/common-hal/_bleio/Service.c @@ -153,7 +153,6 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, char_md.p_char_user_desc = (const uint8_t *)user_description; char_md.char_user_desc_max_size = strlen(user_description); char_md.char_user_desc_size = strlen(user_description); - mp_printf(&mp_plat_print, "user description %s\n", user_description); } bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm); diff --git a/supervisor/shared/bluetooth/bluetooth.c b/supervisor/shared/bluetooth/bluetooth.c index 1a57075c6e..df57bf691d 100644 --- a/supervisor/shared/bluetooth/bluetooth.c +++ b/supervisor/shared/bluetooth/bluetooth.c @@ -87,9 +87,9 @@ bool boot_in_discovery_mode = false; bool advertising = false; STATIC void supervisor_bluetooth_start_advertising(void) { - // #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - // return; - // #else + #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE + return; + #else bool is_connected = common_hal_bleio_adapter_get_connected(&common_hal_bleio_adapter_obj); if (is_connected) { return; @@ -98,7 +98,6 @@ STATIC void supervisor_bluetooth_start_advertising(void) { #if CIRCUITPY_USB // Don't advertise when we have USB instead of BLE. if (!bonded && !boot_in_discovery_mode) { - mp_printf(&mp_plat_print, "skipping advertising\n"); return; } #endif @@ -112,7 +111,6 @@ STATIC void supervisor_bluetooth_start_advertising(void) { // Advertise with less power when doing so publicly to reduce who can hear us. This will make it // harder for someone with bad intentions to pair from a distance. if (!bonded) { - mp_printf(&mp_plat_print, "public advertising\n"); tx_power = -40; adv = public_advertising_data; adv_len = sizeof(public_advertising_data); @@ -130,9 +128,9 @@ STATIC void supervisor_bluetooth_start_advertising(void) { scan_response_len, tx_power, NULL); - mp_printf(&mp_plat_print, "advert %d\n", status); // This may fail if we are already advertising. advertising = status == NRF_SUCCESS; + #endif } #define BLE_DISCOVERY_DATA_GUARD 0xbb0000bb @@ -144,22 +142,20 @@ void supervisor_bluetooth_init(void) { if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) { ble_mode = (reset_state & ~BLE_DISCOVERY_DATA_GUARD_MASK) >> 8; } - // const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason(); + const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason(); boot_in_discovery_mode = false; - // if (reset_reason != RESET_REASON_POWER_ON && - // reset_reason != RESET_REASON_RESET_PIN && - // reset_reason != RESET_REASON_UNKNOWN && - // reset_reason != RESET_REASON_SOFTWARE) { - // return; - // } + if (reset_reason != RESET_REASON_POWER_ON && + reset_reason != RESET_REASON_RESET_PIN && + reset_reason != RESET_REASON_UNKNOWN && + reset_reason != RESET_REASON_SOFTWARE) { + return; + } if (ble_mode == 0) { port_set_saved_word(BLE_DISCOVERY_DATA_GUARD | (0x01 << 8)); } // Wait for a while to allow for reset. - ble_mode = 1; - #ifdef CIRCUITPY_BOOT_BUTTON digitalio_digitalinout_obj_t boot_button; common_hal_digitalio_digitalinout_construct(&boot_button, CIRCUITPY_BOOT_BUTTON); diff --git a/supervisor/shared/bluetooth/serial.h b/supervisor/shared/bluetooth/serial.h index ac96a67f40..b5bbcccf10 100644 --- a/supervisor/shared/bluetooth/serial.h +++ b/supervisor/shared/bluetooth/serial.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal