Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- UL: Nero Radio static parse and display more data (by @xMasterX)
- UL: Marantec protocol implement CRC verification display and add manually support (by @xMasterX & @li0ard, original code by @Skorpionm)
- UL: Keeloq Comunello add manually support (by @xMasterX)
- BT Remote: Add Rename Option, simplify Bad KB BLE profile (by @aaronjamt & @WillyJL)
- MNTM Settings: Add Skip Sliding Animations option for Lockscreen (by @aaronjamt)

### Updated:
Expand Down
2 changes: 1 addition & 1 deletion applications/main/bad_usb/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ App(
icon="A_BadUsb_14",
order=70,
resources="resources",
fap_libs=["assets"],
fap_libs=["assets", "ble_profile"],
fap_icon="icon.png",
fap_category="Tools",
)
4 changes: 2 additions & 2 deletions applications/main/bad_usb/helpers/bad_usb_hid.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bad_usb_hid.h"
#include "ble_hid_profile.h"
#include "ble_hid_ext_profile.h"
#include <bt/bt_service/bt.h>
#include <bt/bt_service/bt_i.h>
#include <storage/storage.h>
Expand Down Expand Up @@ -173,7 +173,7 @@ void* hid_ble_init(BadUsbHidConfig* hid_cfg) {
bt_keys_storage_set_storage_path(ble_hid->bt, APP_DATA_PATH(HID_BT_KEYS_STORAGE_NAME));

hid_ble_adjust_config(hid_cfg);
ble_hid->profile = bt_profile_start(ble_hid->bt, ble_profile_hid, &hid_cfg->ble);
ble_hid->profile = bt_profile_start(ble_hid->bt, ble_profile_hid_ext, &hid_cfg->ble);
furi_check(ble_hid->profile);

furi_hal_bt_start_advertising();
Expand Down
4 changes: 2 additions & 2 deletions applications/main/bad_usb/helpers/bad_usb_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern "C" {
#include <furi.h>
#include <furi_hal.h>

#include "ble_hid_profile.h"
#include "ble_hid_ext_profile.h"

typedef enum {
BadUsbHidInterfaceUsb,
Expand All @@ -16,7 +16,7 @@ typedef enum {
} BadUsbHidInterface;

typedef struct {
BleProfileHidParams ble;
BleProfileHidExtParams ble;
FuriHalUsbHidConfig usb;
} BadUsbHidConfig;

Expand Down
43 changes: 43 additions & 0 deletions applications/main/bad_usb/helpers/ble_hid_ext_profile.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "ble_hid_ext_profile.h"

#include <furi.h>

static FuriHalBleProfileBase* ble_profile_hid_ext_start(FuriHalBleProfileParams profile_params) {
UNUSED(profile_params);

return ble_profile_hid->start(NULL);
}

static void ble_profile_hid_ext_stop(FuriHalBleProfileBase* profile) {
ble_profile_hid->stop(profile);
}

static void
ble_profile_hid_ext_get_config(GapConfig* config, FuriHalBleProfileParams profile_params) {
furi_check(config);
furi_check(profile_params);
BleProfileHidExtParams* hid_ext_profile_params = profile_params;

// Setup config with basic profile
ble_profile_hid->get_gap_config(config, NULL);

// Set MAC address
memcpy(config->mac_address, hid_ext_profile_params->mac, sizeof(config->mac_address));

// Set advertise name (skip first byte which is the ADV type)
strlcpy(config->adv_name + 1, hid_ext_profile_params->name, sizeof(config->adv_name) - 1);

// Set bonding mode
config->bonding_mode = hid_ext_profile_params->bonding;

// Set pairing method
config->pairing_method = hid_ext_profile_params->pairing;
}

static const FuriHalBleProfileTemplate profile_callbacks = {
.start = ble_profile_hid_ext_start,
.stop = ble_profile_hid_ext_stop,
.get_gap_config = ble_profile_hid_ext_get_config,
};

const FuriHalBleProfileTemplate* ble_profile_hid_ext = &profile_callbacks;
17 changes: 17 additions & 0 deletions applications/main/bad_usb/helpers/ble_hid_ext_profile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <ble_profile/extra_profiles/hid_profile.h>

/**
* Optional arguments to pass along with profile template as
* FuriHalBleProfileParams for tuning profile behavior
**/
typedef struct {
char name[FURI_HAL_BT_ADV_NAME_LENGTH]; /**< Full device name */
uint8_t mac[GAP_MAC_ADDR_SIZE]; /**< Full device address */
bool bonding; /**< Save paired devices */
GapPairing pairing; /**< Pairing security method */
} BleProfileHidExtParams;

/** Hid Keyboard Profile descriptor */
extern const FuriHalBleProfileTemplate* ble_profile_hid_ext;
Loading