Data Logger BLE Cellular Board
Loading...
Searching...
No Matches
jfet_commandLine.c File Reference

Command Line Interface (CLI) functions and commands. More...

#include "jfet_files/common.h"
#include "jfet_files/w25q64jv_Driver.h"
#include <zephyr/drivers/i2c.h>
#include "HDC2080.h"
#include "ncs_version.h"
#include <bluetooth/services/nus.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/pm/device.h>

Go to the source code of this file.

Macros

#define __USE_MINGW_ANSI_STDIO   1
 
#define LINE_SIZE   90
 maximum number of characters on a CLI line
 
#define NUM_LINES   10
 maximum number of lines in saved history
 

Enumerations

enum  COMMANDS {
  ADCX , BATMON , BME688 , BME688CS ,
  DATETIME , DEVICEID , DEVICEINFO , CUSTOMER ,
  DUTYCYCLE , FLASHERASE , FLASHERASESECTOR , FLASHFILLPAGE ,
  FLASHID , FLASHNSS , FLASHREADPAGE , FLASHSTATUS ,
  FLASHWRITEPAGE , FLASHPARAMETERS , GROUP , HELP ,
  HUMIDITY , I2CREAD , I2CWRITE , IGNOREBME688 ,
  LOCATION , MANUALTRIGGER , NOUART0 , PUBLISHNOW ,
  RESCAN , RESETX , RESETCAUSE , SAVED ,
  SENSORID , SENSORNAME , SILENT , SENSORS ,
  TEMP , VERSIONX
}
 < vaild command indexes More...
 

Functions

void executeCmd (char *line)
 executes the command in line array.
 
int8_t getCLICmd (char *line)
 parses command line to find position of command in validCLICmds array.
 
void cliADC ()
 CLI command to sample and display the ADC voltage.
 
void cliBatMon ()
 CLI command to enable or disable the battery monitor hardware.
 
void cliBME688 ()
 CLI command to read and display data from the BME688 sensor.
 
void cliBME688CS ()
 CLI command to manually control the BME688 SPI Chip Select (CS) pin.
 
void cliDeviceID ()
 Display the unique device identifier string.
 
void cliDeviceInfo ()
 Transmit comprehensive device information over BLE NUS service.
 
void cliCustomer ()
 CLI command to set or display the customer name in flash parameters.
 
void cliDateTime ()
 CLI command to set or display the gateway epoch timestamp.
 
void cliDutyCycle ()
 CLI command to configure the sensor data sampling interval.
 
void cliFlashErase ()
 CLI command to erase the entire external flash memory.
 
void cliFlashEraseSector ()
 CLI command to erase a specific 4KB sector of the external flash.
 
void cliFlashFillPage ()
 CLI command to fill one or more flash pages with a specific 32-bit data pattern.
 
void cliFlashID ()
 CLI command to read and display the unique Flash memory ID.
 
void cliFlashNSS ()
 CLI command to manually toggle the SPI Chip Select (NSS) for the Flash memory.
 
void cliFlashReadPage ()
 CLI command to read and display the contents of external flash pages.
 
void cliFlashStatus ()
 CLI command to read and display the status registers of the external flash.
 
void cliFlashWritePage ()
 CLI command to write a single byte of data to a specific address within a flash page.
 
void cliGroup ()
 CLI command to set or display the sensor group name.
 
void cliHelp ()
 CLI command to display help information for available commands.
 
void cliHumidity ()
 CLI command to display humidity data from connected sensors.
 
void cliNouart0 (void)
 
void cliI2CRead ()
 CLI command to read data from an I2C device.
 
void cliI2CWrite ()
 CLI command to write data to a specific I2C device register.
 
void cliIgnoreBME688 ()
 CLI command to set or display the ignore BME688 flag.
 
void cliLocation ()
 CLI command to set or display the sensor's physical location.
 
void cliManualTrigger (void)
 CLI command to set or display the manual trigger mode flag.
 
void cliPublishNow ()
 CLI command to trigger an immediate sensor data publication.
 
void cliReset ()
 CLI command to reset the processor.
 
void cliResetCause ()
 CLI command to display the reason for the last processor reset.
 
void cliSaved ()
 CLI command to manage and display JSON packets saved in external flash.
 
void cliSensorID ()
 CLI command to set or display the unique sensor ID.
 
void cliSensorName ()
 CLI command to set or display the human-readable sensor name.
 
void cliSensors ()
 CLI command to list all supported sensors and their detection status.
 
