Skip to content

Commit 5990b32

Browse files
committed
Use NavigationService from InfiniTime, improve nimble headers
Improve the nimble headers such that we can use the NavigationService from InfiniTime instead of having a slightly modified verison in InfiniSim.
1 parent ed393d0 commit 5990b32

12 files changed

+209
-218
lines changed

CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ add_library(sim-base STATIC
9292
sim/host/ble_gatt.h
9393
sim/host/ble_gatt.cpp
9494
sim/host/ble_uuid.h
95+
sim/host/ble_uuid.cpp
96+
sim/host/os_mbuf.h
97+
sim/host/os_mbuf.cpp
9598
)
9699
# include the generated lv_conf.h file before anything else
97100
target_include_directories(sim-base PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") # lv_conf.h
@@ -129,8 +132,6 @@ target_sources(infinisim PUBLIC
129132
sim/components/ble/MotionService.cpp
130133
sim/components/ble/MusicService.h
131134
sim/components/ble/MusicService.cpp
132-
sim/components/ble/NavigationService.h
133-
sim/components/ble/NavigationService.cpp
134135
sim/components/ble/NimbleController.h
135136
sim/components/ble/NimbleController.cpp
136137
sim/components/brightness/BrightnessController.h
@@ -197,6 +198,8 @@ target_sources(infinisim PUBLIC
197198
${InfiniTime_DIR}/src/components/datetime/DateTimeController.cpp
198199
${InfiniTime_DIR}/src/components/settings/Settings.h
199200
${InfiniTime_DIR}/src/components/settings/Settings.cpp
201+
${InfiniTime_DIR}/src/components/ble/NavigationService.h
202+
${InfiniTime_DIR}/src/components/ble/NavigationService.cpp
200203
${InfiniTime_DIR}/src/components/ble/NotificationManager.h
201204
${InfiniTime_DIR}/src/components/ble/NotificationManager.cpp
202205
${InfiniTime_DIR}/src/components/ble/SimpleWeatherService.h

main.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
#include "lv_drivers/indev/keyboard.h"
2121
#include "lv_drivers/indev/mousewheel.h"
2222

23-
// get PineTime header
24-
#include "displayapp/InfiniTimeTheme.h"
25-
#include <drivers/Hrs3300.h>
26-
#include <drivers/Bma421.h>
2723

2824
# // be sure to get the sim headers for SimpleWeatherService.h
2925
#include "host/ble_gatt.h"
3026
#include "host/ble_uuid.h"
3127

28+
// get PineTime header
29+
#include "displayapp/InfiniTimeTheme.h"
30+
#include <drivers/Hrs3300.h>
31+
#include <drivers/Bma421.h>
32+
3233
#include "BootloaderVersion.h"
3334
#include "components/battery/BatteryController.h"
3435
#include "components/ble/BleController.h"

sim/components/ble/NavigationService.cpp

-111
This file was deleted.

sim/components/ble/NavigationService.h

-63
This file was deleted.

sim/components/ble/NimbleController.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
4545
// currentTimeService {dateTimeController},
4646
musicService {systemTask},
4747
weatherService {dateTimeController},
48-
navService {systemTask},
4948
// batteryInformationService {batteryController},
5049
// immediateAlertService {systemTask, notificationManager},
5150
// heartRateService {systemTask, heartRateController},

sim/host/ble_gatt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs)
6969
// ble_hs_unlock();
7070
// return rc;
7171
return 0;
72-
}
72+
}

sim/host/ble_gatt.h

+4-36
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#include <inttypes.h>
3131
//#include "host/ble_att.h"
3232
#include "host/ble_uuid.h"
33+
// include from sim for ASSERT
34+
#include "nrf_assert.h"
35+
#include "host/os_mbuf.h"
36+
3337
#ifdef __cplusplus
3438
extern "C" {
3539
#endif
@@ -613,42 +617,6 @@ struct ble_gatt_dsc_def {
613617
void *arg;
614618
};
615619

616-
// buffer from os_mbuf.h
617-
/**
618-
* Chained memory buffer.
619-
*/
620-
struct os_mbuf {
621-
/**
622-
* Current pointer to data in the structure
623-
*/
624-
uint8_t *om_data;
625-
/**
626-
* Flags associated with this buffer, see OS_MBUF_F_* defintions
627-
*/
628-
uint8_t om_flags;
629-
/**
630-
* Length of packet header
631-
*/
632-
uint8_t om_pkthdr_len;
633-
/**
634-
* Length of data in this buffer
635-
*/
636-
uint16_t om_len;
637-
638-
// sim: disabled, not used by InfiniSim
639-
///**
640-
// * The mbuf pool this mbuf was allocated out of
641-
// */
642-
//struct os_mbuf_pool *om_omp;
643-
644-
//SLIST_ENTRY(os_mbuf) om_next;
645-
646-
/**
647-
* Pointer to the beginning of the data, after this buffer
648-
*/
649-
uint8_t om_databuf[0];
650-
};
651-
652620

653621
/**
654622
* Context for an access to a GATT characteristic or descriptor. When a client

sim/host/ble_uuid.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "host/ble_uuid.h"
21+
22+
23+
int
24+
ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2)
25+
{
26+
return 0;
27+
}

sim/host/ble_uuid.h

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ typedef union {
8080
ble_uuid128_t u128;
8181
} ble_uuid_any_t;
8282

83+
/** @brief Compares two Bluetooth UUIDs.
84+
*
85+
* @param uuid1 The first UUID to compare.
86+
* @param uuid2 The second UUID to compare.
87+
*
88+
* @return 0 if the two UUIDs are equal, nonzero if the UUIDs differ.
89+
*/
90+
int ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2);
91+
8392
#ifdef __cplusplus
8493
}
8594
#endif

sim/host/os_mbuf.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "host/os_mbuf.h"
21+
22+
23+
int
24+
os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst)
25+
{
26+
return 0;
27+
}

0 commit comments

Comments
 (0)