Skip to content

Commit

Permalink
examples/awsiot_gnsslogger: Add processing to stop gnss
Browse files Browse the repository at this point in the history
It is necessary to close gnss driver after stopping it.
  • Loading branch information
SPRESENSE committed Mar 9, 2022
1 parent c0055f6 commit f3b5b4b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/awsiot_gnsslogger/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ examples/awsiot_gnsslogger
Location is NOT fixed. 3 satellites is captured.
....

To capture GNSS sattelites, take the device outside or by a window.
To capture GNSS satellites, take the device outside or by a window.

After fix the measured location, the application will set UTC time and
date which is measured by GNSS as a system time on the board. Then it
connects to AWS IoT server.
And after established the connectionm the location latitude and longitude
is published as a topic on "data/device/gps" with below message.

Location is fixed. 4 sattelites is captured.
Location is fixed. 4 satellites is captured.
Publish data to data/device/gps topic as <<{ "device_loc": { "lat": xxx.xxxxx, "lng": xxx.xxxxxx } }>>

If you subscribe the topic "data/device/gps" in AWS IoTCore, you can see
Expand Down
2 changes: 1 addition & 1 deletion examples/awsiot_gnsslogger/awsiot_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int publish_topic(AWS_IoT_Client *client, const char *topic, uint8_t *data, int

if (rc != SUCCESS)
{
printf("An error occured of the publish : %d.\n", rc);
printf("An error occurred of the publish : %d.\n", rc);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/awsiot_gnsslogger/awsiot_gnsslogger_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int main(int argc, FAR char *argv[])

snprintf(topic_name, sizeof(topic_name), LOCATION_TOPIC, app_config.client_id);

/* Initialze GNSS driver */
/* Initialize GNSS driver */

gnss_fd = init_gnss(&mask);
if (gnss_fd < 0)
Expand Down Expand Up @@ -265,7 +265,7 @@ int main(int argc, FAR char *argv[])
aws_iot_mqtt_yield(&client, 10);
break;

case GNSS_UTIL_STATE_ERROR: /* Error is occured */
case GNSS_UTIL_STATE_ERROR: /* Error is occurred */
printf("Known error is returned.. ");
default:
printf("Error happened.\n");
Expand Down
12 changes: 9 additions & 3 deletions examples/awsiot_gnsslogger/gnss_util.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* examples/awsiot_gnsslogger/gnss_util.c
*
* Copyright 2021 Sony Semiconductor Solutions Corporation
* Copyright 2021, 2022 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,6 +37,8 @@
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
Expand Down Expand Up @@ -73,7 +75,7 @@ static struct cxd56_gnss_positiondata_s posdat;
*
* Returned Value:
* Negative value is returned when an error is happened.
* When the initialization is successed, file descripter is returned.
* When the initialization is successful, file descripter is returned.
*
****************************************************************************/

Expand Down Expand Up @@ -108,7 +110,7 @@ int init_gnss(sigset_t *mask)
setting.signo = MY_GNSS_SIG;
setting.data = NULL;
er = ioctl(fd, CXD56_GNSS_IOCTL_SIGNAL_SET, (unsigned long)&setting);
if(er < 0)
if (er < 0)
{
printf("ioctl(SIGNAL_SET) error:%d\n", er);
sigprocmask(SIG_UNBLOCK, mask, NULL);
Expand Down Expand Up @@ -233,6 +235,10 @@ void fin_gnss(int fd, sigset_t *mask)
{
struct cxd56_gnss_signal_setting_s setting;

/* Stop GNSS. */

ioctl(fd, CXD56_GNSS_IOCTL_STOP, 0);

memset(&setting, 0, sizeof(setting));

setting.enable = 0;
Expand Down

0 comments on commit f3b5b4b

Please sign in to comment.