diff options
-rw-r--r-- | .gitpod.yml | 18 | ||||
-rw-r--r-- | doc/ble.md | 23 | ||||
-rw-r--r-- | docker/.gitpod.Dockerfile | 39 | ||||
-rw-r--r-- | src/components/ble/MusicService.cpp | 88 | ||||
-rw-r--r-- | src/components/ble/MusicService.h | 30 | ||||
-rw-r--r-- | src/libs/lvgl/patches/0002-fix_bug_in_animation_management_for_lv_label.patch | 51 | ||||
-rw-r--r-- | src/libs/lvgl/src/lv_misc/lv_anim.c | 4 | ||||
-rw-r--r-- | src/libs/lvgl/src/lv_misc/lv_anim.h | 6 |
8 files changed, 213 insertions, 46 deletions
diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..0af6dce8 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,18 @@ +image: + file: docker/.gitpod.Dockerfile +github: + prebuilds: + # enable for the master/default branch (defaults to true) + master: true + # enable for all branches in this repo (defaults to false) + branches: false + # enable for pull requests coming from this repo (defaults to true) + pullRequests: false + # enable for pull requests coming from forks (defaults to false) + pullRequestsFromForks: false + # add a "Review in Gitpod" button as a comment to pull requests (defaults to true) + addComment: true + # add a "Review in Gitpod" button to pull requests (defaults to false) + addBadge: false + # add a label once the prebuild is ready to pull requests (defaults to false) + addLabel: false #prebuilt-in-gitpod
\ No newline at end of file @@ -15,6 +15,29 @@ If **CTS** is detected, it'll request the current time to the companion applicat ![BLE connection sequence diagram](ble/connection_sequence.png "BLE connection sequence diagram") +## BLE UUIDs +When possible, InfiniTime tries to implement BLE services defined by the BLE specification. + +When the service does not exist in the BLE specification, InfiniTime implement custom services. As all BLE services, custom services are identified by a UUID. Here is how to define the UUID of custom services in InfiniTime: + +``` + - Base UUID : xxxxxxxx-78fc-48fe-8e23-433b3a1942d0 + - Service UUID : SSSS0000-78fc-48fe-8e23-433b3a1942d0 where SSSS is the service ID + - Characteristic UUID : SSSSCCCC-78fc-48fe-8e23-433b3a1942d0 where CCCC is the characteristic ID for the service SSSS and is different than 0 +``` + +The following custom services are implemented in InfiniTime: + + - Since InfiniTime 0.8: + ``` + * Music Service : 00000000-78fc-48fe-8e23-433b3a1942d0 + ``` + + - Since InfiniTime 0.11: + ``` + * Navigation Service : 00010000-78fc-48fe-8e23-433b3a1942d0 + ``` + ## BLE services [List of standard BLE services](https://www.bluetooth.com/specifications/gatt/services/) diff --git a/docker/.gitpod.Dockerfile b/docker/.gitpod.Dockerfile new file mode 100644 index 00000000..71bf479b --- /dev/null +++ b/docker/.gitpod.Dockerfile @@ -0,0 +1,39 @@ +FROM gitpod/workspace-full + +USER root +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update -qq \ + && apt-get install -y \ +# x86_64 / generic packages + bash \ + build-essential \ + cmake \ + git \ + make \ + python3 \ + python3-pip \ + tar \ + unzip \ + wget \ +# aarch64 packages + libffi-dev \ + libssl-dev \ + python3-dev \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; + +# Needs to be installed as root +RUN pip3 install adafruit-nrfutil + +COPY docker/build.sh /opt/ +# Lets get each in a separate docker layer for better downloads +# GCC +RUN bash -c "source /opt/build.sh; GetGcc;" +# NrfSdk +RUN bash -c "source /opt/build.sh; GetNrfSdk;" +# McuBoot +RUN bash -c "source /opt/build.sh; GetMcuBoot;" + +# Link the default checkout workspace in to the default $SOURCES_DIR +RUN ln -s /workspace/Pinetime /sources + +USER gitpod
\ No newline at end of file diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp index fdecb6b3..bd6e27fb 100644 --- a/src/components/ble/MusicService.cpp +++ b/src/components/ble/MusicService.cpp @@ -24,32 +24,68 @@ int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_acces } Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system) { - msUuid.value[11] = msId[0]; - msUuid.value[12] = msId[1]; - msEventCharUuid.value[11] = msEventCharId[0]; - msEventCharUuid.value[12] = msEventCharId[1]; - msStatusCharUuid.value[11] = msStatusCharId[0]; - msStatusCharUuid.value[12] = msStatusCharId[1]; - msTrackCharUuid.value[11] = msTrackCharId[0]; - msTrackCharUuid.value[12] = msTrackCharId[1]; - msArtistCharUuid.value[11] = msArtistCharId[0]; - msArtistCharUuid.value[12] = msArtistCharId[1]; - msAlbumCharUuid.value[11] = msAlbumCharId[0]; - msAlbumCharUuid.value[12] = msAlbumCharId[1]; - msPositionCharUuid.value[11] = msPositionCharId[0]; - msPositionCharUuid.value[12] = msPositionCharId[1]; - msTotalLengthCharUuid.value[11] = msTotalLengthCharId[0]; - msTotalLengthCharUuid.value[12] = msTotalLengthCharId[1]; - msTrackNumberCharUuid.value[11] = msTrackNumberCharId[0]; - msTrackNumberCharUuid.value[12] = msTrackNumberCharId[1]; - msTrackTotalCharUuid.value[11] = msTrackTotalCharId[0]; - msTrackTotalCharUuid.value[12] = msTrackTotalCharId[1]; - msPlaybackSpeedCharUuid.value[11] = msPlaybackSpeedCharId[0]; - msPlaybackSpeedCharUuid.value[12] = msPlaybackSpeedCharId[1]; - msRepeatCharUuid.value[11] = msRepeatCharId[0]; - msRepeatCharUuid.value[12] = msRepeatCharId[1]; - msShuffleCharUuid.value[11] = msShuffleCharId[0]; - msShuffleCharUuid.value[12] = msShuffleCharId[1]; + msUuid.value[14] = msId[0]; + msUuid.value[15] = msId[1]; + + msEventCharUuid.value[12] = msEventCharId[0]; + msEventCharUuid.value[13] = msEventCharId[1]; + msEventCharUuid.value[14] = msId[0]; + msEventCharUuid.value[15] = msId[1]; + + msStatusCharUuid.value[12] = msStatusCharId[0]; + msStatusCharUuid.value[13] = msStatusCharId[1]; + msStatusCharUuid.value[14] = msId[0]; + msStatusCharUuid.value[15] = msId[1]; + + msTrackCharUuid.value[12] = msTrackCharId[0]; + msTrackCharUuid.value[13] = msTrackCharId[1]; + msTrackCharUuid.value[14] = msId[0]; + msTrackCharUuid.value[15] = msId[1]; + + msArtistCharUuid.value[12] = msArtistCharId[0]; + msArtistCharUuid.value[13] = msArtistCharId[1]; + msArtistCharUuid.value[14] = msId[0]; + msArtistCharUuid.value[15] = msId[1]; + + msAlbumCharUuid.value[12] = msAlbumCharId[0]; + msAlbumCharUuid.value[13] = msAlbumCharId[1]; + msAlbumCharUuid.value[14] = msId[0]; + msAlbumCharUuid.value[15] = msId[1]; + + msPositionCharUuid.value[12] = msPositionCharId[0]; + msPositionCharUuid.value[13] = msPositionCharId[1]; + msPositionCharUuid.value[14] = msId[0]; + msPositionCharUuid.value[15] = msId[1]; + + msTotalLengthCharUuid.value[12] = msTotalLengthCharId[0]; + msTotalLengthCharUuid.value[13] = msTotalLengthCharId[1]; + msTotalLengthCharUuid.value[14] = msId[0]; + msTotalLengthCharUuid.value[15] = msId[1]; + + msTrackNumberCharUuid.value[12] = msTrackNumberCharId[0]; + msTrackNumberCharUuid.value[13] = msTrackNumberCharId[1]; + msTrackNumberCharUuid.value[14] = msId[0]; + msTrackNumberCharUuid.value[15] = msId[1]; + + msTrackTotalCharUuid.value[12] = msTrackTotalCharId[0]; + msTrackTotalCharUuid.value[13] = msTrackTotalCharId[1]; + msTrackTotalCharUuid.value[14] = msId[0]; + msTrackTotalCharUuid.value[15] = msId[1]; + + msPlaybackSpeedCharUuid.value[12] = msPlaybackSpeedCharId[0]; + msPlaybackSpeedCharUuid.value[13] = msPlaybackSpeedCharId[1]; + msPlaybackSpeedCharUuid.value[14] = msId[0]; + msPlaybackSpeedCharUuid.value[15] = msId[1]; + + msRepeatCharUuid.value[12] = msRepeatCharId[0]; + msRepeatCharUuid.value[13] = msRepeatCharId[1]; + msRepeatCharUuid.value[14] = msId[0]; + msRepeatCharUuid.value[15] = msId[1]; + + msShuffleCharUuid.value[12] = msShuffleCharId[0]; + msShuffleCharUuid.value[13] = msShuffleCharId[1]; + msShuffleCharUuid.value[14] = msId[0]; + msShuffleCharUuid.value[15] = msId[1]; characteristicDefinition[0] = {.uuid = (ble_uuid_t *) (&msEventCharUuid), .access_cb = MSCallback, diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h index ee3628b0..172ab61c 100644 --- a/src/components/ble/MusicService.h +++ b/src/components/ble/MusicService.h @@ -26,8 +26,8 @@ #undef max #undef min -//c7e50000-78fc-48fe-8e23-43b37a1942d0 -#define MUSIC_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0xe5, 0xc7} +//00000000-78fc-48fe-8e23-433b3a1942d0 +#define MUSIC_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0x00, 0x00} namespace Pinetime { namespace System { @@ -73,19 +73,19 @@ namespace Pinetime { Playing = 0x01 }; private: - static constexpr uint8_t msId[2] = {0x00, 0x01}; - static constexpr uint8_t msEventCharId[2] = {0x00, 0x02}; - static constexpr uint8_t msStatusCharId[2] = {0x00, 0x03}; - static constexpr uint8_t msArtistCharId[2] = {0x00, 0x04}; - static constexpr uint8_t msTrackCharId[2] = {0x00, 0x05}; - static constexpr uint8_t msAlbumCharId[2] = {0x00, 0x06}; - static constexpr uint8_t msPositionCharId[2] = {0x00, 0x07}; - static constexpr uint8_t msTotalLengthCharId[2] = {0x00, 0x08}; - static constexpr uint8_t msTrackNumberCharId[2] = {0x00, 0x09}; - static constexpr uint8_t msTrackTotalCharId[2] = {0x00, 0x0a}; - static constexpr uint8_t msPlaybackSpeedCharId[2] = {0x00, 0x0b}; - static constexpr uint8_t msRepeatCharId[2] = {0x00, 0x0c}; - static constexpr uint8_t msShuffleCharId[2] = {0x00, 0x0d}; + static constexpr uint8_t msId[2] = {0x00, 0x00}; + static constexpr uint8_t msEventCharId[2] = {0x01, 0x00}; + static constexpr uint8_t msStatusCharId[2] = {0x02, 0x00}; + static constexpr uint8_t msArtistCharId[2] = {0x03, 0x00}; + static constexpr uint8_t msTrackCharId[2] = {0x04, 0x00}; + static constexpr uint8_t msAlbumCharId[2] = {0x05, 0x00}; + static constexpr uint8_t msPositionCharId[2] = {0x06, 0x00}; + static constexpr uint8_t msTotalLengthCharId[2] = {0x07, 0x00}; + static constexpr uint8_t msTrackNumberCharId[2] = {0x08, 0x00}; + static constexpr uint8_t msTrackTotalCharId[2] = {0x09, 0x00}; + static constexpr uint8_t msPlaybackSpeedCharId[2] = {0x0a, 0x00}; + static constexpr uint8_t msRepeatCharId[2] = {0x0b, 0x00}; + static constexpr uint8_t msShuffleCharId[2] = {0x0c, 0x00}; ble_uuid128_t msUuid{ .u = {.type = BLE_UUID_TYPE_128}, diff --git a/src/libs/lvgl/patches/0002-fix_bug_in_animation_management_for_lv_label.patch b/src/libs/lvgl/patches/0002-fix_bug_in_animation_management_for_lv_label.patch new file mode 100644 index 00000000..7b4c204a --- /dev/null +++ b/src/libs/lvgl/patches/0002-fix_bug_in_animation_management_for_lv_label.patch @@ -0,0 +1,51 @@ +Index: src/libs/lvgl/src/lv_misc/lv_anim.c +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.c b/src/libs/lvgl/src/lv_misc/lv_anim.c +--- a/src/libs/lvgl/src/lv_misc/lv_anim.c (revision 12a3b6cc8ec1fd6b951c353ab3a5fbbb9934fdd4) ++++ b/src/libs/lvgl/src/lv_misc/lv_anim.c (date 1610901672072) +@@ -158,12 +158,12 @@ + * @param end end value of the animation + * @return the required time [ms] for the animation with the given parameters + */ +-uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) ++uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) + { + int32_t d = LV_MATH_ABS((int32_t)start - end); + uint32_t time = (int32_t)((int32_t)(d * 1000) / speed); + +- if(time > UINT16_MAX) time = UINT16_MAX; ++ if(time > UINT32_MAX) time = UINT32_MAX; + + if(time == 0) { + time++; +Index: src/libs/lvgl/src/lv_misc/lv_anim.h +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.h b/src/libs/lvgl/src/lv_misc/lv_anim.h +--- a/src/libs/lvgl/src/lv_misc/lv_anim.h (revision 12a3b6cc8ec1fd6b951c353ab3a5fbbb9934fdd4) ++++ b/src/libs/lvgl/src/lv_misc/lv_anim.h (date 1610901672076) +@@ -73,8 +73,8 @@ + lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/ + int32_t start; /**< Start value*/ + int32_t end; /**< End value*/ +- uint16_t time; /**< Animation time in ms*/ +- int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/ ++ uint32_t time; /**< Animation time in ms*/ ++ int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/ + uint16_t playback_pause; /**< Wait before play back*/ + uint16_t repeat_pause; /**< Wait before repeat*/ + #if LV_USE_USER_DATA +@@ -266,7 +266,7 @@ + * @param end end value of the animation + * @return the required time [ms] for the animation with the given parameters + */ +-uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end); ++uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end); + + /** + * Calculate the current value of an animation applying linear characteristic diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.c b/src/libs/lvgl/src/lv_misc/lv_anim.c index 790dfc77..77bd87b9 100644 --- a/src/libs/lvgl/src/lv_misc/lv_anim.c +++ b/src/libs/lvgl/src/lv_misc/lv_anim.c @@ -158,12 +158,12 @@ uint16_t lv_anim_count_running(void) * @param end end value of the animation * @return the required time [ms] for the animation with the given parameters */ -uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) +uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) { int32_t d = LV_MATH_ABS((int32_t)start - end); uint32_t time = (int32_t)((int32_t)(d * 1000) / speed); - if(time > UINT16_MAX) time = UINT16_MAX; + if(time > UINT32_MAX) time = UINT32_MAX; if(time == 0) { time++; diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.h b/src/libs/lvgl/src/lv_misc/lv_anim.h index 36cc35ad..b43035aa 100644 --- a/src/libs/lvgl/src/lv_misc/lv_anim.h +++ b/src/libs/lvgl/src/lv_misc/lv_anim.h @@ -73,8 +73,8 @@ typedef struct _lv_anim_t lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/ int32_t start; /**< Start value*/ int32_t end; /**< End value*/ - uint16_t time; /**< Animation time in ms*/ - int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/ + uint32_t time; /**< Animation time in ms*/ + int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/ uint16_t playback_pause; /**< Wait before play back*/ uint16_t repeat_pause; /**< Wait before repeat*/ #if LV_USE_USER_DATA @@ -266,7 +266,7 @@ uint16_t lv_anim_count_running(void); * @param end end value of the animation * @return the required time [ms] for the animation with the given parameters */ -uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end); +uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end); /** * Calculate the current value of an animation applying linear characteristic |