Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: location: Use zbus subscriber instead of listener #132

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

gregersrygg
Copy link
Collaborator

Updated the location module to use zbus subscribe instead of a listener for consistency and easier logic. Removed semaphores and modem lib connection handling. Connection handling might be needed unless the location lib doesn't handle this internally, but it should probably be dealt with using the Zephyr State Machine Framework.

@gregersrygg gregersrygg force-pushed the location-use-zbus-sub branch 4 times, most recently from dc13ac9 to 6fda775 Compare June 4, 2024 08:17
Copy link
Collaborator

@simensrostad simensrostad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good,

I get an unknown event when testing, was fixed by adding a handler case for:

case **LOCATION_EVT_STARTED**:
	LOG_WRN("Getting location started");
	break;
default:
	LOG_DBG("Unknown event %d", event_data->id);
	break;

@@ -59,74 +72,49 @@ void location_task(void)
}

err = location_init(location_event_handler);
if (err)
{
if (err) {
LOG_ERR("Unable to init location library: %d", err);
Copy link
Collaborator

@simensrostad simensrostad Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_ERR("Unable to init location library: %d", err);
LOG_ERR("Unable to init location library: %d", err);
SEND_FATAL_ERROR();
return;

static K_SEM_DEFINE(location_lib_sem, 1, 1);
static K_SEM_DEFINE(modem_init_sem, 0, 1);
static K_SEM_DEFINE(trigger_sem, 0, 1);
ZBUS_SUBSCRIBER_DEFINE(location, CONFIG_APP_LOCATION_ZBUS_QUEUE_SIZE);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Forward declarations */

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the PR.

@@ -22,13 +22,10 @@
LOG_MODULE_REGISTER(location_module, CONFIG_APP_LOCATION_LOG_LEVEL);

BUILD_ASSERT(CONFIG_APP_LOCATION_WATCHDOG_TIMEOUT_SECONDS >
CONFIG_APP_LOCATION_TRIGGER_TIMEOUT_SECONDS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Some alignment issues here it looks like. Could align with CONFIG_APP_LOCATION

{
LOG_ERR("Unable to send location request: %d", err);
if (&TRIGGER_CHAN == chan) {
LOG_WRN("Trigger received");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_WRN("Trigger received");
LOG_DBG("Trigger received");

@gregersrygg gregersrygg force-pushed the location-use-zbus-sub branch 2 times, most recently from 0b00ddb to a0272de Compare June 4, 2024 14:08
Updated the location module to use zbus subscribe instead of a listener
for consistency and easier logic. Removed semaphores and modem lib
connection handling. Connection handling might be needed unless the
location lib doesn't handle this internally, but it should probably be
dealt with using the Zephyr State Machine Framework.

Signed-off-by: Gregers Gram Rygg <[email protected]>
@gregersrygg gregersrygg force-pushed the location-use-zbus-sub branch from a0272de to f0545bd Compare June 4, 2024 14:39
Copy link

sonarqubecloud bot commented Jun 4, 2024

@gregersrygg gregersrygg merged commit 9350b6e into main Jun 4, 2024
5 checks passed
@gregersrygg gregersrygg deleted the location-use-zbus-sub branch June 4, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants