diff --git a/.github/workflows/cpputest.yml b/.github/workflows/cpputest.yml index 7e05da850..d3d12763f 100644 --- a/.github/workflows/cpputest.yml +++ b/.github/workflows/cpputest.yml @@ -11,7 +11,9 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 + container: + image: pllee4/ubuntu-ci:20.04-gRPC steps: - uses: actions/checkout@v2 @@ -23,6 +25,3 @@ jobs: - name: Build run: cmake --build --preset=unittest_build - - - name: Test - run: ctest --preset=unittest --rerun-failed --output-on-failure diff --git a/.gitignore b/.gitignore index 4a29d3aad..6764095e0 100644 --- a/.gitignore +++ b/.gitignore @@ -113,7 +113,10 @@ ipch/ *.dbg* *.scvd -.vscode/.cortex-debug.registers.state.json -:50003 -:50006 -.vscode/.cortex-debug.peripherals.state.json +.vscode/.cortex-debug.registers.state.json +:50003 +:50006 +.vscode/.cortex-debug.peripherals.state.json + +# Generated files +tests/generator diff --git a/CMakePresets.json b/CMakePresets.json index c9e420402..9f3c5a71e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -61,17 +61,25 @@ } ], "buildPresets": [ + { + "name": "parallel_build", + "description": "Build will all cores", + "displayName": "parallel_build", + "jobs": 0 + }, { "name": "unittest_build", "description": "Build the unittest", "displayName": "unittest_build", - "configurePreset": "unittesting_configs" + "configurePreset": "unittesting_configs", + "inherits": "parallel_build" }, { "name": "target_build", "description": "Build for the STM32l0 target", "displayName": "target_build", - "configurePreset": "on_target_configs" + "configurePreset": "on_target_configs", + "inherits": "parallel_build" } ], "testPresets": [ diff --git a/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c b/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.cpp similarity index 95% rename from src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c rename to src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.cpp index c0284244c..340b5dee5 100644 --- a/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c +++ b/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.cpp @@ -53,9 +53,9 @@ static uint8_t AppDataBuffer[LORAWAN_APP_DATA_BUFFER_MAX_SIZE]; */ static LmHandlerAppData_t AppData = { - .Buffer = AppDataBuffer, + .Port = 0, .BufferSize = 0, - .Port = 0 + .Buffer = AppDataBuffer }; /*! @@ -125,7 +125,6 @@ static volatile uint8_t IsTxFramePending = 0; */ extern Uart_t Uart1; - uint32_t tx_count_on_this_credential = 0; /*! @@ -133,6 +132,7 @@ uint32_t tx_count_on_this_credential = 0; */ int main( void ) { + #if( USE_WATCHDOG ) IWDG_Init( ); #endif @@ -148,9 +148,6 @@ int main( void ) /* Initialise timer */ timer_init( ); - /* Transmit immediately (10 milliseconds later) */ - setup_next_tx_alarm( 10 ); - while( 1 ) { switch_to_next_registered_credentials( ); // Switch to the next set of @@ -162,6 +159,9 @@ int main( void ) static void transmit_n_times_on_this_credential( void ) { + /* Transmit immediately (10 milliseconds later) */ + setup_next_tx_alarm( 10 ); + print_current_region( ); /* Configure the subband settings for AS923 BEFORE initing it. Only needed @@ -244,8 +244,8 @@ static void PrepareTxFrame( void ) return; } - tx_count_on_this_credential ++; sensor_read_and_send( &AppData, LmHandlerParams.Region ); + tx_count_on_this_credential++; uint32_t interval = read_tx_interval_in_eeprom( TX_INTERVAL_EEPROM_ADDRESS, TX_INTERVAL_GPS_FIX_OK ); setup_next_tx_alarm( interval ); diff --git a/src/peripherals/bsp.c b/src/peripherals/bsp.c index 9c7a9ff81..14c3f7ae8 100644 --- a/src/peripherals/bsp.c +++ b/src/peripherals/bsp.c @@ -378,9 +378,9 @@ void BSP_sensor_Init(void) printf("SELFTEST: Initialising GPS\n\r"); GpioWrite(&Load_enable, 0); /* Enable power to GPS */ - gps_info_latest = get_latest_gps_info(); //GPS SETUP setup_GPS(); + gps_info_latest = get_latest_gps_info(); IWDG_reset(); diff --git a/src/peripherals/config.h b/src/peripherals/config.h index f8cee4d53..94554963f 100644 --- a/src/peripherals/config.h +++ b/src/peripherals/config.h @@ -120,7 +120,7 @@ extern "C" * @brief Define how quickly to return to searching for a GPS fix after transmitting * */ -#define TX_INTERVAL_GPS_FIX_OK 2800 /* When fix was aquired, then sleep for this period (in milliseconds) before searching again */ +#define TX_INTERVAL_GPS_FIX_OK 10000 /* When fix was aquired, then sleep for this period (in milliseconds) before searching again */ /** * @brief Lorawan defaults, normally will not be changed diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f37040d6f..e55e501b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,21 +1,14 @@ -cmake_minimum_required(VERSION 3.7) +# src/CMakeLists.txt +cmake_minimum_required(VERSION 3.5.1) +# For Protobuf's cmake warnings +if(POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() -# Get the test framework Cpputest -include(FetchContent) -FetchContent_Declare( - cpputest - GIT_REPOSITORY https://github.com/cpputest/cpputest.git - GIT_TAG v4.0 -) -# Set this to ON if you want to have the CppUTests in your project as well. -set(TESTS OFF CACHE BOOL "Switch off CppUTest Test build") - - -set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -m32") -set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -m32") +# project(hello C CXX) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -FetchContent_MakeAvailable(cpputest) add_definitions( -DREGION_EU868 @@ -35,9 +28,6 @@ add_definitions( ) -include_directories(${CPPUTEST_SRC_DIR}) -include_directories(${CPPUTESTEXT_SRC_DIR}) - # Test includes include_directories(${PROJECT_SOURCE_DIR}/mocking) include_directories(${PROJECT_SOURCE_DIR}/tests/mocks/) @@ -65,7 +55,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src/radio/sx1276/) # Unittests set(UNIT_TESTS - main.cpp + # main.cpp geofence_ut.cpp playback_ut.cpp lorawan_credentials_ut.cpp @@ -93,18 +83,12 @@ set(MOCKS systime-mock.cpp ublox-mock.cpp nvm_images.cpp - gps_mock_utils.cpp delay-board-mock.c gpio_mock.c rtc-board-mock.c mocks/rtc_mock.c ) - - -# CLI sources - - # Put in compile files(all logic so no hardware connection) set(FILES_UNDER_TEST ${PROJECT_SOURCE_DIR}/src/peripherals/geofence.c @@ -120,10 +104,9 @@ set(FILES_UNDER_TEST ${PROJECT_SOURCE_DIR}/src/apps/LoRaMac/common/LmHandler/LmHandler.c ${PROJECT_SOURCE_DIR}/src/system/delay.c ${PROJECT_SOURCE_DIR}/src/system/timer.c - ${PROJECT_SOURCE_DIR}/src/apps/LoRaMac/common/callbacks.c - - - + ${PROJECT_SOURCE_DIR}/src/apps/LoRaMac/common/callbacks.c + ${PROJECT_SOURCE_DIR}/src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.cpp + # Compile region files ${PROJECT_SOURCE_DIR}/src/mac/region/RegionAU915.c ${PROJECT_SOURCE_DIR}/src/mac/region/RegionUS915.c @@ -168,24 +151,63 @@ set(FILES_UNDER_TEST ${PROJECT_SOURCE_DIR}/src/apps/LoRaMac/common/message_sender.c ${PROJECT_SOURCE_DIR}/src/system/nvmm.c - + greeter_client.cc + ) -set(SOURCE_FILES - ${UNIT_TESTS} - ${MOCKS} +find_package(Threads REQUIRED) + +# Find Protobuf installation +# Looks for protobuf-config.cmake file installed by Protobuf's cmake installation. +set(protobuf_MODULE_COMPATIBLE TRUE) +find_package(Protobuf CONFIG REQUIRED) +message(STATUS "Using protobuf ${Protobuf_VERSION}") + +set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) +set(_REFLECTION gRPC::grpc++_reflection) +find_program(_PROTOBUF_PROTOC protoc) + +# Find gRPC installation +# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. +find_package(gRPC CONFIG REQUIRED) +message(STATUS "Using gRPC ${gRPC_VERSION}") + +set(_GRPC_GRPCPP gRPC::grpc++) +find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin) + +# Protos +get_filename_component(h_proto "hello.proto" ABSOLUTE) +get_filename_component(h_proto_path "${h_proto}" PATH) + +# Generated sources +set(h_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/hello.pb.cc") +set(h_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/hello.pb.h") +set(h_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/hello.grpc.pb.cc") +set(h_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/hello.grpc.pb.h") +add_custom_command( + OUTPUT "${h_proto_srcs}" "${h_proto_hdrs}" "${h_grpc_srcs}" "${h_grpc_hdrs}" + COMMAND ${_PROTOBUF_PROTOC} + ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" + --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" + -I "${h_proto_path}" + --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" + "${h_proto}" + DEPENDS "${h_proto}") + +# Generated sources headers +include_directories("${CMAKE_CURRENT_BINARY_DIR}") + +# Targets (the binaries) + +add_executable("project" ${FILES_UNDER_TEST} + ${MOCKS} + ${h_proto_srcs} + ${h_grpc_srcs} +) +target_link_libraries("project" + ${_REFLECTION} + ${_GRPC_GRPCPP} + ${_PROTOBUF_LIBPROTOBUF} ) -add_executable(picotracker_lora_tests ${SOURCE_FILES}) -target_compile_options(picotracker_lora_tests PRIVATE -fshort-enums) -# target_compile_options(picotracker_lora_tests PRIVATE -Wall -Wextra -Wpedantic) -target_link_libraries(picotracker_lora_tests PRIVATE CppUTest CppUTestExt) - - -# only build 32-bit binaries -target_compile_options(picotracker_lora_tests PRIVATE -m32) -target_link_options(picotracker_lora_tests PRIVATE -m32) - -# Add tests -add_test(picotracker_lora_tests picotracker_lora_tests -p) # Pass option to run CppUTests all on different threads diff --git a/tests/bsp_mock.cpp b/tests/bsp_mock.cpp index 0e07a0079..2ba583745 100644 --- a/tests/bsp_mock.cpp +++ b/tests/bsp_mock.cpp @@ -1,4 +1,3 @@ -#include "CppUTestExt/MockSupport.h" extern "C" { diff --git a/tests/eeprom-board-mock.cpp b/tests/eeprom-board-mock.cpp index 6a4f6ef2a..806071830 100644 --- a/tests/eeprom-board-mock.cpp +++ b/tests/eeprom-board-mock.cpp @@ -23,7 +23,6 @@ * Modified by Medad Newman for unittesting */ -#include "CppUTestExt/MockSupport.h" extern "C" { diff --git a/tests/gps_mock_utils.cpp b/tests/gps_mock_utils.cpp deleted file mode 100644 index dcafc6966..000000000 --- a/tests/gps_mock_utils.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file gps_mock_utils.cpp - * @author Medad Newman (medad@medadnewman.co.uk) - * @brief - * @version 0.1 - * @date 2021-09-10 - * - * @copyright Copyright (c) 2021 - * - */ - -#include "CppUTest/TestHarness.h" -#include "CppUTestExt/MockSupport.h" - -extern "C" -{ -#include "ublox.h" -#include "main.h" -#include /* fmod */ -} -#include - -std::list position_list; - -void prepare_n_position_mocks(int number_of_readings, int degrees_moved_per_shift) -{ - - gps_info_t world_trip_mock; - - /* Fill list with positions to simulate */ - for (int i = 0; i <= number_of_readings; i++) - { - - float latitude = 53.23; - float longitude = fmod(0.3 + i * degrees_moved_per_shift, 360) - 180; - - world_trip_mock.GPS_UBX_latitude_Float = latitude; - world_trip_mock.GPS_UBX_longitude_Float = (float)longitude; - world_trip_mock.GPSaltitude_mm = 12342000; - world_trip_mock.unix_time = 1631323786 + 60 * 60 * i; /* travel one degree longitude every hour */ - world_trip_mock.latest_gps_status = GPS_SUCCESS; - world_trip_mock.GPSsats = 16; - - position_list.push_back(world_trip_mock); - } - - /* Now mock those positions */ - for (auto &position : position_list) - { - mock().expectOneCall("get_latest_gps_info").andReturnValue(&position); - } -} - -void teardown_n_positions_mock() -{ - position_list.clear(); -} diff --git a/tests/gps_mock_utils.hpp b/tests/gps_mock_utils.hpp deleted file mode 100644 index 76490e365..000000000 --- a/tests/gps_mock_utils.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @file gps_mock_utils.hpp - * @author Medad Newman (medad@medadnewman.co.uk) - * @brief - * @version 0.1 - * @date 2021-09-10 - * - * @copyright Copyright (c) 2021 - * - */ - - -void prepare_n_position_mocks(int number_of_readings, int degrees_moved_per_shift); -void teardown_n_positions_mock(); - diff --git a/tests/greeter_client.cc b/tests/greeter_client.cc new file mode 100644 index 000000000..e93baec1c --- /dev/null +++ b/tests/greeter_client.cc @@ -0,0 +1,123 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed 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 "greeter_client.h" +#include +#include +#include + +extern "C" +{ +#include "ublox.h" +} +#include + +#ifdef BAZEL_BUILD +#include "examples/protos/helloworld.grpc.pb.h" +#else +#include "hello.grpc.pb.h" +#endif + +using grpc::Channel; +using grpc::ClientContext; +using grpc::Status; +using helloworld::Greeter; +using helloworld::HelloReply; +using helloworld::HelloRequest; + +std::string target_str = "localhost:50051"; + +class GreeterClient +{ +public: + GreeterClient(std::shared_ptr channel) + : stub_(Greeter::NewStub(channel)) {} + + // Assembles the client's payload, sends it and presents the response back + // from the server. + helloworld::HelloReply SayHello(const std::string &user) + { + // Data we are sending to the server. + HelloRequest request; + request.set_name(user); + + // Container for the data we expect from the server. + HelloReply reply; + + // Context for the client. It could be used to convey extra information to + // the server and/or tweak certain RPC behaviors. + ClientContext context; + + // The actual RPC. + Status status = stub_->SayHello(&context, request, &reply); + + // Act upon its status. + if (!status.ok()) + { + std::cout << status.error_code() << ": " << status.error_message() + << std::endl; + std::cout << "RPC failed" << std::endl; + } + + return reply; + } + +private: + std::unique_ptr stub_; +}; + +TestPlugin::TestPlugin() +{ +} + +TestPlugin::~TestPlugin() +{ +} + +GreeterClient *ourGreeterClient; + +int TestPlugin::do_it() +{ + // Instantiate the client. It requires a channel, out of which the actual RPCs + // are created. This channel models a connection to an endpoint specified by + // the argument "--target=" which is the only expected argument. + // We indicate that the channel isn't authenticated (use of + // InsecureChannelCredentials()). + + std::shared_ptr channel = grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials()); + + ourGreeterClient = new GreeterClient(channel); + + return 0; +} + +gps_info_t TestPlugin::get_gps_position() +{ + + std::string user("world"); + HelloReply reply = ourGreeterClient->SayHello(user); + gps_info_t position = { + .GPS_UBX_latitude_Float = reply.latitude(), + .GPS_UBX_longitude_Float = reply.longitude(), + .GPSaltitude_mm = reply.alt(), + .GPSsats = reply.sats(), + .unix_time = reply.unix_time(), + .latest_gps_status = (gps_status_t)reply.latest_gps_status() + }; + return position; +} diff --git a/tests/greeter_client.h b/tests/greeter_client.h new file mode 100644 index 000000000..c8211917f --- /dev/null +++ b/tests/greeter_client.h @@ -0,0 +1,21 @@ + + +#ifndef D_TestPlugin_h +#define D_TestPlugin_h + +extern "C" +{ +#include "ublox.h" +} + +class TestPlugin +{ +public: + TestPlugin(); + virtual ~TestPlugin(); + + int do_it(); + gps_info_t get_gps_position(); +}; + +#endif diff --git a/tests/hello.proto b/tests/hello.proto new file mode 100644 index 000000000..070cbb1fd --- /dev/null +++ b/tests/hello.proto @@ -0,0 +1,48 @@ +// Copyright 2015 gRPC authors. +// +// Licensed 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. + +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +enum gps_status_t { + GPS_FAILURE = 0; + GPS_SUCCESS = 1; +} + +// The response message containing the greetings +message HelloReply { + double latitude = 1; + double longitude = 2; + int32 alt = 3; + uint32 sats = 4; + uint32 unix_time = 5; + gps_status_t latest_gps_status = 6; +} diff --git a/tests/mocks/main.h b/tests/mocks/main.h deleted file mode 100644 index acefd24b9..000000000 --- a/tests/mocks/main.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file main.h - * @author Medad Newman (medad@medadnewman.co.uk) - * @brief - * @version 0.1 - * @date 2021-08-11 - * - * @copyright Copyright (c) 2021 - * - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H_1 -#define __MAIN_H_1 - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "LmHandler.h" - - - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H_1 */ diff --git a/tests/ublox-emulator/Makefile b/tests/ublox-emulator/Makefile new file mode 100644 index 000000000..4be20cef2 --- /dev/null +++ b/tests/ublox-emulator/Makefile @@ -0,0 +1,31 @@ +# Copyright 2022 The gRPC Authors +# +# Licensed 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. + +# Regenerates all generated files in the Python examples directory. + +ARTIFACTS= + +ARTIFACTS += helloworld/helloworld_pb2.py +ARTIFACTS += helloworld/helloworld_pb2_grpc.py +ARTIFACTS += helloworld/helloworld_pb2.pyi + +.PHONY: all +all: ${ARTIFACTS} + +helloworld/helloworld_pb2.py helloworld/helloworld_pb2_grpc.py helloworld/helloworld_pb2.pyi: ../hello.proto + python3 -m grpc_tools.protoc --python_out=helloworld --grpc_python_out=helloworld --pyi_out=helloworld -I ../ ../hello.proto + +.PHONY: clean +clean: + rm -f ${ARTIFACTS} diff --git a/tests/ublox-emulator/README.md b/tests/ublox-emulator/README.md new file mode 100644 index 000000000..be57d8978 --- /dev/null +++ b/tests/ublox-emulator/README.md @@ -0,0 +1 @@ +[This code's documentation lives on the grpc.io site.](https://grpc.io/docs/languages/python/quickstart) diff --git a/tests/ublox-emulator/helloworld/.gitignore b/tests/ublox-emulator/helloworld/.gitignore new file mode 100644 index 000000000..fc7ab121e --- /dev/null +++ b/tests/ublox-emulator/helloworld/.gitignore @@ -0,0 +1,4 @@ +*.pyc +*_pb2.py +*_pb2.pyi +*_pb2_grpc.py \ No newline at end of file diff --git a/tests/ublox-emulator/helloworld/greeter_server.py b/tests/ublox-emulator/helloworld/greeter_server.py new file mode 100644 index 000000000..eea2ff5da --- /dev/null +++ b/tests/ublox-emulator/helloworld/greeter_server.py @@ -0,0 +1,48 @@ +# Copyright 2015 gRPC authors. +# +# Licensed 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. +"""The Python implementation of the GRPC helloworld.Greeter server.""" + +from concurrent import futures +import logging + +import grpc +import hello_pb2 +import hello_pb2_grpc +import itertools + +unixtime = itertools.count(1668349205, 15) +latitude = itertools.cycle(x * 0.001 for x in range(-90000, 90000, 1)) +longitude = itertools.cycle(x * 0.001 for x in range(-180000, 180000, 1)) +altitude = 10000000 + + +class Greeter(hello_pb2_grpc.GreeterServicer): + + def SayHello(self, request, context): + return hello_pb2.HelloReply(latitude=next(latitude), longitude=next(longitude), alt=altitude, sats=3, unix_time=next(unixtime), latest_gps_status=hello_pb2.GPS_SUCCESS) + + +def serve(): + port = '50051' + server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + hello_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) + server.add_insecure_port('[::]:' + port) + server.start() + print("Server started, listening on " + port) + server.wait_for_termination() + + +if __name__ == '__main__': + logging.basicConfig() + serve() diff --git a/tests/ublox-mock.cpp b/tests/ublox-mock.cpp deleted file mode 100644 index 88fa44e67..000000000 --- a/tests/ublox-mock.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "CppUTestExt/MockSupport.h" - -extern "C" -{ -#include "ublox.h" -} - - - -gps_status_t get_location_fix(uint32_t timeout) -{ - return GPS_SUCCESS; -} - -/* - * sets up gps by putting in airbourne mode, setting to use GPS satellites only, turning off NMEA - * Needs TO BE REFACTORED TO TIME OUT OR EXIT IF NO MESSAGED IS ReCEIVED BACK! - */ -gps_status_t setup_GPS() -{ - return GPS_SUCCESS; -} - -/* Get solar voltage when under load from GPS */ -uint16_t get_load_solar_voltage() -{ - return 2323; -} - -gps_info_t get_latest_gps_info() -{ - auto returnValue = mock().actualCall(__func__).returnPointerValue(); - return *(gps_info_t *)(returnValue); -} - -gps_status_t get_latest_gps_status(void) -{ - return GPS_SUCCESS; -} \ No newline at end of file