void cliSilent ()
 CLI command to set or display the silent mode flag.
 
void cliTemperature ()
 CLI command to display temperature data from connected sensors.
 
void cliVersion ()
 CLI command to display firmware, hardware, and SDK version information.
 
void displayHelp (char c)
 displays a list of all available CLI commands
 
int uart_init (void)
 
void int64_to_string (int64_t num, char *str)
 Converts a 64-bit signed integer to a null-terminated string.
 

Variables

static char lineTmp [LINE_SIZE]
 tempory line saved
 
char * sensorTypeNames []
 sensor types and state (present = 1)
 
char const * validCLICmds []
 array of valid commands - case insensitive
 
char const * helpMessages []
 array of help messages
 

Detailed Description

Command Line Interface (CLI) functions and commands.

Author
T. J. Mulrooney

Definition in file jfet_commandLine.c.

Macro Definition Documentation

◆ __USE_MINGW_ANSI_STDIO

#define __USE_MINGW_ANSI_STDIO   1

Definition at line 18 of file jfet_commandLine.c.

◆ LINE_SIZE

#define LINE_SIZE   90

maximum number of characters on a CLI line

Definition at line 141 of file jfet_commandLine.c.

◆ NUM_LINES

#define NUM_LINES   10

maximum number of lines in saved history

Definition at line 142 of file jfet_commandLine.c.

Enumeration Type Documentation

◆ COMMANDS

enum COMMANDS

< vaild command indexes

  • external *‍/ /extern struct cloud_data_cfg current_cfg;* globals *‍/
Enumerator
ADCX 
BATMON 
BME688 
BME688CS 
DATETIME 
DEVICEID 
DEVICEINFO 
CUSTOMER 
DUTYCYCLE 
FLASHERASE 
FLASHERASESECTOR 
FLASHFILLPAGE 
FLASHID 
FLASHNSS 
FLASHREADPAGE 
FLASHSTATUS 
FLASHWRITEPAGE 
FLASHPARAMETERS 
GROUP 
HELP 
HUMIDITY 
I2CREAD 
I2CWRITE 
IGNOREBME688 
LOCATION 
MANUALTRIGGER 
NOUART0 
PUBLISHNOW 
RESCAN 
RESETX 
RESETCAUSE 
SAVED 
SENSORID 
SENSORNAME 
SILENT 
SENSORS 
TEMP 
VERSIONX 

Definition at line 97 of file jfet_commandLine.c.

Function Documentation

◆ cliADC()

void cliADC ( void )

CLI command to sample and display the ADC voltage.

This function triggers an ADC sampling process and prints the resulting voltage from the primary channel to the console.

Definition at line 536 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliBatMon()

void cliBatMon ( void )

CLI command to enable or disable the battery monitor hardware.

This function parses the command line parameter to set the state of the battery enable (BATEN) GPIO pin.

Definition at line 558 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliBME688()

void cliBME688 ( void )

CLI command to read and display data from the BME688 sensor.

Definition at line 580 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliBME688CS()

void cliBME688CS ( void )

CLI command to manually control the BME688 SPI Chip Select (CS) pin.

Definition at line 611 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliCustomer()

void cliCustomer ( void )

CLI command to set or display the customer name in flash parameters.

Definition at line 641 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliDateTime()

void cliDateTime ( )

CLI command to set or display the gateway epoch timestamp.

Definition at line 689 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliDeviceID()

void cliDeviceID ( void )

Display the unique device identifier string.

Definition at line 717 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliDeviceInfo()

void cliDeviceInfo ( void )

Transmit comprehensive device information over BLE NUS service.

This function iterates through various device parameters (ID, Name, Customer, etc.) and sends them both to the local console and over the Bluetooth NUS service.

Definition at line 727 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliDutyCycle()

void cliDutyCycle ( void )

CLI command to configure the sensor data sampling interval.

< HDC2080 specific rate code

< Pointer for strtoul parsing

< String representation of the duty cycle

Definition at line 817 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashErase()

void cliFlashErase ( void )

CLI command to erase the entire external flash memory.

Definition at line 892 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashEraseSector()

void cliFlashEraseSector ( void )

CLI command to erase a specific 4KB sector of the external flash.

If no parameter is provided, it defaults to erasing the parameter storage sector. Erasing the parameter sector also triggers a reset of the local parameter structure.

Definition at line 914 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashFillPage()

void cliFlashFillPage ( void )

CLI command to fill one or more flash pages with a specific 32-bit data pattern.

