Skip to content

Commit

Permalink
iOS Apple Media Service (#111)
Browse files Browse the repository at this point in the history
* ios Apple Media Service
  • Loading branch information
ldab authored Nov 16, 2023
1 parent 1c901bd commit 297c048
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ jobs:
west build app --build-dir ${{ matrix.board }}_${{ matrix.built_type }} -p -b ${{ matrix.board }} -- -DOVERLAY_CONFIG=boards/${{ matrix.built_type }}.conf
cd ${{ matrix.board }}_${{ matrix.built_type }}/zephyr
mv zephyr.hex ${{ matrix.board }}_${{ matrix.built_type }}.hex || true
- name: Build firmware for iOS
working-directory: ZSWatch
run: |
west build app --build-dir ${{ matrix.board }}_${{ matrix.built_type }}_ios -p -b ${{ matrix.board }} -- -DOVERLAY_CONFIG=boards/${{ matrix.built_type }}.conf -DCONFIG_BLE_USES_AMS="y"
cd ${{ matrix.board }}_${{ matrix.built_type }}/zephyr
mv zephyr.hex ${{ matrix.board }}_${{ matrix.built_type }}.hex || true
- name : Upload Firmware
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build
build*
*.code-workspace
*__pycache__*
nrf/

# Zephyr workspace
/.west
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
"nrf-connect.debugging.bindings": {
"${workspaceFolder}/app/build": "Launch build"
},
"editor.defaultFormatter": "chiehyu.vscode-astyle"
}
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ target_sources(app PRIVATE src/ble/ble_aoa.c)
target_sources(app PRIVATE src/ble/ble_comm.c)
target_sources(app PRIVATE src/ble/ble_transport.c)
target_sources(app PRIVATE src/ble/zsw_gatt_sensor_server.c)
target_sources_ifdef(CONFIG_BLE_USES_AMS app PRIVATE src/ble/ble_ams.c)

target_sources(app PRIVATE src/sensors/zsw_imu.c)
target_sources(app PRIVATE src/sensors/zsw_pressure_sensor.c)
Expand Down
16 changes: 16 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ menu "ZSWatch"
default n
help
"Disable encryption for BLE connection (pairing/bonding). Used only for debugging purposes."

choice BLE_SMARTPHONE_INTERFACE
bool
prompt "Select which BLE smartphone interface to use."
def_bool BLE_USES_GADGETBRIDGE
help
"If using with iOS you likely use AMS"

config BLE_USES_GADGETBRIDGE
prompt "Smartphone interaction and notifications uses Gadgetbridge"
config BLE_USES_AMS
prompt "Smartphone uses Apple Media Service Client"
select BT_GATT_DM
select BT_AMS_CLIENT
endchoice

endmenu

menu "SPI RTT Flash Loader"
Expand Down
28 changes: 28 additions & 0 deletions app/src/applications/music_control/music_control_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <zsw_clock.h>
#include <zephyr/zbus/zbus.h>

#ifdef CONFIG_BLE_USES_AMS
#include "ble/ble_ams.h"
#endif

#include "music_control_ui.h"
#include "ble/ble_comm.h"
#include "events/ble_data_event.h"
Expand Down Expand Up @@ -58,6 +62,8 @@ static void on_music_ui_evt_music(music_control_ui_evt_type_t evt_type)
uint8_t buf[50];
int msg_len = 0;

#if defined(CONFIG_BLE_USES_GADGETBRIDGE)

switch (evt_type) {
case MUSIC_CONTROL_UI_CLOSE:
zsw_app_manager_app_close_request(&app);
Expand All @@ -78,6 +84,28 @@ static void on_music_ui_evt_music(music_control_ui_evt_type_t evt_type)
if (msg_len > 0) {
ble_comm_send(buf, msg_len);
}

#elif defined(CONFIG_BLE_USES_AMS)

switch (evt_type) {
case MUSIC_CONTROL_UI_CLOSE:
zsw_app_manager_app_close_request(&app);
break;
case MUSIC_CONTROL_UI_PLAY:
ble_ams_play_pause();
break;
case MUSIC_CONTROL_UI_PAUSE:
ble_ams_play_pause();
break;
case MUSIC_CONTROL_UI_NEXT_TRACK:
ble_ams_next_track();
break;
case MUSIC_CONTROL_UI_PREV_TRACK:
ble_ams_previous_track();
break;
}

#endif // CONFIG_BLE_USES_AMS
}

static void zbus_ble_comm_data_callback(const struct zbus_channel *chan)
Expand Down
Loading

0 comments on commit 297c048

Please sign in to comment.