Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions chipset/em9301/EM9301_Patch_V0x0A.c

Large diffs are not rendered by default.

384 changes: 264 additions & 120 deletions chipset/em9301/btstack_chipset_em9301.c

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions chipset/em9301/btstack_chipset_em9301.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ extern const hci_cmd_t hci_vendor_em_transmitter_test_end;
extern const hci_cmd_t hci_vendor_em_patch_query;
extern const hci_cmd_t hci_vendor_em_set_memory_mode;
extern const hci_cmd_t hci_vendor_em_set_sleep_options;
extern const hci_cmd_t hci_vendor_em_set_operating_state;

#define HCI_SUBEVENT_EM_STANDBY_STATE 0x01
#define HCI_SUBEVENT_EM_BLE_IDLE_ENTERED 0x02

#if defined __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion platform/embedded/btstack_em9304_spi_embedded.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void btstack_em9304_spi_embedded_set_transfer_done_callback(void (*callba
/**
* @brief Poll READY state
*/
static int btstack_em9304_spi_embedded_get_ready(){
static int btstack_em9304_spi_embedded_get_ready(void){
return hal_em9304_spi_get_ready();
}

Expand Down
2 changes: 1 addition & 1 deletion platform/embedded/hal_em9304_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void hal_em9304_spi_disable_ready_interrupt(void);
/**
* @brief Poll READY state
*/
int hal_em9304_spi_get_ready();
int hal_em9304_spi_get_ready(void);

/**
* @brief Set Chip Selet
Expand Down
5 changes: 5 additions & 0 deletions platform/embedded/hal_uart_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ extern "C" {
*/
void hal_uart_dma_init(void);

/**
* @brief Deinit and close device
*/
void hal_uart_dma_deinit(void);

/**
* @brief Set callback for block received - can be called from ISR context
* @param callback
Expand Down
2 changes: 1 addition & 1 deletion platform/freertos/btstack_run_loop_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "btstack_linked_list.h"
#include "btstack_debug.h"
#include "btstack_util.h"
#include "hal_time_ms.h"
#include <platform/embedded/hal_time_ms.h>

// some SDKs, e.g. esp-idf, place FreeRTOS headers into an 'freertos' folder to avoid name collisions (e.g. list.h, queue.h, ..)
// wih this flag, the headers are properly found
Expand Down Expand Up @@ -122,7 +122,7 @@
btstack_linked_item_t *it;
for (it = (btstack_linked_item_t *) &timers; it->next ; it = it->next){
// don't add timer that's already in there
btstack_timer_source_t * next = (btstack_timer_source_t *) it->next;

Check warning on line 125 in platform/freertos/btstack_run_loop_freertos.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "next" is "struct btstack_timer_source *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG9I_VoME7_WxVjc&open=AZ0aQG9I_VoME7_WxVjc&pullRequest=269
if (next == ts){
log_error( "btstack_run_loop_timer_add error: timer to add already in list!");
return;
Expand All @@ -146,8 +146,8 @@
#ifdef ENABLE_LOG_INFO
btstack_linked_item_t *it;
int i = 0;
for (it = (btstack_linked_item_t *) timers; it ; it = it->next){

Check warning on line 149 in platform/freertos/btstack_run_loop_freertos.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Declare the variable "it" inside the loop.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG9I_VoME7_WxVjd&open=AZ0aQG9I_VoME7_WxVjd&pullRequest=269

Check warning on line 149 in platform/freertos/btstack_run_loop_freertos.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant cast.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG9I_VoME7_WxVje&open=AZ0aQG9I_VoME7_WxVje&pullRequest=269
btstack_timer_source_t *ts = (btstack_timer_source_t*) it;

Check warning on line 150 in platform/freertos/btstack_run_loop_freertos.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "ts" is "struct btstack_timer_source *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG9I_VoME7_WxVjf&open=AZ0aQG9I_VoME7_WxVjf&pullRequest=269
log_info("timer %u, timeout %u\n", i, (unsigned int) ts->timeout);
}
#endif
Expand Down
6 changes: 4 additions & 2 deletions platform/freertos/btstack_uart_block_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "btstack_debug.h"
#include "btstack_uart_block.h"
#include "btstack_run_loop_freertos.h"
#include "hal_uart_dma.h"
#include <platform/embedded/hal_uart_dma.h>

#ifdef HAVE_FREERTOS_INCLUDE_PREFIX
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -126,9 +126,11 @@ static int btstack_uart_block_freertos_open(void){
}

static int btstack_uart_block_freertos_close(void){

// close device
// ...
#ifdef HAL_UART_DMA_DEINIT
hal_uart_dma_deinit();
#endif
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@

/* ENUM_START: BLUETOOTH_ERROR_CODE */
#define ERROR_CODE_SUCCESS 0x00
#define ERROR_CODE_UNKNOWN_HCI_COMMAND 0x01

Check failure on line 134 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVg5&open=AZ0aQGzL_VoME7_WxVg5&pullRequest=269
#define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02

Check failure on line 135 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVg6&open=AZ0aQGzL_VoME7_WxVg6&pullRequest=269
#define ERROR_CODE_HARDWARE_FAILURE 0x03

Check failure on line 136 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVg7&open=AZ0aQGzL_VoME7_WxVg7&pullRequest=269
#define ERROR_CODE_PAGE_TIMEOUT 0x04
#define ERROR_CODE_AUTHENTICATION_FAILURE 0x05
#define ERROR_CODE_PIN_OR_KEY_MISSING 0x06
Expand All @@ -147,46 +147,46 @@
#define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS 0x0E
#define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
#define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED 0x10
#define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE 0x11

Check failure on line 150 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhJ&open=AZ0aQGzL_VoME7_WxVhJ&pullRequest=269
#define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS 0x12

Check failure on line 151 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhK&open=AZ0aQGzL_VoME7_WxVhK&pullRequest=269
#define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION 0x13
#define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
#define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF 0x15
#define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST 0x16

Check failure on line 155 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhO&open=AZ0aQGzL_VoME7_WxVhO&pullRequest=269
#define ERROR_CODE_REPEATED_ATTEMPTS 0x17
#define ERROR_CODE_PAIRING_NOT_ALLOWED 0x18

Check failure on line 157 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhQ&open=AZ0aQGzL_VoME7_WxVhQ&pullRequest=269
#define ERROR_CODE_UNKNOWN_LMP_PDU 0x19
#define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
#define ERROR_CODE_SCO_OFFSET_REJECTED 0x1B

Check failure on line 160 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhT&open=AZ0aQGzL_VoME7_WxVhT&pullRequest=269
#define ERROR_CODE_SCO_INTERVAL_REJECTED 0x1C
#define ERROR_CODE_SCO_AIR_MODE_REJECTED 0x1D
#define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
#define ERROR_CODE_UNSPECIFIED_ERROR 0x1F
#define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
#define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED 0x21
#define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22

Check failure on line 167 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhZ&open=AZ0aQGzL_VoME7_WxVhZ&pullRequest=269
#define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23
#define ERROR_CODE_LMP_PDU_NOT_ALLOWED 0x24
#define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE 0x25
#define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED 0x26

Check failure on line 171 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhd&open=AZ0aQGzL_VoME7_WxVhd&pullRequest=269
#define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED 0x27

Check failure on line 172 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhe&open=AZ0aQGzL_VoME7_WxVhe&pullRequest=269
#define ERROR_CODE_INSTANT_PASSED 0x28
#define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED 0x29
#define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION 0x2A
#define ERROR_CODE_RESERVED 0x2B
#define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER 0x2C
#define ERROR_CODE_QOS_REJECTED 0x2D

Check failure on line 178 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhk&open=AZ0aQGzL_VoME7_WxVhk&pullRequest=269
#define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED 0x2E

Check failure on line 179 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhl&open=AZ0aQGzL_VoME7_WxVhl&pullRequest=269
#define ERROR_CODE_INSUFFICIENT_SECURITY 0x2F
#define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE 0x30

Check failure on line 181 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhn&open=AZ0aQGzL_VoME7_WxVhn&pullRequest=269
// #define ERROR_CODE_RESERVED
#define ERROR_CODE_ROLE_SWITCH_PENDING 0x32
// #define ERROR_CODE_RESERVED
#define ERROR_CODE_RESERVED_SLOT_VIOLATION 0x34
#define ERROR_CODE_ROLE_SWITCH_FAILED 0x35
#define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36
#define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37

Check failure on line 188 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVhs&open=AZ0aQGzL_VoME7_WxVhs&pullRequest=269
#define ERROR_CODE_HOST_BUSY_PAIRING 0x38

Check failure on line 189 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVht&open=AZ0aQGzL_VoME7_WxVht&pullRequest=269
#define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
#define ERROR_CODE_CONTROLLER_BUSY 0x3A
#define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS 0x3B
Expand All @@ -194,7 +194,7 @@
#define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
#define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED 0x3E
#define ERROR_CODE_MAC_CONNECTION_FAILED 0x3F
#define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40

Check failure on line 197 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVh1&open=AZ0aQGzL_VoME7_WxVh1&pullRequest=269

// BTstack defined ERRORS, mapped into BLuetooth status code range

Expand Down Expand Up @@ -324,7 +324,7 @@
#define LM_LINK_POLICY_DISABLE_ALL_LM_MODES 0
#define LM_LINK_POLICY_ENABLE_ROLE_SWITCH 1
#define LM_LINK_POLICY_ENABLE_HOLD_MODE 2
#define LM_LINK_POLICY_ENABLE_SNIFF_MODE 3

Check failure on line 327 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVh4&open=AZ0aQGzL_VoME7_WxVh4&pullRequest=269

// ACL Connection Modes
#define ACL_CONNECTION_MODE_ACTIVE 0
Expand Down Expand Up @@ -380,7 +380,7 @@
#define OGF_LE_CONTROLLER 0x08
#define OGF_VENDOR 0x3f


#define HCI_CMD_OPCODE(ogf, ocf) ((ocf) | ((ogf) << 10))


/**
Expand Down Expand Up @@ -556,7 +556,7 @@
#define ATT_ERROR_WRITE_NOT_PERMITTED 0x03
#define ATT_ERROR_INVALID_PDU 0x04
#define ATT_ERROR_INSUFFICIENT_AUTHENTICATION 0x05
#define ATT_ERROR_REQUEST_NOT_SUPPORTED 0x06

Check failure on line 559 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVh6&open=AZ0aQGzL_VoME7_WxVh6&pullRequest=269
#define ATT_ERROR_INVALID_OFFSET 0x07
#define ATT_ERROR_INSUFFICIENT_AUTHORIZATION 0x08
#define ATT_ERROR_PREPARE_QUEUE_FULL 0x09
Expand Down Expand Up @@ -618,13 +618,13 @@

// MARK: GATT UUIDs
#define GATT_PRIMARY_SERVICE_UUID 0x2800
#define GATT_SECONDARY_SERVICE_UUID 0x2801

Check failure on line 621 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxViK&open=AZ0aQGzL_VoME7_WxViK&pullRequest=269
#define GATT_INCLUDE_SERVICE_UUID 0x2802
#define GATT_CHARACTERISTICS_UUID 0x2803
#define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES 0x2900
#define GATT_CHARACTERISTIC_USER_DESCRIPTION 0x2901
#define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION 0x2902
#define GATT_SERVER_CHARACTERISTICS_CONFIGURATION 0x2903

Check failure on line 627 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxViQ&open=AZ0aQGzL_VoME7_WxViQ&pullRequest=269
#define GATT_CHARACTERISTIC_PRESENTATION_FORMAT 0x2904
#define GATT_CHARACTERISTIC_AGGREGATE_FORMAT 0x2905

Expand All @@ -637,8 +637,8 @@
#define GAP_DEVICE_NAME_UUID 0x2a00
#define GAP_APPEARANCE_UUID 0x2a01
#define GAP_PERIPHERAL_PRIVACY_FLAG 0x2a02
#define GAP_RECONNECTION_ADDRESS_UUID 0x2a03

Check failure on line 640 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVia&open=AZ0aQGzL_VoME7_WxVia&pullRequest=269
#define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04

Check failure on line 641 in src/bluetooth.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGzL_VoME7_WxVib&open=AZ0aQGzL_VoME7_WxVib&pullRequest=269
#define GAP_SERVICE_CHANGED 0x2a05

// Bluetooth GATT types
Expand Down
10 changes: 10 additions & 0 deletions src/hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
}
#endif

static int hci_is_le_connection(hci_connection_t * connection){

Check warning on line 424 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "connection" is "hci_connection_t *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVio&open=AZ0aQG1s_VoME7_WxVio&pullRequest=269
switch (connection->address_type){
case BD_ADDR_TYPE_LE_PUBLIC:
case BD_ADDR_TYPE_LE_RANDOM:
Expand Down Expand Up @@ -528,7 +528,7 @@
}
return hci_stack->sco_packets_total_num - num_sco_packets_sent;
} else {
// implicit flow control -- TODO

Check warning on line 531 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1r_VoME7_WxVie&open=AZ0aQG1r_VoME7_WxVie&pullRequest=269
int num_ready = 0;
for (it = (btstack_linked_item_t *) hci_stack->connections; it ; it = it->next){
hci_connection_t * connection = (hci_connection_t *) it;
Expand Down Expand Up @@ -723,7 +723,7 @@
// pre: caller has reserved the packet buffer
int hci_send_acl_packet_buffer(int size){

// log_info("hci_send_acl_packet_buffer size %u", size);

Check warning on line 726 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjT&open=AZ0aQG1s_VoME7_WxVjT&pullRequest=269

if (!hci_stack->hci_packet_buffer_reserved) {
log_error("hci_send_acl_packet_buffer called without reserving packet buffer");
Expand Down Expand Up @@ -1532,7 +1532,7 @@
hci_run();
}

static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){

Check warning on line 1535 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "packet" is "unsigned char *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVit&open=AZ0aQG1s_VoME7_WxVit&pullRequest=269

Check failure on line 1535 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 72 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVis&open=AZ0aQG1s_VoME7_WxVis&pullRequest=269

UNUSED(size); // ok: less than 6 bytes are read from our buffer

Expand Down Expand Up @@ -1563,6 +1563,16 @@
}
}

#ifdef HAVE_EM9301_PATCH_CONTAINER
// EM9301 is in ISP mode
if ((hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT)
&& (hci_event_packet_get_type(packet) == HCI_EVENT_HARDWARE_ERROR)
&& (packet[2] == 0x80)){
// continue processing due normal behavior
command_completed = 1;
}
#endif

#if !defined(HAVE_PLATFORM_IPHONE_OS) && !defined (HAVE_HOST_CONTROLLER_API)

// Vendor == CSR
Expand Down Expand Up @@ -1924,7 +1934,7 @@
}
}
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_rssi)){
if (packet[5] == 0){

Check warning on line 1937 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVi2&open=AZ0aQG1s_VoME7_WxVi2&pullRequest=269
uint8_t event[5];
event[0] = GAP_EVENT_RSSI_MEASUREMENT;
event[1] = 3;
Expand Down Expand Up @@ -1995,8 +2005,8 @@
log_info("BR/EDR support %u, LE support %u", hci_classic_supported(), hci_le_supported());
}
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_version_information)){
// hci_stack->hci_version = little_endian_read_16(packet, 4);
// hci_stack->hci_revision = little_endian_read_16(packet, 6);

Check warning on line 2009 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjW&open=AZ0aQG1s_VoME7_WxVjW&pullRequest=269
uint16_t manufacturer = little_endian_read_16(packet, 10);
// map Cypress to Broadcom
if (manufacturer == BLUETOOTH_COMPANY_ID_CYPRESS_SEMICONDUCTOR){
Expand All @@ -2005,8 +2015,8 @@
little_endian_store_16(packet, 10, manufacturer);
}
hci_stack->manufacturer = manufacturer;
// hci_stack->lmp_version = little_endian_read_16(packet, 8);
// hci_stack->lmp_subversion = little_endian_read_16(packet, 12);

Check warning on line 2019 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjX&open=AZ0aQG1s_VoME7_WxVjX&pullRequest=269
log_info("Manufacturer: 0x%04x", hci_stack->manufacturer);
}
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
Expand All @@ -2022,7 +2032,7 @@
}
#ifdef ENABLE_CLASSIC
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_synchronous_flow_control_enable)){
if (packet[5] == 0){

Check warning on line 2035 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVi4&open=AZ0aQG1s_VoME7_WxVi4&pullRequest=269
hci_stack->synchronous_flow_control_enabled = 1;
}
}
Expand Down Expand Up @@ -2168,7 +2178,7 @@
conn->bonding_flags |= BONDING_REQUEST_REMOTE_FEATURES;

// queue set supervision timeout if we're master
if ((hci_stack->link_supervision_timeout != 0) && (conn->role == HCI_ROLE_MASTER)){

Check failure on line 2181 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxViw&open=AZ0aQG1s_VoME7_WxViw&pullRequest=269
connectionSetAuthenticationFlags(conn, WRITE_SUPERVISION_TIMEOUT);
}

Expand Down Expand Up @@ -2220,7 +2230,7 @@
conn = hci_connection_for_handle(handle);
if (!conn) break;
if (!packet[2]){
uint8_t * features = &packet[5];

Check warning on line 2233 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "features" is "unsigned char *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVi6&open=AZ0aQG1s_VoME7_WxVi6&pullRequest=269
if (features[6] & (1 << 3)){
conn->bonding_flags |= BONDING_REMOTE_SUPPORTS_SSP;
}
Expand Down Expand Up @@ -2469,7 +2479,7 @@
// outgoing connection establishment is done
hci_stack->le_connecting_state = LE_CONNECTING_IDLE;
// remove entry
if (conn){

Check failure on line 2482 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxViy&open=AZ0aQG1s_VoME7_WxViy&pullRequest=269
btstack_linked_list_remove(&hci_stack->connections, (btstack_linked_item_t *) conn);
btstack_memory_hci_connection_free( conn );
}
Expand Down Expand Up @@ -2690,7 +2700,7 @@
if (delta > 0){
conn->sco_rx_ms++;
}
// log_debug("sco rx %u", conn->sco_rx_ms);

Check warning on line 2703 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjZ&open=AZ0aQG1s_VoME7_WxVjZ&pullRequest=269
sco_schedule_tx(conn);
}
}
Expand Down Expand Up @@ -3303,7 +3313,7 @@

static void hci_run(void){

// log_info("hci_run: entered");

Check warning on line 3316 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVja&open=AZ0aQG1s_VoME7_WxVja&pullRequest=269
btstack_linked_item_t * it;

// send continuation fragments first, as they block the prepared packet buffer
Expand Down Expand Up @@ -3800,7 +3810,7 @@
if (!hci_can_send_command_packet_now()) return;

// check state
if (connection->state == SENT_DISCONNECT) return;

Check failure on line 3813 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjD&open=AZ0aQG1s_VoME7_WxVjD&pullRequest=269
connection->state = SENT_DISCONNECT;

log_info("HCI_STATE_HALTING, connection %p, handle %u", connection, con_handle);
Expand Down Expand Up @@ -4273,7 +4283,7 @@
event[2] = HCI_SUBEVENT_LE_CONNECTION_COMPLETE;
event[3] = status;
little_endian_store_16(event, 4, con_handle);
event[6] = 0; // TODO: role

Check warning on line 4286 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1r_VoME7_WxVii&open=AZ0aQG1r_VoME7_WxVii&pullRequest=269
event[7] = address_type;
reverse_bd_addr(address, &event[8]);
little_endian_store_16(event, 14, 0); // interval
Expand Down Expand Up @@ -4880,7 +4890,7 @@
* @param address
* @returns 0 if ok
*/
int gap_auto_connection_start(bd_addr_type_t address_type, bd_addr_t address){

Check warning on line 4893 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "address" is "unsigned char *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjO&open=AZ0aQG1s_VoME7_WxVjO&pullRequest=269
// check capacity
int num_entries = btstack_linked_list_count(&hci_stack->le_whitelist);
if (num_entries >= hci_stack->le_whitelist_capacity) return ERROR_CODE_MEMORY_CAPACITY_EXCEEDED;
Expand All @@ -4894,7 +4904,7 @@
return 0;
}

static void hci_remove_from_whitelist(bd_addr_type_t address_type, bd_addr_t address){

Check warning on line 4907 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "address" is "unsigned char *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjP&open=AZ0aQG1s_VoME7_WxVjP&pullRequest=269
btstack_linked_list_iterator_t it;
btstack_linked_list_iterator_init(&it, &hci_stack->le_whitelist);
while (btstack_linked_list_iterator_has_next(&it)){
Expand Down Expand Up @@ -5015,7 +5025,7 @@
return 0;
}

static int gap_pairing_set_state_and_run(bd_addr_t addr, uint8_t state){

Check warning on line 5028 in src/hci.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "addr" is "unsigned char *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQG1s_VoME7_WxVjR&open=AZ0aQG1s_VoME7_WxVjR&pullRequest=269
hci_stack->gap_pairing_state = state;
(void)memcpy(hci_stack->gap_pairing_addr, addr, 6);
hci_run();
Expand Down
2 changes: 1 addition & 1 deletion src/hci_transport_h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
}

// -----------------------------
static void hci_transport_inactivity_timeout_handler(btstack_timer_source_t * ts){

Check warning on line 199 in src/hci_transport_h5.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "ts" is "struct btstack_timer_source *".

See more on https://sonarcloud.io/project/issues?id=bluekitchen_btstack&issues=AZ0aQGvr_VoME7_WxVg1&open=AZ0aQGvr_VoME7_WxVg1&pullRequest=269
UNUSED(ts);
log_info("inactivity timeout. link state %d, peer asleep %u, actions 0x%02x, outgoing packet %u",
link_state, link_peer_asleep, hci_transport_link_actions, hci_transport_link_have_outgoing_packet());
Expand Down Expand Up @@ -738,7 +738,7 @@

// track time receiving SLIP frame
static uint32_t hci_transport_h5_receive_start;
static void hci_transport_h5_block_received(){
static void hci_transport_h5_block_received(void){
if (hci_transport_h5_active == 0) return;

// track start time when receiving first byte // a bit hackish
Expand Down