Definition at line 946 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashID()

void cliFlashID ( void )

CLI command to read and display the unique Flash memory ID.

This function retrieves the manufacturer and device identification from the external SPI flash and prints it to the console.

Definition at line 993 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashNSS()

void cliFlashNSS ( void )

CLI command to manually toggle the SPI Chip Select (NSS) for the Flash memory.

This is used for hardware debugging to verify the SPI CS1 line state.

Definition at line 1007 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashReadPage()

void cliFlashReadPage ( void )

CLI command to read and display the contents of external flash pages.

This function reads 256-byte pages from the SPI flash and displays them in a hex-dump format with corresponding ASCII representation.

Definition at line 1038 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashStatus()

void cliFlashStatus ( void )

CLI command to read and display the status registers of the external flash.

This function reads the three status registers from the SPI flash and decodes individual bits such as Busy, Write Enable, and Protection settings.

Definition at line 1099 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliFlashWritePage()

void cliFlashWritePage ( void )

CLI command to write a single byte of data to a specific address within a flash page.

This function parses the page index, the byte offset within that page, and the data byte to be written. It validates the ranges before calling the flash driver.

Definition at line 1130 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliGroup()

void cliGroup ( void )

CLI command to set or display the sensor group name.

If a parameter is provided, it updates the group name in the flash parameters.

Definition at line 1174 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliHelp()

void cliHelp ( void )

CLI command to display help information for available commands.

Definition at line 1191 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliHumidity()

void cliHumidity ( void )

CLI command to display humidity data from connected sensors.

Definition at line 1207 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliI2CRead()

void cliI2CRead ( void )

CLI command to read data from an I2C device.

Parses the command line for I2C address, register, and length, then performs the read operation and prints the results in hex.

Definition at line 1237 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliI2CWrite()

void cliI2CWrite ( void )

CLI command to write data to a specific I2C device register.

This function parses the I2C slave address, the target register, and the data byte from the command line, then executes the I2C write transaction.

Definition at line 1278 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliIgnoreBME688()

void cliIgnoreBME688 ( void )

CLI command to set or display the ignore BME688 flag.

Definition at line 1376 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliLocation()

void cliLocation ( void )

CLI command to set or display the sensor's physical location.

If a location string is provided, it updates the flash parameters.

Definition at line 1407 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliManualTrigger()

void cliManualTrigger ( void )

CLI command to set or display the manual trigger mode flag.

Definition at line 1424 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliNouart0()

void cliNouart0 ( void )

Definition at line 1313 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliPublishNow()

void cliPublishNow ( void )

CLI command to trigger an immediate sensor data publication.

This function releases the hdc_rdy_seen semaphore to bypass the normal duty cycle timer and force a sensor read/BLE transmission.

Definition at line 1456 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliReset()

void cliReset ( void )

CLI command to reset the processor.

If called without parameters, it performs a clean system reset. If called with any parameter, it stops the watchdog feeder to force a WDT reset.

Definition at line 1471 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliResetCause()

void cliResetCause ( void )

CLI command to display the reason for the last processor reset.

Definition at line 1490 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliSaved()

void cliSaved ( void )

CLI command to manage and display JSON packets saved in external flash.

This function allows the user to clear all saved packets, read a specific packet, or display a range of packets stored in the flash memory.

Definition at line 1503 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliSensorID()

void cliSensorID ( void )

CLI command to set or display the unique sensor ID.

If a parameter is provided, it updates the sensorID in flash memory.

Definition at line 1571 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliSensorName()

void cliSensorName ( void )

CLI command to set or display the human-readable sensor name.

Updates the sensorName in flash parameters if a new name is provided.

Definition at line 1590 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliSensors()

void cliSensors ( void )

CLI command to list all supported sensors and their detection status.

Checks the sensorTypePresentAll bitmask against the known sensor list.

Definition at line 1609 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliSilent()

void cliSilent ( void )

CLI command to set or display the silent mode flag.

Definition at line 1634 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliTemperature()

void cliTemperature ( void )

CLI command to display temperature data from connected sensors.

Reads the current temperature from the HDC2080 and displays it alongside the configured low and high alarm thresholds.

Definition at line 1666 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliVersion()

void cliVersion ( void )

CLI command to display firmware, hardware, and SDK version information.

Definition at line 1689 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayHelp()

void displayHelp ( char c)

displays a list of all available CLI commands

Parameters
ccheck for only help messages beginning with c

Definition at line 489 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeCmd()

