Skip to content

Commit

Permalink
examples/ambient_gnsslogger: Add Ambient GNSS Logger application
Browse files Browse the repository at this point in the history
Add new example to upload the positioning data acquired by GNSS
to the Ambient service. This application uses the Ambient library.
  • Loading branch information
SPRESENSE committed Mar 9, 2022
1 parent b65ac37 commit c05721b
Show file tree
Hide file tree
Showing 7 changed files with 762 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/ambient_gnsslogger/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config EXAMPLES_AMBIENT_GNSSLOGGER
tristate "Ambient GNSS Logger example"
default n
depends on SYSTEM_AMBIENT
---help---
Enable the Ambient GNSS Logger application

if EXAMPLES_AMBIENT_GNSSLOGGER

config EXAMPLES_AMBIENT_GNSSLOGGER_PROGNAME
string "Program name"
default "ambient_gnsslogger"
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.

config EXAMPLES_AMBIENT_GNSSLOGGER_PRIORITY
int "Ambient GNSS Logger task priority"
default 100

config EXAMPLES_AMBIENT_GNSSLOGGER_STACKSIZE
int "Ambient GNSS Logger stack size"
default DEFAULT_TASK_STACKSIZE

endif
38 changes: 38 additions & 0 deletions examples/ambient_gnsslogger/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
############################################################################
# examples/ambient_gnsslogger/Make.defs
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of Sony Semiconductor Solutions Corporation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

ifneq ($(CONFIG_EXAMPLES_AMBIENT_GNSSLOGGER),)
CONFIGURED_APPS += ambient_gnsslogger
endif
55 changes: 55 additions & 0 deletions examples/ambient_gnsslogger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
############################################################################
# examples/ambient_gnsslogger/Makefile
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of Sony Semiconductor Solutions Corporation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

include $(APPDIR)/Make.defs
include $(SDKDIR)/Make.defs

# Ambient GNSS Logger built-in application info

PROGNAME = $(CONFIG_EXAMPLES_AMBIENT_GNSSLOGGER_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_AMBIENT_GNSSLOGGER_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_AMBIENT_GNSSLOGGER_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_AMBIENT_GNSSLOGGER)

# Ambient GNSS Logger example

ASRCS =
CSRCS = gnss_util.c
MAINSRC = ambient_gnsslogger_main.c

CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
"$(SDKDIR)$(DELIM)system$(DELIM)ambient"}

include $(APPDIR)/Application.mk
114 changes: 114 additions & 0 deletions examples/ambient_gnsslogger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Examples / `ambient_gnsslogger` Ambient GNSS Logger application

## Description

The `ambient_gnsslogger` is an application to upload the positioning data
acquired by Spresense GNSS to the Ambient service. Ambient is an IoT data
visualization service. It receives, stores, and visualizes sensor data
sent from microcontrollers and other devices.

https://ambidata.io/

To use Ambient service, you need to register as a user.

Please see below for more details.

https://ambidata.io/docs/gettingstarted/

The procedure to use the Ambient service is as below:

1. User registration (free of charge)
2. Channel generation
3. Microcontroller-side programming
4. Data transmission
5. Visualization (graphing)

## How to configuration and build

This application uses an Ambient library and any network feature.
The explanation shows an example using LTE network.

```bash
$ cd spresense/sdk
$ ./tools/config.py feature/lte examples/ambient_gnsslogger
$ make
```

## Running this application


The first step is to connect to the LTE network.

```bash
*** Usage ***
nsh> lte_sysctl
lte_sysctl: missing required argument(s)

USAGE: lte_sysctl command
[-a <apn_name>] [-i <ip_type>] [-v <auth_type>] [-u <user_name>] [-p <password>] [-r <rat_type>] start
-a: APN name
-i: IP type 0=IPv4, 1=IPv6, 2=IPv4 and IPv6, 3=Non-IP
-v: Authenticaion type 0=NONE, 1=PAP, 2=CHAP
-u: User name for authenticaion
-p: Password for authenticaion
-r: Radio Access Technology type M1=CAT-M1, NB=NB-IoT
stop
stat
[-h]: Show this message

*** Specify the appropriate parameters based on your SIM and start ***
nsh> lte_sysctl -a <apn_name> -u <user_name> -p <password> start

*** Enable the network interface ***
nsh> ifup eth0
ifup eth0...OK

*** You can confirm if your board is connected to the network ***
nsh> ifconfig
```
The next step uses the channel ID and write key you generated on the Ambient server.
```bash
*** Usage ***
nsh> ambient_gnsslogger -h
Usage: ambient_gnsslogger [-c <channel>] [-w <write_key>]
Options:
-c: channel ID
-w: write key string

```
For example, it shows a command in the following cases.
- channelID : 123456
- write_key : 1234567890123456
```bash
nsh> ambient_gnsslogger -c 123456 -w 1234567890123456
Create: channel=123456 write_key=1234567890123456
gnss: state=-1, satellites=0
gnss: state=0, satellites=0
gnss: state=0, satellites=7
gnss: state=0, satellites=7
gnss: state=0, satellites=8
:
gnss: state=1, satellites=11
lat=xx.xxxxxx lng=xxx.xxxxxx
gnss: state=1, satellites=12
lat=xx.xxxxxx lng=xxx.xxxxxx
```
You can edit an `ambient_gnsslogger_main.c` and pre-set your own channel and write key.
Then you do not need to specify `-c` and `-w` options of the `ambient_gnsslogger` arguments.
```c
#define MY_CHANNEL 123456
#define MY_WRITEKEY "1234567890123456"
```
```bash
nsh> ambient_gnsslogger
```
Finally, you will view the positioning data on the Ambient server.
Loading

0 comments on commit c05721b

Please sign in to comment.