Fix ble bonding fail
This commit is contained in:
parent
afdc3a5ced
commit
8ca87a5d27
@ -88,7 +88,7 @@ SRC_C += \
|
||||
mphalport.c \
|
||||
$(SILABS_BUILD)/pins.c\
|
||||
|
||||
ifeq ('$(BOARD)','brd2601b')
|
||||
ifneq (,$(wildcard boards/$(BOARD)/sensor.c))
|
||||
SRC_C += boards/$(BOARD)/sensor.c
|
||||
endif
|
||||
|
||||
|
@ -24,4 +24,3 @@ requires:
|
||||
recommends:
|
||||
- id: sensor_rht
|
||||
- id: sensor_lux
|
||||
- id: bt_rail_compatibility_fix
|
||||
|
@ -1,14 +1,15 @@
|
||||
|
||||
BOARD_BRD = brd2601b
|
||||
INTERNAL_FLASH_FILESYSTEM = 0
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
QSPI_FLASH_FILESYSTEM = 0
|
||||
SPI_FLASH_FILESYSTEM = 1
|
||||
SPI_FLASH_FILESYSTEM = 0
|
||||
EXTERNAL_FLASH_DEVICES = MX25R3235F
|
||||
|
||||
MCU_SERIES = MG24
|
||||
MCU_VARIANT = EFR32MG24B310F1536IM48
|
||||
|
||||
CIRCUITPY_USB = 0
|
||||
CIRCUITPY_SDCARDIO = 1
|
||||
|
||||
CIRCUITPY_CREATOR_ID = 0x19960000
|
||||
CIRCUITPY_CREATION_ID = 0x00242601
|
||||
|
@ -10,8 +10,8 @@ PB2,BTN0,1,2
|
||||
PB3,BTN1,1,3
|
||||
PC0,FLASH_CS,2,0
|
||||
PC1,SCLK,2,1
|
||||
PC2,CIPO,2,2
|
||||
PC3,COPI,2,3
|
||||
PC2,MISO,2,2
|
||||
PC3,MOSI,2,3
|
||||
PC4,SCL,2,4
|
||||
PC5,SDA,2,5
|
||||
PC9,SENSOR_CS,2,9
|
||||
|
|
@ -16,5 +16,3 @@ provides:
|
||||
- name: custom_brd2703a_cp_support
|
||||
requires:
|
||||
- name: efr32mg24b210f1536im48
|
||||
recommends:
|
||||
- id: bt_rail_compatibility_fix
|
||||
|
@ -37,8 +37,8 @@
|
||||
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS)
|
||||
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB5)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB4)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PC5)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PC4)
|
||||
#define DEFAULT_I2C_PERIPHERAL I2C0
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PC1)
|
||||
|
@ -7,6 +7,7 @@ MCU_SERIES = MG24
|
||||
MCU_VARIANT = EFR32MG24B210F1536IM48
|
||||
|
||||
CIRCUITPY_USB = 0
|
||||
CIRCUITPY_SDCARDIO = 1
|
||||
|
||||
CIRCUITPY_CREATOR_ID = 0x19960000
|
||||
CIRCUITPY_CREATION_ID = 0x00242703
|
||||
|
@ -42,7 +42,6 @@ component:
|
||||
- {id: sleeptimer}
|
||||
- {id: emlib_wdog}
|
||||
- {id: bluetooth_feature_connection}
|
||||
- {id: rail_lib_multiprotocol}
|
||||
- {id: bluetooth_feature_dynamic_gattdb}
|
||||
- {id: bluetooth_feature_system}
|
||||
- {id: bluetooth_feature_scanner}
|
||||
|
@ -280,9 +280,10 @@ uint32_t _common_hal_bleio_adapter_start_advertising(
|
||||
const bleio_address_obj_t *directed_to) {
|
||||
|
||||
sl_status_t sc = SL_STATUS_FAIL;
|
||||
int16_t power = tx_power * 10; // TX power in 0.1 dBm steps
|
||||
int16_t set_power;
|
||||
uint32_t interval_min = 160;
|
||||
uint32_t interval_max = 160;
|
||||
uint32_t interval_min = (uint32_t)(interval * 1600); // (milliseconds * 1.6)
|
||||
uint32_t interval_max = (uint32_t)(interval * 1600); // (milliseconds * 1.6)
|
||||
bd_addr address;
|
||||
uint8_t address_type;
|
||||
uint8_t system_id[8];
|
||||
@ -328,7 +329,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(
|
||||
}
|
||||
|
||||
sc = sl_bt_advertiser_set_tx_power(self->advertising_handle,
|
||||
tx_power,
|
||||
power,
|
||||
&set_power);
|
||||
if (SL_STATUS_OK != sc) {
|
||||
return sc;
|
||||
|
@ -41,6 +41,7 @@
|
||||
STATIC conn_state_t conn_state;
|
||||
osMutexId_t bluetooth_connection_mutex_id;
|
||||
bleio_adapter_obj_t common_hal_bleio_adapter_obj;
|
||||
uint8_t ble_bonding_handle = 0xFF;
|
||||
|
||||
__ALIGNED(4) static uint8_t bluetooth_connection_mutex_cb[osMutexCbSize];
|
||||
const osMutexAttr_t bluetooth_connection_mutex_attr = {
|
||||
@ -106,7 +107,6 @@ void common_hal_bleio_check_connected(uint16_t conn_handle) {
|
||||
|
||||
// Bluetooth stack event handler.
|
||||
void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
sl_status_t sc = SL_STATUS_OK;
|
||||
bd_addr address;
|
||||
uint8_t address_type = 0;
|
||||
STATIC uint8_t serv_idx = 0;
|
||||
@ -122,23 +122,18 @@ void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
|
||||
case sl_bt_evt_system_boot_id:
|
||||
|
||||
sc = sl_bt_system_get_identity_address(&address, &address_type);
|
||||
sl_bt_system_get_identity_address(&address, &address_type);
|
||||
|
||||
snprintf((char *)device_name, 14 + 1,
|
||||
"CIRCUITPY-%X%X",address.addr[1], address.addr[0]);
|
||||
sl_bt_gatt_server_write_attribute_value(gattdb_device_name,
|
||||
0,14,device_name);
|
||||
|
||||
sc = sl_bt_sm_configure(0x00,sl_bt_sm_io_capability_noinputnooutput);
|
||||
if (SL_STATUS_OK != sc) {
|
||||
mp_raise_bleio_BluetoothError(translate("Sm configure fail"));
|
||||
}
|
||||
sl_bt_sm_store_bonding_configuration(5,2);
|
||||
|
||||
sc = sl_bt_sm_set_bondable_mode(1);
|
||||
if (SL_STATUS_OK != sc) {
|
||||
mp_raise_bleio_BluetoothError(translate("Set bondable mode fail"));
|
||||
}
|
||||
sl_bt_sm_delete_bondings();
|
||||
sl_bt_sm_configure(0x00,sl_bt_sm_io_capability_noinputnooutput);
|
||||
|
||||
sl_bt_sm_set_bondable_mode(1);
|
||||
break;
|
||||
|
||||
// This event indicates that a new connection was opened.
|
||||
@ -154,14 +149,7 @@ void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
bleio_connections[0].is_central = false;
|
||||
bleio_connections[0].mtu = 0;
|
||||
}
|
||||
|
||||
sc = sl_bt_sm_increase_security(
|
||||
evt->data.evt_connection_opened.connection);
|
||||
|
||||
if (SL_STATUS_OK != sc) {
|
||||
mp_raise_bleio_BluetoothError(
|
||||
translate("Increase security fail."));
|
||||
}
|
||||
ble_bonding_handle = evt->data.evt_connection_opened.bonding;
|
||||
osMutexRelease(bluetooth_connection_mutex_id);
|
||||
break;
|
||||
|
||||
@ -181,6 +169,8 @@ void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
case sl_bt_evt_connection_closed_id:
|
||||
common_hal_bleio_adapter_remove_connection(
|
||||
evt->data.evt_connection_closed.connection);
|
||||
// reset bonding handle variable to avoid deleting wrong bonding info
|
||||
ble_bonding_handle = 0xFF;
|
||||
break;
|
||||
|
||||
case sl_bt_evt_system_external_signal_id:
|
||||
@ -306,7 +296,7 @@ void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
&& serv_idx < connection->remote_service_list->len) {
|
||||
|
||||
service = connection->remote_service_list->items[serv_idx];
|
||||
sc = sl_bt_gatt_discover_characteristics(
|
||||
sl_bt_gatt_discover_characteristics(
|
||||
evt->data.evt_gatt_procedure_completed.connection,
|
||||
service->handle);
|
||||
|
||||
@ -366,34 +356,20 @@ void sl_bt_on_event(sl_bt_msg_t *evt) {
|
||||
break;
|
||||
|
||||
case sl_bt_evt_sm_confirm_bonding_id:
|
||||
sc = sl_bt_sm_bonding_confirm(
|
||||
evt->data.evt_sm_confirm_bonding.connection,1);
|
||||
if (SL_STATUS_OK != sc) {
|
||||
mp_raise_bleio_BluetoothError(
|
||||
translate("Bonding confirm fail"));
|
||||
}
|
||||
sl_bt_sm_bonding_confirm(evt->data.evt_sm_confirm_bonding.connection,1);
|
||||
break;
|
||||
|
||||
case sl_bt_evt_sm_bonded_id:
|
||||
break;
|
||||
|
||||
case sl_bt_evt_sm_bonding_failed_id:
|
||||
if (ble_bonding_handle != 0xFF) {
|
||||
sl_bt_sm_delete_bonding(ble_bonding_handle);
|
||||
ble_bonding_handle = 0xFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case sl_bt_evt_connection_parameters_id:
|
||||
switch (evt->data.evt_connection_parameters.security_mode)
|
||||
{
|
||||
case connection_mode1_level1:
|
||||
break;
|
||||
case connection_mode1_level2:
|
||||
break;
|
||||
case connection_mode1_level3:
|
||||
break;
|
||||
case connection_mode1_level4:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -91,10 +91,10 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
|
||||
// Resolution is not configurable directly but is based on the
|
||||
// selected oversampling ratio (osrHighSpeed), which defaults to
|
||||
// 2x and generates 12-bit results.
|
||||
initAllConfigs.configs[0].reference = iadcCfgReferenceInt1V2;
|
||||
initAllConfigs.configs[0].vRef = 1210;
|
||||
initAllConfigs.configs[0].reference = iadcCfgReferenceVddx;
|
||||
initAllConfigs.configs[0].vRef = 3300;
|
||||
initAllConfigs.configs[0].osrHighSpeed = iadcCfgOsrHighSpeed2x;
|
||||
initAllConfigs.configs[0].analogGain = iadcCfgAnalogGain0P5x;
|
||||
initAllConfigs.configs[0].analogGain = iadcCfgAnalogGain1x;
|
||||
|
||||
// Divide CLK_SRC_ADC to set the CLK_ADC frequency
|
||||
initAllConfigs.configs[0].adcClkPrescale
|
||||
@ -212,5 +212,5 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||
// Get adc ref value
|
||||
float common_hal_analogio_analogin_get_reference_voltage
|
||||
(analogio_analogin_obj_t *self) {
|
||||
return 2.42f;
|
||||
return 3.3f;
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG24B310F1536IM48" partId="mcu.arm.efr32.mg24.efr32mg24b310f1536im48" contextId="com.silabs.sdk.stack.super:4.1.0._-50688992">
|
||||
<mode name="DefaultMode">
|
||||
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
|
||||
<property object="PC00" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_MX25_FLASH_SHUTDOWN_CS%T%sl_mx25_flash_shutdown_eusart_config.h"/>
|
||||
<property object="PC00" propertyId="pin.reserve" value="Reserved"/>
|
||||
<property object="PC08" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_BOARD_ENABLE_SENSOR_MICROPHONE%T%sl_board_control_config.h"/>
|
||||
<property object="PC08" propertyId="pin.reserve" value="Reserved"/>
|
||||
<property object="PC09" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_BOARD_ENABLE_SENSOR_IMU%T%sl_board_control_config.h"/>
|
||||
<property object="PC09" propertyId="pin.reserve" value="Reserved"/>
|
||||
<property object="PORTIO" propertyId="portio.pti.enable.dframe" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.pti.enable.dout" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.pti.location.dframe" value="39"/>
|
||||
<property object="PORTIO" propertyId="portio.pti.location.dout" value="38"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.rx" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.tx" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.location.rx" value="6"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.location.tx" value="5"/>
|
||||
<property object="PTI" propertyId="ABModule.selectedRequirement" value="pti%T%SL_RAIL_UTIL_PTI%T%sl_rail_util_pti_config.h"/>
|
||||
<property object="PTI" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="USART0" propertyId="ABModule.selectedRequirement" value="usart%T%SL_IOSTREAM_USART_VCOM%T%sl_iostream_usart_vcom_config.h"/>
|
||||
<property object="USART0" propertyId="ABPeripheral.included" value="true"/>
|
||||
</mode>
|
||||
<modeTransition>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.source" value="RESET"/>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.target" value="DefaultMode"/>
|
||||
</modeTransition>
|
||||
</device:XMLDevice>
|
Loading…
Reference in New Issue
Block a user