void executeCmd ( char * line)

executes the command in line array.

  • prottypes *‍/

Definition at line 270 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCLICmd()

int8_t getCLICmd ( char * line)

parses command line to find position of command in validCLICmds array.

goes through line array separated by spaces. cmdLineParameter[numParameters]
is an array of pointers to the various parameters in the line until the end of line then
searches cmd array for a match in validCLICmds array.

Returns
int8 - position of command in command array if found. -1 if not found

Definition at line 444 of file jfet_commandLine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ int64_to_string()

void int64_to_string ( int64_t num,
char * str )

Converts a 64-bit signed integer to a null-terminated string.

Parameters
numThe 64-bit integer to convert.
strPointer to the destination buffer (must be large enough to hold the result).

Definition at line 663 of file jfet_commandLine.c.

Here is the caller graph for this function:

◆ uart_init()

int uart_init ( void )
Here is the caller graph for this function:

Variable Documentation

◆ helpMessages

char const* helpMessages[]
Initial value:
= {
"adc - display Battery voltage AIN0",
"batmon - <0 | 1> enable or disable Battery monitor",
"bme688 <n> - read n sample from BME688",
"bme688cs <0 | 1> - display/set BME688 CS",
"datetime save data/time from gateway"
"deviceid - display Device ID",
"deviceinfo - display device information",
"customer [X]- display/set customer",
"dutycycle [0 <minutes> | 1-7] - 0=minutes,1=2min,2=1min,3=10secs,4=5secs,5=1secs,6=.5secs,7=.2secs",
"flasherase - erase entire memory",
"flasherasesector - [sector] erase 256K Byte sector X (default 0) range ( 0 -> 31)",
"flashfillpage [page data length] - fill length pages with data starting at page",
"flashid - display serial flash ID",
"flashnss <0 | 1> - set SPI NSS",
"flashparameters - list the saved flash parameters",
"flashreadpage [page length] - read length pages starting at page",
"flashstatus - display serial flash status registers",
"flashwritepage page address data - write data to address in page",
"group [X]- display/set group",
"help [c] - display list of valid commands starting with c",
"humidity- display humidity",
"i2cread [add reg length] - read length bytes from I2C address starting at r",
"i2cwrite add reg data length - write byte to I2C address at reg",
"ignorebme688 [0 | 1] - display set ignore BME688 flag",
"location [X]- display/set location",
"manualtrigger [0 | 1] - display set manual trigger flag",
"nouart0 [0/1] - display/set No UART0",
"publishnow- publish a BLE payload now",
"rescan - rescan for connected devices",
"reset [x]- reset the board any paramter causes a WDT reset",
"resetCause - display reason for last reset ",
"saved [clear | n] [count]- display count saved flash JSON packets or clear all saved packets",
"sensorid [X]- display/set sensor ID",
"sensorname - display/set sensor name",
"sensors - display available sensors",
"silent [0 | 1]- display/set silent flag",
"temp- display sensor temperatures ",
"version - display version information",
"END",
}

array of help messages

Definition at line 216 of file jfet_commandLine.c.

◆ lineTmp

char lineTmp[LINE_SIZE]
static

tempory line saved

Definition at line 153 of file jfet_commandLine.c.

◆ sensorTypeNames

char* sensorTypeNames[]
Initial value:
=
{
"HDC2080 - temperature/Humidty Sensor(I2C 0x40)",
"W25Q64JV - 64MB Flash memory(SPI CS1)",
"BME688 - Gas/Pressure/temperature/Humidty Sensor(SPI CS2)",
"Unknown",
}

sensor types and state (present = 1)

Definition at line 164 of file jfet_commandLine.c.

◆ validCLICmds

char const* validCLICmds[]
Initial value:
=
{
"adc",
"batmon",
"bme688",
"bme688cs",
"datetime",
"deviceid",
"deviceinfo",
"customer",
"dutycycle",
"flasherase",
"flasherasesector",
"flashfillpage",
"flashid",
"flashnss",
"flashreadpage",
"flashstatus",
"flashwritepage",
"flashparameters",
"group",
"help",
"humidity",
"i2cread",
"i2cwrite",
"ignorebme688",
"location",
"manualtrigger",
"nouart0",
"publishnow",
"rescan",
"reset",
"resetcause",
"saved",
"sensorid",
"sensorname",
"silent",
"sensors",
"temp",
"version",
}

array of valid commands - case insensitive

Definition at line 172 of file jfet_commandLine.c.