Repository navigation
Migrate api-mockup to Community - #9
Merged
Merged
Conversation
SFL: #19168 Change-Id: I2b471b8acbbf148dc25f952f93a3c0d2ac7fa3d5 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Import Mosquitto-based MQTT communication developed for the GEISA conformance testing tool into the api-mockup project. This integration enables MQTT messaging capabilities within the api-mockup framework. SFL: #19168 Change-Id: Ia3764f14806cf5f0ed56256ea04eefb5d3268646 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
This main file is for now only connecting to the MQTT broker, waiting for connection and disconnect. SFL: #19168 Change-Id: Ia50f5bddbc1dc26ae2040bdfd92cefccc87791cf Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
This commit introduces a Makefile to facilitate the building and installation of the gapi program using the mosquitto library. SFL: #19168 Change-Id: Ia9c241abbeda9affa9af51807f8b21f95eae7e44 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Add .clang-format and .clang-tidy configuration files to the project, and update the Makefile to include a 'lint' target that runs these tools for code style and static analysis checks. SFL: #19168 Change-Id: I2206903bd71c7d3d864b0773ea08c1aa0fa1eded Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Add a CQFD configuration to build and lint the project inside a Docker container. SFL: #19168 Change-Id: I4ddad6ded6e89c43e16aec9ba69d56bf315ee81c Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
SFL: #19168 Change-Id: I2b87fbb0d7f58457e9357f22d0d603e31af52437 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
As Mosquitto broker now requires authentication, set the username and password when initializing the API MQTT client. SFL: #19168 Change-Id: I4134060c4bb06eb3bda928c206324e7ff0b42ae6 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Unlike MQTT's application messages, GEISA specification requires different QoS levels for topics. This commit updates the gapi_mosquitto API to allow specifying the QoS level when subscribing or publishing messages. SFL: #19168 Change-Id: I8d9670e346ee558e007e95f34cb21ce0b0f15ae9 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Add the schemas submodule to the repository to manage JSON schemas separately. This allows for easier updates and maintenance of the schemas used in the GEISA API Mockup project. SFL: #21154 Change-Id: I601456523813de503c4415b8a78fbc3ffc1a0e58 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Compile the subproject that builds the protobuf schemas as a dependency for the main gapi target. SFL: #21154 Change-Id: Ide232f34a1d98344c171db0236df75c2fbd2b261 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To ease the build process and include/src files organization, this commit introduces a build directory and moves the gapi_mosquitto.c and gapi_mosquitto.h files into src/ and include/ directories respectively. The Makefile is updated accordingly to reflect these changes. SFL: #21154 Change-Id: Ifae57fa55a8594633ca188dc0ae4933cee7e1fd0 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Handlers will be used to process incoming messages for specific topics. It will decrease the complexity of the on_message callback by delegating the processing to dedicated functions in different files. Then add a function to register a handler for a specific topic. SFL: #21154 Change-Id: I9c50794882fafdc6fa041d67a5ab89f382ed754b Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Create a new module to handle API platform discovery messages, including app manifest requests. This module registers the necessary handlers and subscribes to the relevant topics during initialization. SFL: #21154 Change-Id: I2d1e9e6a6a6f05a10ed12f17344dec5981494714 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
By default, executing the Makefile of schemas directory generates the binpb files only. Since we need the C files, modify the Makefile to generate c and h files from schemas/*.proto files using protoc directly in the main Makefile. Add these files to the compilation process by modifying the OBJ variable and adding the required flags and libraries using pkg-config. The generated C and H files are placed in build/schemas directory as they are the result of a compilation and are not intended to be modified by the user. SFL: #21154 Change-Id: I71574514f1e587b3d89aa79c5f6aa5d5e8f84419 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To avoid mixed indentation between tabs and spaces in some cases, set the ContinuationIndentWidth to 8 (tab width). SFL: #21154 Change-Id: I4423f80fb3760a5c74b60a09def1fc9c8b74c8af Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Modify the platform discovery request handler to build and send a platform discovery response message using predefined platform information. As the message size is retrieved with the protobuf-c function, the api_publish function signature is modified to accept a message size parameter. The handler is also updated: * to add the mosquitto pointer parameter to be able to publish the response message. * to change the payload parameter type from char* to uint8_t* as the protbuf-c messages are binary data. SFL: #21154 Change-Id: Id563cd2f8530dcd07c48462250fdd871cc83fedf Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
As the API program is a daemon, it should not exit after sending a message or after and error. Instead, it should just continue running. Then remove the exit(1) call in on_publish callback when the mid does not match the expected one and remove the set of running to false that will stop the main loop after sending a message. SFL: #21154 Change-Id: I2f7bfe1ac2a8a5cd1830013cecfd59826ae1609c Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Update the application manifest handler to respond with a static manifest to the app_id extracted from the topic. SFL: #21154 Change-Id: Ib8fa1081f31a585957a07a843a356f7c05a3c928 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Sent_mid variable was used to track if the published message ID matched the one received in the on_publish callback. However, since there will be multiple publishers in the future, this tracking is not reliable. As the publish callback is not doing anything else, remove it. SFL: #19175 Change-Id: Ibea7edfd5954bcd29e6f0e5843b04093f5e9390b Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Add a thread that will send instantaneous data messages every second. The thread is initialized in main() after the discovery initialization. For now the thread sends a dummy message "instdata" on the topic "geisa/api/instantaneous-data". SFL: #19175 Change-Id: I0b1100b6a5a71ba39661d175c059576d5dd3017b Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
In order to simulate the retrieval of instantaneous data from the system, add a function that populates the data structures with mock values. These values are sent every second on the "geisa/api/instantaneous-data" topic. SFL: #19175 Change-Id: Ieba7371b4b8bd36939476e744d60e629440205cc Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
The schemas repository is now defining the TYPE_PHASE__PHASE_N enum value in the latest version. Then update the schemas submodule and assign the phase field for phase_n. SFL: #19175 Change-Id: I850923a66884e013c1d4df5374a1fb48b7bc8551 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Create a new module to handle API waveform data messages. This module subscribes to the "geisa/api/waveform-req/#" topic and processes incoming requests. For now if the message is well-formed, it responds with a success status. SFL: #19176 Change-Id: I995a478f44d6a5b2cf1e3cbcb9b8df5bbcf32862 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
In order to facilitate access to waveform information for platform discovery, introduce a new function `get_waveform_info()`. This function returns a pointer to the `PlatformDiscoveryWaveform` structure, allowing other components to easily retrieve waveform details without duplicating code. This will be used in the waveform API. SFL: #19176 Change-Id: I94ab2431b1eedc108bdf3630c40b8fdb356580b2 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
There is multiple status possible when building the response to a waveform enabling, then base on the platform info and the request parameters, set the correct status. SFL: #19176 Change-Id: I87a7d2d5da4d8d6f5a47e6c7d3aeb215ac8caf47 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To simplify code and avoid potential memory issues, replace the malloc + strcpy + strcat sequence with a single asprintf call. SFL: #19176 Change-Id: Ia43d12882f3d5be3bf91545f38d057e9aef940c2 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
In the github CI run the linting and the build of the api-mockup project SFL: #19176 Change-Id: I189470dc38320c59a6a16751bcfd3a04737fb495 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
The identation was incorrect for the linting step in the CI workflow file, causing the linting job to fail. SFL: #19176 Change-Id: I482e97a45a0f90dc1ba773f713c2749b72735c3a Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Update GEISA schemas to the latest version. As the latest version is now using optional fields, and protobuf-c does not support optional fields for now, we need to change the C files generation to use nanopb. Then this commit update the code to use nanopb instead of protobuf-c for: * Protobuf schemas C files generation * Encoding and decoding of messages in the API handlers This commit also update the code to follow the changes in the schemas. For now, only the required changes to make the code compile and behave as before has been done. The schemas new fields will be added in further commits. SFL: #22399 Change-Id: If346849e2eed48d27c0cbbc2c81b726efc9d6c9b
This test application will only print some elements of the messages received to validate the API calls. Document the testing procedure in the README.md file. SFL: #22399 Change-Id: I6cbf38b103808ad959bb9009a7e8647bc1f45162
Geisa schemas for platform discovery and manifest have added new fields, so update the mockup implementation to fill those fields in the responses. Update the test app to print the new fields in the discovery response. SFL: #22399 Change-Id: Iddabb3f1be890083107aba6e01c5307e24cd034b Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
SFL: #22399 Change-Id: I8ab4031766526219894fcca29baf7fdda7678347 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
As GEISA platform are arm64 architecture, provide an easy way to build the application for this architecture using cqfd. SFL: #22399 Change-Id: I3b9e160ef0b5ef9c7a84cc3c835af2601d4b231a Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
As the new schemas is now defining the manifest outside the discovery proto, split the discovery and manifest handlers into separate files to better reflect the new structure and improve code organization. SFL: #22399 Change-Id: Iaebf290173a1642eb27dfac1c284e46c2c745791 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Latest instantaneous data schema includes frequency and temperature. This commit updates the instantaneous data with these new fields. SFL: #22399 Change-Id: I97fb466952394a68e6559a3243e7100d2d9eb4a2 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Latest waveform schema now includes request and expect waveform status depending on the result of the request, as well as a socket path to be used by the app to receive waveform data. The API implementation is updated to reflect these changes, and to create and manage Unix domain sockets for each app subscribing to a waveform stream. A deinit function is also added to clean up the created sockets on shutdown. The test app is also updated to print the new fields in the response message. SFL: #22399 Change-Id: I0124a1caf455f960840364886792979b787413e1 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Clean target should not fail if nanopb/*.o doesn't exist. This can happen if the user has never built the project before. SFL: #22439 Change-Id: Ia91a703638a13e5c620105a0af7a3f2ef333f055 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
SFL: #22439 Change-Id: Ia5079b2809092b55e90e0038ea7a891503359c96 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To avoid uninitialized values in the response, we initialize it with default values using the `GeisaInstantaneousQuantities_init_default` macro provided by nanopb. This ensures that all fields in the response are set to their default values before being populated with actual data. SFL: #21956 Change-Id: I40cae925a9959d3eb11be6b3d835d7e86253e467 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
If socket_path is freed before the message is encoded, the response will contain a NULL value for socket_path, which is not the expected behavior. The socket_path should only be freed after the message has been successfully encoded and published. SFL: #21908 Change-Id: Ia0bffe38ba12a4b973ffd7c02d0e02657f4acb2e Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To fully test the waveform feature, we need to implement a dedicated thread that will handle incoming connections on the waveform sockets. This thread will use epoll to efficiently monitor multiple sockets for incoming connection requests and accept them as they arrive. SFL: #21908 Change-Id: I51626e4ca6a03a552bb5ef2c34601fc7efcea4ef Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
As remove_socket is shifting the array of sockets, we need to iterate backwards to avoid skipping sockets during cleanup. SFL: #21908 Change-Id: Ic29157309722069911a0543c1a5fc0dfc427df62 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To take the tests a step further, add a second waveform instance with reduced sample rate to the API mockup application. This will allow for testing of different waveform configurations and ensure that the system can handle multiple waveform instances simultaneously. SFL: #21908 Change-Id: I9cb5b7c56eeff5fc6d9ee831cc8a831e3951d638 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
In order to have the latest changes, update the schemas submodule to the latest commit. SFL: #22704 Change-Id: I7d9c21299aaa61a599c68aae647a7abf0aafd10b Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To inform the user about the reason of the failure, add error messages to stderr when the waveform request fails. SFL: #21908 Change-Id: I5a18a2bf6c757b62eaeb58b3e62fdb43267342be Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
This skeleton code provides the basic structure for handling actuator messages in the GEISA API. It includes the necessary header and source files, as well as the implementation of request handlers for actuator set and get requests. The code also includes test cases to verify the functionality of the actuator message handling. SFL: #22704 Change-Id: I9da946565139f34479591a5ed2286e7dccdf0104 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Initialize actuator statuses and implement get/set requests to manage them. SFL: #22704 Change-Id: I10f1e60a75a83740b04d2ffe12988df646d36660 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To ease the testing of the actuator API, this commit adds a simple test application that can send get and set requests to the actuator API. SFL: #22704 Change-Id: I3bcfbd7dcd74e58a33d3d6715bb35e5c33228364 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
This change adds support for the sensor API, allowing clients to request sensor readings from the platform. It will handle requests for specific sensors or all available sensors, and respond with the corresponding readings or error messages if the request is malformed or the requested sensor is not found or not supported. SFL: #21958 Change-Id: I0b07f7f616307dced9fc9d1a1abd909286efe8b8 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
To ease sending requests to the sensor API, a dedicated test application has been added. This application can send requests to get all sensors or specific sensors by their IDs. The test_app application has also been updated to handle the sensor response messages. SFL: #21958 Change-Id: I49be6768e5f062b279d8049ac8cf222b32ff5988 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
For test purpose, add a sensor that is not readable, to test the behavior of the system when a sensor cannot be read. SFL: #21958 Change-Id: I21f7c4a662b15e536a415e3c4821d4fe3a11c04a Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Some arguments in get_all_sensors_info and get_requested_sensors_info were passed but could be defined inside the function, so we removed them to simplify the code. SFL: #22707 Change-Id: I758bcc9457295500c19960ca1523d1fe29289637 Signed-off-by: Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com>
Signed-off-by: Scott Wegener <swegener+tech@gmail.com>
Signed-off-by: Scott Wegener <swegener+tech@gmail.com>
Signed-off-by: Scott Wegener <swegener+tech@gmail.com>
Signed-off-by: Scott Wegener <swegener+tech@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the GEISA API mockup into the Community repository under:
example-implementations/api/api-mockup/Source
geisa/api-mockup423ac34815099fa7bda455099c6ab654b24b3d7d@kevlhop)Project Information
The API mockup implements portions of the GEISA API used by the existing conformance and integration work.
It is a Community example implementation and is not intended to represent a complete production platform or current specification conformance.
The migration preserves:
cad3c18ef15a663e30e3e43e3a752b66378adec1;df75ff51332c2aca0541fa60c2e740bcc276c3ce.Dependency updates and regeneration against current GEISA schemas are intentionally outside the scope of this migration.
Changes
example-implementations/api/api-mockup/.make setup-dev.pkg-config.Validation
Verified on Ubuntu 22.04 ARM64:
make setup-devclean serial build and clean parallel build with
make -jmake lintstrict C11 compilation with
-Wall -Wextra -pedantic -Werrorgeneration of:
build/gapibuild/test_appbuild/test_app_actuatorbuild/test_app_sensorclean pinned submodule state
git diff --check