diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml index 8d5fd776..0ec5291a 100644 --- a/.github/workflows/clang-format-check.yaml +++ b/.github/workflows/clang-format-check.yaml @@ -9,11 +9,19 @@ jobs: formatting-check: name: Formatting Check runs-on: ubuntu-latest + strategy: + matrix: + path: + - check: 'src' + exclude: 'src/components/(cmd_nvs|cmd_system)' + - check: 'examples' + exclude: '' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run clang-format style check for C/C++/Protobuf programs. - uses: jidicula/clang-format-action@v4.6.2 + uses: jidicula/clang-format-action@v4.11.0 with: clang-format-version: '13' - check-path: 'src' - exclude-regex: 'src/components/(cmd_nvs|cmd_system)' + check-path: ${{ matrix.path['check'] }} + exclude-regex: ${{ matrix.path['exclude'] }} + diff --git a/examples/esp32/main/main.c b/examples/esp32/main/main.c index a6e62d18..6f81e026 100644 --- a/examples/esp32/main/main.c +++ b/examples/esp32/main/main.c @@ -7,7 +7,7 @@ #include #include "sdkconfig.h" -#include "uni_main.h" +#include "uni_init.h" #include "uni_platform.h" // Sanity check @@ -27,12 +27,12 @@ int app_main(void) { // hci_dump_init(hci_dump_embedded_stdout_get_instance()); #ifdef CONFIG_BLUEPAD32_PLATFORM_CUSTOM - // Must be called before uni_main() + // Must be called before uni_init() uni_platform_set_custom(get_my_platform()); #endif // CONFIG_BLUEPAD32_PLATFORM_CUSTOM // Init Bluepad32. - uni_main(0 /* argc */, NULL /* argv */); + uni_init(0 /* argc */, NULL /* argv */); // Does not return. btstack_run_loop_execute(); diff --git a/examples/linux/Makefile b/examples/linux/Makefile index 66df8a4f..11c17d10 100644 --- a/examples/linux/Makefile +++ b/examples/linux/Makefile @@ -105,10 +105,10 @@ bluepad32: ${CORE_OBJ} ${COMMON_OBJ} ${CLASSIC_OBJ} ${SDP_CLIENT} btstack_ring_b ${BLUEPAD32_ROOT}/uni_hid_parser_switch.o \ ${BLUEPAD32_ROOT}/uni_hid_parser_wii.o \ ${BLUEPAD32_ROOT}/uni_hid_parser_xboxone.o \ + ${BLUEPAD32_ROOT}/uni_init.o \ ${BLUEPAD32_ROOT}/uni_joystick.o \ ${BLUEPAD32_ROOT}/uni_keyboard.o \ ${BLUEPAD32_ROOT}/uni_log.o \ - ${BLUEPAD32_ROOT}/uni_main.o \ ${BLUEPAD32_ROOT}/uni_mouse.o \ ${BLUEPAD32_ROOT}/uni_platform.o \ ${BLUEPAD32_ROOT}/uni_property.o \ diff --git a/examples/linux/main.c b/examples/linux/main.c index 7731b71c..b6690b93 100644 --- a/examples/linux/main.c +++ b/examples/linux/main.c @@ -44,13 +44,13 @@ // ***************************************************************************** #include +#include +#include #include #include #include #include -#include #include -#include #include "btstack_config.h" @@ -77,7 +77,7 @@ // Bluepad32 related #include "sdkconfig.h" -#include "uni_main.h" +#include "uni_init.h" #include "uni_platform.h" // Local includes @@ -89,11 +89,11 @@ #define TLV_DB_PATH_POSTFIX ".tlv" static char tlv_db_path[100]; static bool tlv_reset; -static const btstack_tlv_t * tlv_impl; -static btstack_tlv_posix_t tlv_context; -static bd_addr_t local_addr; +static const btstack_tlv_t* tlv_impl; +static btstack_tlv_posix_t tlv_context; +static bd_addr_t local_addr; -int btstack_main(int argc, const char * argv[]); +int btstack_main(int argc, const char* argv[]); static bd_addr_t static_address; static int using_static_address; @@ -103,19 +103,19 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; // shutdown static bool shutdown_triggered; -static void local_version_information_handler(uint8_t * packet){ +static void local_version_information_handler(uint8_t* packet) { printf("Local version information:\n"); - uint16_t hci_version = packet[6]; - uint16_t hci_revision = little_endian_read_16(packet, 7); - uint16_t lmp_version = packet[9]; - uint16_t manufacturer = little_endian_read_16(packet, 10); + uint16_t hci_version = packet[6]; + uint16_t hci_revision = little_endian_read_16(packet, 7); + uint16_t lmp_version = packet[9]; + uint16_t manufacturer = little_endian_read_16(packet, 10); uint16_t lmp_subversion = little_endian_read_16(packet, 12); printf("- HCI Version 0x%04x\n", hci_version); printf("- HCI Revision 0x%04x\n", hci_revision); printf("- LMP Version 0x%04x\n", lmp_version); printf("- LMP Subversion 0x%04x\n", lmp_subversion); printf("- Manufacturer 0x%04x\n", manufacturer); - switch (manufacturer){ + switch (manufacturer) { case BLUETOOTH_COMPANY_ID_THE_LINUX_FOUNDATION: printf("- Linux Foundation - assume Zephyr hci_usb firmware running on nRF52xx\n"); // setup Zephyr chipset support @@ -128,19 +128,20 @@ static void local_version_information_handler(uint8_t * packet){ } } -static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ +static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t* packet, uint16_t size) { UNUSED(channel); UNUSED(size); uint8_t i; uint8_t usb_path_len; - const uint8_t * usb_path; + const uint8_t* usb_path; uint16_t product_id; uint16_t vendor_id; - const uint8_t * params; + const uint8_t* params; - if (packet_type != HCI_EVENT_PACKET) return; + if (packet_type != HCI_EVENT_PACKET) + return; - switch (hci_event_packet_get_type(packet)){ + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_TRANSPORT_USB_INFO: usb_path_len = hci_event_transport_usb_info_get_path_len(packet); usb_path = hci_event_transport_usb_info_get_path(packet); @@ -148,8 +149,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack product_id = hci_event_transport_usb_info_get_product_id(packet); vendor_id = hci_event_transport_usb_info_get_vendor_id(packet); printf("USB device 0x%04x/0x%04x, path: ", vendor_id, product_id); - for (i=0;i #include "sdkconfig.h" +#include "uni_init.h" #include "uni_log.h" -#include "uni_main.h" #include "uni_platform.h" // Sanity check @@ -30,11 +30,11 @@ int main() { // Turn-on LED. Turn it off once init is done. cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1); - // Must be called before uni_main() + // Must be called before uni_init() uni_platform_set_custom(get_my_platform()); // Initialize BP32 - uni_main(0, NULL); + uni_init(0, NULL); // Does not return. btstack_run_loop_execute(); diff --git a/src/components/bluepad32/CMakeLists.txt b/src/components/bluepad32/CMakeLists.txt index 702c4809..5b8d559c 100644 --- a/src/components/bluepad32/CMakeLists.txt +++ b/src/components/bluepad32/CMakeLists.txt @@ -28,10 +28,10 @@ set(srcs "uni_balance_board.c" "uni_hid_parser_switch.c" "uni_hid_parser_wii.c" "uni_hid_parser_xboxone.c" + "uni_init.c" "uni_joystick.c" "uni_keyboard.c" "uni_log.c" - "uni_main.c" "uni_mouse.c" "uni_platform.c" "uni_platform_arduino.c" diff --git a/src/components/bluepad32/include/uni_main.h b/src/components/bluepad32/include/uni_init.h similarity index 79% rename from src/components/bluepad32/include/uni_main.h rename to src/components/bluepad32/include/uni_init.h index 2b99b8ef..59b344e0 100644 --- a/src/components/bluepad32/include/uni_main.h +++ b/src/components/bluepad32/include/uni_init.h @@ -16,9 +16,12 @@ See the License for the specific language governing permissions and limitations under the License. ****************************************************************************/ -#ifndef UNI_MAIN_H -#define UNI_MAIN_H +#ifndef UNI_INIT_H +#define UNI_INIT_H -int uni_main(int argc, const char** argv); +/* Initialize Bluepad32. + * argc / argv are parameters passed to the 'platform' + */ +int uni_init(int argc, const char** argv); -#endif // UNI_MAIN_H +#endif // UNI_INIT_H diff --git a/src/components/bluepad32/uni_esp32.c b/src/components/bluepad32/uni_esp32.c index d51c321d..7d9e4e8c 100644 --- a/src/components/bluepad32/uni_esp32.c +++ b/src/components/bluepad32/uni_esp32.c @@ -36,7 +36,7 @@ limitations under the License. #include #include "uni_config.h" -#include "uni_main.h" +#include "uni_init.h" #ifdef UNI_ENABLE_BREDR _Static_assert(CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN >= 2, "Max ACL must be >= 2"); diff --git a/src/components/bluepad32/uni_main.c b/src/components/bluepad32/uni_init.c similarity index 94% rename from src/components/bluepad32/uni_main.c rename to src/components/bluepad32/uni_init.c index ddc940e0..05efe6d8 100644 --- a/src/components/bluepad32/uni_main.c +++ b/src/components/bluepad32/uni_init.c @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. ****************************************************************************/ -#include "uni_main.h" +#include "uni_init.h" #include "sdkconfig.h" #include "uni_bt_allowlist.h" @@ -31,8 +31,7 @@ limitations under the License. #include "uni_version.h" #include "uni_virtual_device.h" -// Main entry point, runs forever -int uni_main(int argc, const char** argv) { +int uni_init(int argc, const char** argv) { #ifdef CONFIG_IDF_TARGET uni_esp32_init(); #endif diff --git a/src/main/main.c b/src/main/main.c index 1186f273..cd2ebd45 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -21,7 +21,7 @@ limitations under the License. #include #include "sdkconfig.h" -#include "uni_main.h" +#include "uni_init.h" #include "uni_platform.h" #ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO @@ -41,7 +41,7 @@ int app_main(void) { // hci_dump_init(hci_dump_embedded_stdout_get_instance()); // Init Bluepad32. - uni_main(0 /* argc */, NULL /* argv */); + uni_init(0 /* argc */, NULL /* argv */); // Does not return. btstack_run_loop_execute();