Skip to content

Commit

Permalink
triggerble updates
Browse files Browse the repository at this point in the history
by Willy-JL
  • Loading branch information
xMasterX committed Feb 19, 2024
1 parent fb12c36 commit 79de917
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps_source_code/bluetooth-trigger/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ App(
fap_icon="bt_trigger_logo.png",
fap_category="Bluetooth",
fap_icon_assets="assets",
fap_libs=["ble_profile"],
fap_author="@Nem0oo",
fap_weburl="https://github.com/Nem0oo/flipper-zero-bluetooth-trigger",
fap_version="1.2",
Expand Down
31 changes: 17 additions & 14 deletions apps_source_code/bluetooth-trigger/bt_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ __int32_t bt_trigger_app(void* p) {
UNUSED(p);
AppStruct* app = appStructAlloc();

//bt_disconnect(app->bt);
bt_disconnect(app->bt);

// Wait 2nd core to update nvm storage
//furi_delay_ms(200);
furi_delay_ms(200);

bt_keys_storage_set_storage_path(app->bt, HID_BT_KEYS_STORAGE_PATH);

if(!bt_set_profile(app->bt, BtProfileHidKeyboard)) {
FURI_LOG_E(TAG, "Failed to switch to HID profile");
}
app->ble_hid_profile = bt_profile_start(app->bt, ble_profile_hid, NULL);
furi_check(app->ble_hid_profile);

furi_hal_bt_start_advertising();
bt_set_status_changed_callback(app->bt, bt_hid_connection_status_changed_callback, app);
Expand Down Expand Up @@ -58,8 +57,10 @@ __int32_t bt_trigger_app(void* p) {
if(app->delay > 0) {
app->shooting = !app->shooting;
if(app->shooting) {
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_press(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_release(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
notification_message(app->notifications, &sequence_blink_blue_100);
app->shots++;
//Timer triggered every delay ms
Expand Down Expand Up @@ -87,8 +88,10 @@ __int32_t bt_trigger_app(void* p) {
break;
case(InputKeyRight): //Take a shot
if(!app->shooting) {
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_press(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_release(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
notification_message(app->notifications, &sequence_blink_blue_100);
app->shots++;
}
Expand All @@ -102,8 +105,10 @@ __int32_t bt_trigger_app(void* p) {
case(EventTypeTick):
if(app->shooting) {
//sending command to trigger via BT
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_press(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
ble_profile_hid_consumer_key_release(
app->ble_hid_profile, HID_CONSUMER_VOLUME_INCREMENT);
notification_message(app->notifications, &sequence_blink_blue_100);
app->shots++;
}
Expand All @@ -120,9 +125,7 @@ __int32_t bt_trigger_app(void* p) {
// Wait 2nd core to update nvm storage
furi_delay_ms(200);
bt_keys_storage_set_default_path(app->bt);
if(!bt_set_profile(app->bt, BtProfileSerial)) {
FURI_LOG_E(TAG, "Failed to switch to Serial profile");
}
furi_check(bt_profile_restore_default(app->bt));

//Freeing memory
furi_message_queue_free(event_queue);
Expand Down
4 changes: 3 additions & 1 deletion apps_source_code/bluetooth-trigger/bt_trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <furi.h>
#include <furi_hal_bt.h>
#include <furi_hal_usb_hid.h>
#include <furi_hal_bt_hid.h>
#include <extra_profiles/hid_profile.h>
#include <gui/gui.h>
#include <input/input.h>
#include <notification/notification_messages.h>
Expand All @@ -15,6 +15,7 @@
#include <dolphin/dolphin.h>
#include "bt_trigger_icons.h"


#define HID_BT_KEYS_STORAGE_PATH EXT_PATH("apps_data/hid_ble/.bt_hid.keys")
#define TAG "bt_trigger"

Expand All @@ -33,6 +34,7 @@ typedef struct {

typedef struct {
Bt* bt;
FuriHalBleProfileBase* ble_hid_profile;
Gui* gui;
NotificationApp* notifications;
ViewPort* view_port;
Expand Down

0 comments on commit 79de917

Please sign in to comment.