nbiot2 2.1.0.0
main.c File Reference

NB IoT 2 Click Example. More...

#include "board.h"
#include "log.h"
#include "conversions.h"
#include "nbiot2.h"

Macros

#define NBIOT2_TCP_UDP_EXAMPLE
 
#define SMS_TEXT_MODE
 
#define PHONE_NUMBER_TO_MESSAGE   ""
 
#define SIM_SMSC   ""
 
#define REMOTE_IP   "77.46.162.162"
 
#define REMOTE_PORT   "51111"
 
#define SIM_APN   ""
 
#define MESSAGE_CONTENT   "NB IoT 2 Click Example"
 
#define PROCESS_BUFFER_SIZE   200
 
#define CONFIGURATION_FOR_EXAMPLE   0
 
#define EXAMPLE   1
 
#define CONNECTED   "+CGATT: 1"
 
#define CONTEXTID   "1"
 
#define TCP_PROTOCOL   "0"
 
#define UDP_PROTOCOL   "1"
 
#define URC_READ_SOCKET_DATA   "+QIURC: \"recv\""
 

Functions

void application_init (void)
 
void application_task (void)
 
int main (void)
 

Detailed Description

NB IoT 2 Click Example.

Description

This example reads and processes data from NB IoT 2 clicks.

The demo application is composed of two sections :

Application Init

Initializes driver, wake-up module and sets default configuration for connecting device to network.

Application Task

This application is split into two examples:

  • TCP/UDP example - connecting to echo server and writing and reading data.
  • SMS example - Sending SMS message to desired number using TEXT or PDU mode.

Additional Function

  • static void nbiot2_clear_app_buf ( void )
  • static err_t nbiot2_process ( void )
  • static void nbiot2_config_device_for_example ( void )
  • static void nbiot2_check_connection ( void )
  • static void nbiot2_log_response ( void )
  • static void nbiot2_error_check( err_t error_flag );
  • static err_t nbiot2_check_response ( void )
  • static void nbiot2_config_device_for_network ( void )
  • static void nbiot2_send_sms ( void )
  • static void nbiot2_config_device_for_tcp_udp ( void )
  • static void nbiot2_tcp_udp_example ( void )
Note
In order for the examples to work, user needs to set the APN and SMSC (SMS PDU mode only) of entered SIM card as well as the phone number to which he wants to send an SMS. Enter valid values for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER_TO_MESSAGE. Example: SIM_APN "internet" SIM_SMSC "+381610401" PHONE_NUMBER_TO_MESSAGE "+381659999999"
Author
Stefan Ilic

Macro Definition Documentation

◆ CONFIGURATION_FOR_EXAMPLE

#define CONFIGURATION_FOR_EXAMPLE   0

◆ CONNECTED

#define CONNECTED   "+CGATT: 1"

◆ CONTEXTID

#define CONTEXTID   "1"

◆ EXAMPLE

#define EXAMPLE   1

◆ MESSAGE_CONTENT

#define MESSAGE_CONTENT   "NB IoT 2 Click Example"

◆ NBIOT2_TCP_UDP_EXAMPLE

#define NBIOT2_TCP_UDP_EXAMPLE

◆ PHONE_NUMBER_TO_MESSAGE

#define PHONE_NUMBER_TO_MESSAGE   ""

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   200

◆ REMOTE_IP

#define REMOTE_IP   "77.46.162.162"

◆ REMOTE_PORT

#define REMOTE_PORT   "51111"

◆ SIM_APN

#define SIM_APN   ""

◆ SIM_SMSC

#define SIM_SMSC   ""

◆ SMS_TEXT_MODE

#define SMS_TEXT_MODE

◆ TCP_PROTOCOL

#define TCP_PROTOCOL   "0"

◆ UDP_PROTOCOL

#define UDP_PROTOCOL   "1"

◆ URC_READ_SOCKET_DATA

#define URC_READ_SOCKET_DATA   "+QIURC: \"recv\""

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )