clang-format
This commit is contained in:
parent
b3e6051b8e
commit
bdeb2b85e7
11
.clang-format
Normal file
11
.clang-format
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
BasedOnStyle: WebKit
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Always
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
|
||||||
|
# this doesn't come out until clang-format 15 :(
|
||||||
|
#InsertBraces: true
|
|
@ -2,6 +2,6 @@
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
cmake cmakeCurses ninja python3 gcc-arm-embedded
|
cmake cmakeCurses ninja python3 gcc-arm-embedded
|
||||||
picotool
|
picotool clang-tools
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include "btstack.h"
|
#include "btstack.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "hci_dump_segger_rtt_stdout.h"
|
#include "hci_dump_segger_rtt_stdout.h"
|
||||||
#include "pico/cyw43_arch.h"
|
|
||||||
#include "pico/btstack_cyw43.h"
|
#include "pico/btstack_cyw43.h"
|
||||||
|
#include "pico/cyw43_arch.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "stdio_rtt.h"
|
#include "stdio_rtt.h"
|
||||||
#include "vibe_bt.h"
|
#include "vibe_bt.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef CYW43_WL_GPIO_LED_PIN
|
#ifndef CYW43_WL_GPIO_LED_PIN
|
||||||
#error no WiFi LED on board, wrong -DPICO_BOARD?
|
#error no WiFi LED on board, wrong -DPICO_BOARD?
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "pico/stdio/driver.h"
|
|
||||||
#include "stdio_rtt.h"
|
#include "stdio_rtt.h"
|
||||||
#include "SEGGER_RTT.h"
|
#include "SEGGER_RTT.h"
|
||||||
|
#include "pico/stdio/driver.h"
|
||||||
|
|
||||||
void stdio_rtt_init(void) {
|
void stdio_rtt_init(void) {
|
||||||
stdio_set_driver_enabled(&stdio_rtt, true);
|
stdio_set_driver_enabled(&stdio_rtt, true);
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include "vibe_bt.h"
|
#include "vibe_bt.h"
|
||||||
#include "vibe.h"
|
#include "vibe.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define APP_AD_FLAGS 0x06
|
#define APP_AD_FLAGS 0x06
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
static const uint8_t adv_data[] = {
|
static const uint8_t adv_data[] = {
|
||||||
// Flags general discoverable
|
// Flags general discoverable
|
||||||
0x02, BLUETOOTH_DATA_TYPE_FLAGS, APP_AD_FLAGS,
|
0x02,
|
||||||
|
BLUETOOTH_DATA_TYPE_FLAGS,
|
||||||
|
APP_AD_FLAGS,
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
0x0E, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 's', 'a', 'k', 'u', 'r', 'a', 'n', 'e', 'k', 'o', '-', '0', '3',
|
0x0E,
|
||||||
|
BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME,
|
||||||
|
's', 'a', 'k', 'u', 'r', 'a', 'n', 'e', 'k', 'o', '-', '0', '3',
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t adv_data_len = sizeof(adv_data);
|
static const uint8_t adv_data_len = sizeof(adv_data);
|
||||||
|
|
||||||
bool bt_connected = false;
|
bool bt_connected = false;
|
||||||
|
@ -22,12 +30,14 @@ void bt_packet_handler(
|
||||||
UNUSED(size);
|
UNUSED(size);
|
||||||
UNUSED(channel);
|
UNUSED(channel);
|
||||||
bd_addr_t local_addr;
|
bd_addr_t local_addr;
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET)
|
||||||
|
return;
|
||||||
|
|
||||||
uint8_t event_type = hci_event_packet_get_type(packet);
|
uint8_t event_type = hci_event_packet_get_type(packet);
|
||||||
switch (event_type) {
|
switch (event_type) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) return;
|
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING)
|
||||||
|
return;
|
||||||
gap_local_bd_addr(local_addr);
|
gap_local_bd_addr(local_addr);
|
||||||
printf("BTstack up and running on %s.\n", bd_addr_to_str(local_addr));
|
printf("BTstack up and running on %s.\n", bd_addr_to_str(local_addr));
|
||||||
|
|
||||||
|
@ -83,13 +93,17 @@ int bt_att_write_callback(
|
||||||
printf("%02x ", buffer[i]);
|
printf("%02x ", buffer[i]);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
||||||
if (att_handle != ATT_CHARACTERISTIC_0000ffe1_0000_1000_8000_00805f9b34fb_01_VALUE_HANDLE) return 0;
|
if (att_handle != ATT_CHARACTERISTIC_0000ffe1_0000_1000_8000_00805f9b34fb_01_VALUE_HANDLE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Buttplug.io always sends
|
// Buttplug.io always sends
|
||||||
// 0xa1, 0x08, 0x01, 0x00, 0x00, 0x00, 0x64, PERCENTAGE, 0x00, 0x64, 0xdf, 0x55,
|
// 0xa1, 0x08, 0x01, 0x00, 0x00, 0x00, 0x64, PERCENTAGE, 0x00, 0x64, 0xdf, 0x55,
|
||||||
if (buffer_size != 12) return 0;
|
if (buffer_size != 12)
|
||||||
if (memcmp(buffer, "\xA1\x08\x01\x00\x00\x00\x64", 7) != 0) return 0;
|
return 0;
|
||||||
if (memcmp(buffer + 8, "\x00\x64\xDF\x55", 4) != 0) return 0;
|
if (memcmp(buffer, "\xA1\x08\x01\x00\x00\x00\x64", 7) != 0)
|
||||||
|
return 0;
|
||||||
|
if (memcmp(buffer + 8, "\x00\x64\xDF\x55", 4) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// In case it somehow came unset
|
// In case it somehow came unset
|
||||||
bt_connected = true;
|
bt_connected = true;
|
||||||
|
|
Loading…
Reference in a new issue