Skip to content

Commit

Permalink
Use NavigationService from InfiniTime, improve nimble headers
Browse files Browse the repository at this point in the history
Improve the nimble headers such that we can use the NavigationService
from InfiniTime instead of having a slightly modified verison in
InfiniSim.
  • Loading branch information
NeroBurner committed Sep 25, 2024
1 parent ed393d0 commit c7e512a
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 218 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ add_library(sim-base STATIC
sim/host/ble_gatt.h
sim/host/ble_gatt.cpp
sim/host/ble_uuid.h
sim/host/ble_uuid.cpp
sim/host/os_mbuf.h
sim/host/os_mbuf.cpp
)
# include the generated lv_conf.h file before anything else
target_include_directories(sim-base PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") # lv_conf.h
Expand Down Expand Up @@ -129,8 +132,6 @@ target_sources(infinisim PUBLIC
sim/components/ble/MotionService.cpp
sim/components/ble/MusicService.h
sim/components/ble/MusicService.cpp
sim/components/ble/NavigationService.h
sim/components/ble/NavigationService.cpp
sim/components/ble/NimbleController.h
sim/components/ble/NimbleController.cpp
sim/components/brightness/BrightnessController.h
Expand Down Expand Up @@ -197,6 +198,8 @@ target_sources(infinisim PUBLIC
${InfiniTime_DIR}/src/components/datetime/DateTimeController.cpp
${InfiniTime_DIR}/src/components/settings/Settings.h
${InfiniTime_DIR}/src/components/settings/Settings.cpp
${InfiniTime_DIR}/src/components/ble/NavigationService.h
${InfiniTime_DIR}/src/components/ble/NavigationService.cpp
${InfiniTime_DIR}/src/components/ble/NotificationManager.h
${InfiniTime_DIR}/src/components/ble/NotificationManager.cpp
${InfiniTime_DIR}/src/components/ble/SimpleWeatherService.h
Expand Down
9 changes: 5 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
#include "lv_drivers/indev/keyboard.h"
#include "lv_drivers/indev/mousewheel.h"

// get PineTime header
#include "displayapp/InfiniTimeTheme.h"
#include <drivers/Hrs3300.h>
#include <drivers/Bma421.h>

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

// get PineTime header
#include "displayapp/InfiniTimeTheme.h"
#include <drivers/Hrs3300.h>
#include <drivers/Bma421.h>

#include "BootloaderVersion.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
Expand Down
111 changes: 0 additions & 111 deletions sim/components/ble/NavigationService.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions sim/components/ble/NavigationService.h

This file was deleted.

1 change: 0 additions & 1 deletion sim/components/ble/NimbleController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
// currentTimeService {dateTimeController},
musicService {systemTask},
weatherService {dateTimeController},
navService {systemTask},
// batteryInformationService {batteryController},
// immediateAlertService {systemTask, notificationManager},
// heartRateService {systemTask, heartRateController},
Expand Down
2 changes: 1 addition & 1 deletion sim/host/ble_gatt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs)
// ble_hs_unlock();
// return rc;
return 0;
}
}
40 changes: 4 additions & 36 deletions sim/host/ble_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <inttypes.h>
//#include "host/ble_att.h"
#include "host/ble_uuid.h"
// include from sim for ASSERT
#include "nrf_assert.h"
#include "host/os_mbuf.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -613,42 +617,6 @@ struct ble_gatt_dsc_def {
void *arg;
};

// buffer from os_mbuf.h
/**
* Chained memory buffer.
*/
struct os_mbuf {
/**
* Current pointer to data in the structure
*/
uint8_t *om_data;
/**
* Flags associated with this buffer, see OS_MBUF_F_* defintions
*/
uint8_t om_flags;
/**
* Length of packet header
*/
uint8_t om_pkthdr_len;
/**
* Length of data in this buffer
*/
uint16_t om_len;

// sim: disabled, not used by InfiniSim
///**
// * The mbuf pool this mbuf was allocated out of
// */
//struct os_mbuf_pool *om_omp;

//SLIST_ENTRY(os_mbuf) om_next;

/**
* Pointer to the beginning of the data, after this buffer
*/
uint8_t om_databuf[0];
};


/**
* Context for an access to a GATT characteristic or descriptor. When a client
Expand Down
27 changes: 27 additions & 0 deletions sim/host/ble_uuid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "host/ble_uuid.h"


int
ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2)
{
return 0;
}
9 changes: 9 additions & 0 deletions sim/host/ble_uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ typedef union {
ble_uuid128_t u128;
} ble_uuid_any_t;

/** @brief Compares two Bluetooth UUIDs.
*
* @param uuid1 The first UUID to compare.
* @param uuid2 The second UUID to compare.
*
* @return 0 if the two UUIDs are equal, nonzero if the UUIDs differ.
*/
int ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2);

#ifdef __cplusplus
}
#endif
Expand Down
27 changes: 27 additions & 0 deletions sim/host/os_mbuf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "host/os_mbuf.h"


int
os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst)
{
return 0;
}
Loading

0 comments on commit c7e512a

Please sign in to comment.