669 lines
20 KiB
C
669 lines
20 KiB
C
/*
|
|
************************************************************************
|
|
**
|
|
** Copyright (c) 2008..2010 by
|
|
** Core|Vision B.V.
|
|
** Cereslaan 10b
|
|
** 5384 VT Heesch
|
|
** The Netherlands
|
|
**
|
|
** All Rights Reserved
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Project name: Dual Inventive: Communication Protocol 3000
|
|
** Filename: cp3000-cmd.h
|
|
** Author: Jack Weeland
|
|
** Date: July 9, 2008
|
|
** File version: 1.00 of April 29, 2010
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** CP3000 command definitions
|
|
**
|
|
************************************************************************
|
|
*/
|
|
|
|
#ifndef _CP3000_CMD_H_COMMON
|
|
#define _CP3000_CMD_H_COMMON
|
|
|
|
/*
|
|
** Default port number
|
|
*/
|
|
#define TCPSERVER_DEFAULT_PORT 3000
|
|
#define SMSSERVER_DEFAULT_PORT 3030
|
|
#define SECURESERVER_DEFAULT_PORT 3300
|
|
|
|
/*
|
|
** Status codes and token components
|
|
*/
|
|
|
|
#define TCPFMT_TOKEN_CMD "$"
|
|
#define TCPFMT_TOKEN_REPLY "!"
|
|
#define TCPFMT_TOKEN_CHECKSUM "*"
|
|
#define TCPFMT_TOKEN_CLIENTSEP "@"
|
|
#define TCPFMT_TOKEN_SEP ","
|
|
#define TCPFMT_STATUS_FMT "%02X"
|
|
#define TCPFMT_STATUS_BASE 16 // for 'strtoul()'
|
|
#define TCPFMT_STATUS TCPFMT_TOKEN_REPLY TCPFMT_STATUS_FMT
|
|
#define TCPFMT_REPLY_DATA TCPFMT_TOKEN_SEP "\"%s\""
|
|
#define TCPFMT_CLIENT_FMT "%u"
|
|
#define TCPFMT_CLIENT_BASE 10 // for 'strtoul()'
|
|
#define TCPFMT_CLIENT TCPFMT_TOKEN_CLIENTSEP TCPFMT_CLIENT_FMT
|
|
#define TCPFMT_CHECKSUM_FMT "%02X"
|
|
#define TCPFMT_CHECKSUM TCPFMT_TOKEN_CHECKSUM TCPFMT_CHECKSUM_FMT "\n"
|
|
#define TCPFMT_CHILD_FMT "%s" // child devices are identified by hardware address
|
|
|
|
/*
|
|
** TCP protocol messages
|
|
**
|
|
** Messages are formatted like the NMEA format:
|
|
** $WHAT,<parameters>*CHECKSUM\n
|
|
**
|
|
** Return and status codes are formated like this:
|
|
** !<code>,<description>*CHECKSUM\n
|
|
*/
|
|
|
|
// Maximum length of a TCP message
|
|
#define TCPMSG_MAXLEN 2048
|
|
|
|
/*
|
|
** Messages from ZKL to database server
|
|
*/
|
|
|
|
// ZKL login message
|
|
// Parameters
|
|
// 1 IMEI (string)
|
|
// 2 reprogramming counter (16-bit unsigned integer)
|
|
// 3 start-up counter (16-bit unsigned integer)
|
|
// 4 Primary channel
|
|
// 5 Encoded password or signature (TBD)
|
|
#define TCPID_LOGIN "$ZKL"
|
|
#define TCP_N_LOGIN (1 + 5)
|
|
#define TCPFMT_LOGIN TCPID_LOGIN ",\"%s\",%u,%u,%d,\"%s\""
|
|
|
|
// ZKL logout message
|
|
#define TCPID_LOGOUT "$EXIT"
|
|
#define TCP_N_LOGOUT (1)
|
|
#define TCPFMT_LOGOUT TCPID_LOGOUT
|
|
|
|
// Register a log file; status updates are done by TCPID_RESEND as off 20090729
|
|
// Parameters
|
|
// 1 Reprogramming counter
|
|
// 2 Start-up counter
|
|
// 3 File size
|
|
// 4 Error code (obsolete 20090729)
|
|
// 0: update status
|
|
// other: error code
|
|
#define TCPID_LOGFILE "$LOGFILE"
|
|
#define TCP_N_LOGFILE (1 + 3)
|
|
#define TCP_N_LOGFILE_OLD (1 + 4)
|
|
#define TCP_N_LOGFILE_NONE (1)
|
|
#define TCPFMT_LOGFILE TCPID_LOGFILE ",%u,%u,%lu"
|
|
|
|
// Log entry
|
|
// Parameters
|
|
// 1 Major identifier for the log entry
|
|
// 2 Minor identifier for the log entry
|
|
// 3 Reprogramming counter
|
|
// 4 Start-up counter
|
|
// 5 Next position in the log file (following this entry)
|
|
// 6 Time stamp
|
|
// 7 Sequence number
|
|
// ... Other parameters (maximum: 10)
|
|
#define TCPID_LOG "$LOG"
|
|
#define TCP_NF_LOG (1 + 7) /* fixed nr items */
|
|
#define TCP_N_LOG (TCP_NF_LOG + 10) /* max nr items */
|
|
#define TCPFMT_LOG TCPID_LOG ",%u,%u,%u,%u,%lu,%lu,%lu"
|
|
#define TCPFMT_LOG_NOTIME TCPID_LOG ",%u,%u,%u,%u,,,"
|
|
|
|
// Sync black box log with the database
|
|
// Parameters
|
|
// 1 Reprogramming counter
|
|
// 2 Start-up counter
|
|
// 3 File position
|
|
// 4 Time stamp
|
|
// 5 Old time stamp, for resyncing the database (optional)
|
|
#define TCPID_SYNC "$SYNC"
|
|
#define TCP_N_SYNC (1 + 4 + 1)
|
|
#define TCPFMT_SYNC TCPID_SYNC ",%u,%u,%lu,%lu"
|
|
#define TCPFMT_RESYNC TCPID_SYNC ",%u,%u,%lu,%lu,%lu"
|
|
|
|
// Status
|
|
// Parameters (device to server)
|
|
// 1 What has changed (bitfield)
|
|
// 2 Full status
|
|
#define TCPID_STATUPDATE "$STAT"
|
|
#define TCPID_STATUPDATE_JSON TCPID_STATUPDATE "[JSON]"
|
|
#define TCP_N_STATUPDATE (1 + 2)
|
|
#define TCP_N_STATCACHE (1)
|
|
#define TCPFMT_STATUPDATE_CHNG "%u"
|
|
#define TCPFMT_STATUPDATE TCPID_STATUPDATE "," TCPFMT_STATUPDATE_CHNG ",\"%s\""
|
|
#define TCPFMT_STATCACHE TCPID_STATUPDATE
|
|
#define TCPFMT_STATCACHE_JSON TCPID_STATUPDATE_JSON
|
|
|
|
// Update status, as a (ideally) shorter and more extendable alternative
|
|
// for the STATUPDATE.
|
|
// Parameters
|
|
// 1 Item (simple, single string or numeric)
|
|
// 2 Value
|
|
// No parameters for heartbeat messages (a.k.a. "update cache")
|
|
#define TCPID_UPDATE "$UPDT"
|
|
#define TCP_N_UPDATE (1 + 2)
|
|
#define TCP_N_UPDATECACHE (1)
|
|
#define TCPFMT_UPDATE TCPID_UPDATE ",%u,\"%s\""
|
|
#define TCPFMT_UPDATECACHE TCPID_UPDATE
|
|
|
|
// Abort-command; shuts down the ZKL side of the TCP-server
|
|
// This command is _not_ to be used under normal circumstances;
|
|
// it is used by the TCP-server itself to terminate a hanging
|
|
// server (which may occur when the connection failes, the ZKL
|
|
// tries to connect again but the old connection did not yet
|
|
// notice that it has lost its connection)
|
|
// Parameter:
|
|
// 1 Sender's own process ID
|
|
#define TCPID_ABORT "$ABORT"
|
|
#define TCP_N_ABORT 2
|
|
#define TCPFMT_ABORT TCPID_ABORT ",%lu"
|
|
|
|
/*
|
|
** Messages from database or web server to ZKL
|
|
*/
|
|
|
|
// Database/webserver login
|
|
// Note: obsolete
|
|
// Parameters
|
|
// 1 Database ID of the ZKL
|
|
// 2 channel for alarm messages
|
|
#define TCPID_DB "$DB"
|
|
#define TCP_N_DB 3
|
|
#define TCPFMT_DB TCPID_DB ",%u,%d"
|
|
|
|
// MTinfo login
|
|
// Parameters
|
|
// 1 Database ID of the ZKL
|
|
// 2 channel for alarm messages
|
|
// 3 security key
|
|
#define TCPID_MTINFO "$MTINFO"
|
|
#define TCP_N_MTINFO 3
|
|
#define TCPFMT_MTINFO TCPID_MTINFO ",%u,%d,\"%s\""
|
|
|
|
// MTinfo Secure login
|
|
// Parameters
|
|
// 1 Database ID of the ZKL
|
|
// 2 channel for alarm messages
|
|
// 3 security key
|
|
#define TCPID_MTINFO_SECURE "$SECURE"
|
|
#define TCP_N_MTINFO_SECURE 3
|
|
#define TCPFMT_MTINFO_SECURE TCPID_MTINFO_SECURE ",%u,%d,\"%s\""
|
|
|
|
// Database/webserver changes a value on the ZKL3000
|
|
// Parameters
|
|
// 1 Key (as in the SMS interface)
|
|
// 2 Value
|
|
#define TCPID_DBSTOR "$STOR"
|
|
#define TCP_N_DBSTOR 3
|
|
#define TCPFMT_DBSTOR TCPID_DBSTOR ",\"%s\",\"%s\""
|
|
#define TCPFMT_DBSTOR_CLIENT TCPID_DBSTOR TCPFMT_CLIENT ",\"%s\",\"%s\""
|
|
|
|
// Database/webserver retrieves a value on the ZKL3000
|
|
// Parameters
|
|
// 1 Key (as in the SMS interface)
|
|
#define TCPID_DBRETR "$RETR"
|
|
#define TCP_N_DBRETR 2
|
|
#define TCPFMT_DBRETR TCPID_DBRETR ",\"%s\""
|
|
#define TCPFMT_DBRETR_CLIENT TCPID_DBRETR TCPFMT_CLIENT ",\"%s\""
|
|
|
|
// Connection watchdog reset
|
|
#define TCPID_DBWDRST "$WD"
|
|
#define TCP_N_DBWDRST 0
|
|
#define TCPFMT_DBWDRST TCPID_DBWDRST
|
|
|
|
// Gateway command
|
|
// Parameters:
|
|
// 1 Child index
|
|
// 2 Command
|
|
// 3.. Argument(s) for command
|
|
#define TCPID_GATEWAYCMD "$GW"
|
|
#define TCPFMT_GATEWAYCMD TCPID_GATEWAYCMD "," TCPFMT_CHILD_FMT ",%s"
|
|
#define TCPFMT_GATEWAYCMD_CLIENT TCPID_GATEWAYCMD TCPFMT_CLIENT "," TCPFMT_CHILD_FMT ",%s"
|
|
|
|
// Locking (from peer to database server)
|
|
// No parameters
|
|
// Returns:
|
|
// TCPSTAT_OK
|
|
// TCPSTAT_BUSY when locked by another entity
|
|
#define TCPID_LOCK "$LOCK"
|
|
#define TCP_N_LOCK (1)
|
|
#define TCPID_UNLOCK "$UNLOCK"
|
|
#define TCP_N_UNLOCK (1)
|
|
|
|
// Set authorization
|
|
// Paramter
|
|
// 1 Authorization token
|
|
#define TCPID_AUTH "$AUTH"
|
|
#define TCPID_N_AUTH 2
|
|
#define TCPFMT_AUTH TCPID_AUTH ",\"%s\""
|
|
|
|
// Request ZKL3000 to resent log data _or_ ZKL registers a log file
|
|
// Parameters to ZKL
|
|
// 1 Resend from this reprogramming count; can be negative to indicate
|
|
// special cases
|
|
// 2 Resend from this start-up count
|
|
// If reprogramming count is '-1':
|
|
// -1 abort replay
|
|
// 1 set battery #1 age and time base
|
|
// 2 set battery #2 age and time base
|
|
// 3 File position in the log file to start resending from
|
|
// 4 Time base
|
|
// 5 Initial sequence number
|
|
// Parameters from ZKL
|
|
// 1 Reprogramming counter
|
|
// 2 Start-up counter
|
|
// 3 File size
|
|
// 4 Error code
|
|
// 0: update status
|
|
// other: error code
|
|
#define TCPID_DBRESEND "$REPLAY"
|
|
#define TCP_N_DBRESEND (1 + 5)
|
|
#define TCP_N_DBRESEND_NONE 1
|
|
#define TCP_N_DBRESEND_WCPU (1 + 4)
|
|
#define TCPFMT_DBRESEND TCPID_DBRESEND ",%d,%d,%lu,%lu,%u"
|
|
#define TCPFMT_DBRESEND_ABORT TCPID_DBRESEND ",-1,-1"
|
|
#define TCPFMT_DBRESEND_WCPU TCPID_DBRESEND ",%u,%u,%lu,%d"
|
|
|
|
// Debug traces
|
|
#define TCPID_TRACE "$TRACE"
|
|
#define TCP_N_TRACE 3
|
|
#define TCPFMT_TRACE TCPID_TRACE ",%d,\"%s\""
|
|
|
|
// Synchronise TCP-server
|
|
// Parameters: none
|
|
#define TCPID_DBSYNC "$SYNCDB"
|
|
#define TCP_N_DBSYNC 1
|
|
#define TCPFMT_DBSYNC TCPID_DBSYNC
|
|
#define TCPFMT_DBSYNC_ITEMS TCPID_DBSYNC ",\"%s\""
|
|
|
|
// Request phone number; the ZKL will send an SMS
|
|
// Parameters: phone number of the SMS server
|
|
#define TCPID_DBSENDPHONENR "$SENDPHONENR"
|
|
#define TCP_N_DBSENDPHONENR 2
|
|
#define TCPFMT_DBSENDPHONENR TCPID_DBSENDPHONENR ",\"%s\""
|
|
|
|
// Phone number (sent as SMS to the SMS server)
|
|
// Parameters: IMEI,IMSI,EF-CCID (SIM number)
|
|
#define TCPID_DBPHONENR "$PHONENR"
|
|
#define TCP_N_DBPHONENR 4
|
|
#define TCPFMT_DBPHONENR TCPID_DBPHONENR ",\"%s\",\"%s\",\"%s\""
|
|
|
|
// Run an AT command on the Wavecom (during production only)
|
|
// Returns
|
|
// status with command replies
|
|
#define TCPID_RUNATCOMMAND "$AT"
|
|
#define TCP_N_RUNATCOMMAND 2
|
|
#define TCPFMT_RUNATCOMMAND TCPID_RUNATCOMMAND ",\"%s\""
|
|
|
|
/*
|
|
** Geo-fencing, from database server to ZKL
|
|
** Return status after each sequence
|
|
*/
|
|
|
|
// Commands for TCPID_GEOFENCE - defined in "zkl-common.h"
|
|
// GEOFENCECMD_START 0
|
|
// GEOFENCECMD_END 6
|
|
// GEOFENCECMD_DELETE 7
|
|
// GEOFENCECMD_OBJECT 1
|
|
// GEOFENCECMD_POINT 2
|
|
// GEOFENCECMD_ACTION 3
|
|
|
|
// Main command
|
|
// Parameters
|
|
// 1 Command (one of the GEOFENCECMD_xxx definitions)
|
|
// Returns:
|
|
// Only the GEOFENCECMD_END returns an overall status code
|
|
#define TCPID_GEOFENCE "$GEOFENCE"
|
|
|
|
// Start a geo-fence design
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID
|
|
// 3 Name
|
|
// 4 Number of objects (n)
|
|
// Return value postponed till GEOEND line
|
|
// Next (order undetermined):
|
|
// Send actions.
|
|
// Send exactly n objects.
|
|
// Last: send GEOFENCE_END
|
|
#define TCPFMT_GEOFENCE_START TCPID_GEOFENCE ",0,%u,\"%s\",%u"
|
|
|
|
// End a geo-fence design
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID
|
|
// Returns:
|
|
// TCPSTAT_OK
|
|
// TCPERR_NOMEM: not enough memory
|
|
// TCPERR_INVAL: bad formatting in one of commands in the sequence for this shape
|
|
// TCPERR_PARAM: not enough points sent for an object
|
|
#define TCPFMT_GEOFENCE_END TCPID_GEOFENCE ",6,%u"
|
|
|
|
// Delete a geo-fence design
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID or '-1' to delete all current designs
|
|
// Returns nothing
|
|
#define TCPFMT_GEOFENCE_CLEAR TCPID_GEOFENCE ",7,%u"
|
|
#define TCPFMT_GEOFENCE_CLEAR_ALL TCPID_GEOFENCE ",7,-1"
|
|
|
|
// Geo-fence object
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID
|
|
// 3 Object ID
|
|
// 4 Type:
|
|
// "point", m=1
|
|
// "line", m=2
|
|
// "track" aka multi-line, arbitrary m > 0
|
|
// "rect", rectangle, m=2
|
|
// "polygon", arbitrary m > 0
|
|
// 5 Number of points (m)
|
|
// 6 Radius for a point or (multi-)line (in meters)
|
|
// Return value postponed till GEOFENCE_END line
|
|
// Next:
|
|
// Points, either in-line (seperated by comma's) or as GEOPOINT objects
|
|
#define TCPFMT_GEOFENCE_OBJECT TCPID_GEOFENCE ",1,%u,%u,\"%s\",%u,%f"
|
|
|
|
// Geo-fence object: point(s) for object
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID
|
|
// 3 Object ID
|
|
// 4 Point (latitude,longitude)
|
|
// ... (m-1 points separated by commas)
|
|
// Return value postponed till GEOEND line
|
|
// NB: due to implementation limitations, the number of co-ordinate pairs
|
|
// on one line is limited to 16.
|
|
#define TCPFMT_GEOFENCE_POINT_INLINE ",\"%f,%f\""
|
|
#define TCPFMT_GEOFENCE_POINT_HDR TCPID_GEOFENCE ",2,%u,%u"
|
|
#define TCPFMT_GEOFENCE_POINT TCPID_GEOFENCE_POINT_HDR TCPFMT_GEOPOINT_INLINE /* x m */
|
|
|
|
// Geo-fence action when going from out to in or v.v.
|
|
// Actions are added to a list in the order received.
|
|
// Parameters:
|
|
// 1 Command
|
|
// 2 Geo-fence ID
|
|
// 3 Direction ("exit" or "enter")
|
|
// 4 Key
|
|
// 5 Value
|
|
// Return value postponed till GEOFENCE_END line
|
|
#define TCPFMT_GEOFENCE_ACTION TCPID_GEOFENCE ",3,%u,\"%s\",\"%s\",\"%s\""
|
|
#define TCPFMT_GEOFENCE_ACTION_DEFAULT TCPID_GEOFENCE ",3,%u,\"%s\",\"%s\""
|
|
|
|
/*
|
|
** Messages from database or web server or ZKL to the SMS server;
|
|
** none of these return a status
|
|
*/
|
|
|
|
// Send text message (generic)
|
|
// Parameters
|
|
// 1 da (i.e. phone number to which the message must be sent)
|
|
// 2 text
|
|
// Returns
|
|
// status with message idenitifier
|
|
#define TCPID_SENDSMS "$SENDSMS"
|
|
#define TCP_N_SENDSMS (1 + 2)
|
|
#define TCPFMT_SENDSMS TCPID_SENDSMS ",\"%s\",\"%s\""
|
|
|
|
// Compose text message
|
|
// Parameters
|
|
// 1 message ID (MSG_xxx identifier in "zkl_common.h")
|
|
// 2 MCU state (32-bit integer, state in LSW, local_state in MSW)
|
|
// or error code (16-bit signed integer); type is determined by
|
|
// the message ID
|
|
// 3 full state (as sent by the $STAT command)
|
|
// Returns
|
|
// status with message idenitifier
|
|
#define TCPID_COMPOSE "$COMPOSE"
|
|
#define TCP_N_COMPOSE (1 + 3)
|
|
#define TCPFMT_COMPOSE TCPID_COMPOSE ",%u,\"%08lX\",\"%s\""
|
|
|
|
/*
|
|
** Server stats
|
|
*/
|
|
|
|
// Base command
|
|
#define TCPID_SVRSTAT "$SVRSTAT"
|
|
|
|
// TCP statistics
|
|
#define TCPID_SVRSTAT_TCP "$SVRSTAT[TCP]"
|
|
// Logging statistics
|
|
#define TCPID_SVRSTAT_LOG "$SVRSTAT[LOG]"
|
|
|
|
/*
|
|
** Logging from the Secure Server and CA Server
|
|
*/
|
|
|
|
// Commands for TCPID_LOGSECURE
|
|
#define LOGSECURE_START 0
|
|
#define LOGSECURE_END 1
|
|
#define LOGSECURE_INTERMEDIATE 2
|
|
#define LOGSECURE_DEVICE 3
|
|
#define LOGSECURE_USER 4
|
|
// Commands for TCPID_LOGCA
|
|
#define LOGSECURE_CAVERIFY 10
|
|
#define LOGSECURE_CASIGN 11
|
|
|
|
// Generic secure logging command
|
|
#define TCPID_LOGSECURE "$LOGSECURE"
|
|
// Format of the session identifier in replies
|
|
#define TCPFMT_LOGSECURE_SESSION "%lu"
|
|
|
|
// Start a log session
|
|
// Parameters
|
|
// 1 command
|
|
// 2 database-ID for the project (work instruction)
|
|
// 3 time stamp
|
|
// 4 peer name
|
|
// 5 database-ID of the user
|
|
// 6 reason for connect
|
|
// Returns:
|
|
// status with database identifier for this session
|
|
#define TCPFMT_LOGSECURE_START TCPID_LOGSECURE ",0,%u,%lu,\"%s\",%u,\"%s\""
|
|
|
|
// End a log session
|
|
// Parameters
|
|
// 1 command
|
|
// 2 session identifier
|
|
// 3 time stamp
|
|
// 4 overall status
|
|
// 5 textual description
|
|
// Returns:
|
|
// status with database identifier for this session (same a parameter 2)
|
|
#define TCPFMT_LOGSECURE_END TCPID_LOGSECURE ",1,%lu,%lu,%u,\"%s\""
|
|
|
|
// Add a generic intermediate log entry (as a tree under a TCPID_LOGSECURE)
|
|
// Parameters:
|
|
// 1 command
|
|
// 2 session identifier
|
|
// 3 time stamp
|
|
// 4 (not used)
|
|
// 5 status or error code returned by the device
|
|
// 6 textual description
|
|
// Returns
|
|
// status with database identifier for this session (same a parameter 2)
|
|
#define TCPFMT_LOGSECURE_INTERM TCPID_LOGSECURE ",2,%lu,%lu,,%d,\"%s\""
|
|
|
|
// Add log entry for a device (as a tree under a TCPID_LOGSECURE)
|
|
// Parameters:
|
|
// 1 command
|
|
// 2 session identifier
|
|
// 3 time stamp
|
|
// 4 database-ID for the device
|
|
// 5 status or error code returned by the device
|
|
// 6 textual description
|
|
// Returns
|
|
// status with database identifier for this session (same a parameter 2)
|
|
#define TCPFMT_LOGSECURE_DEVICE TCPID_LOGSECURE ",3,%lu,%lu,%u,%d,\"%s\""
|
|
|
|
// Add log entry for a user (as a tree under a TCPID_LOGSECURE)
|
|
// Parameters:
|
|
// 1 command
|
|
// 2 session identifier
|
|
// 3 time stamp
|
|
// 4 database-ID for the user
|
|
// 5 status or error code
|
|
// 6 textual description
|
|
// Returns
|
|
// status with database identifier for this session (same a parameter 2)
|
|
#define TCPFMT_LOGSECURE_USER TCPID_LOGSECURE ",4,%lu,%lu,%u,%d,\"%s\""
|
|
|
|
// Add log entry on behalf of the CA Server
|
|
// Parameters:
|
|
// 1 command
|
|
// 2 time stamp
|
|
// 3 peer (common) name
|
|
// 4 status or error code
|
|
// 5 target (common) name
|
|
// 6 serial number of the certificate
|
|
#define TCPFMT_LOGCA_VERIFY TCPID_LOGSECURE ",10,%lu,\"%s\",%d,\"%s\",%u"
|
|
#define TCPFMT_LOGCA_SIGN TCPID_LOGSECURE ",11,%lu,\"%s\",%d,\"%s\",%u"
|
|
|
|
/*
|
|
** Commands for MTinfo Secure
|
|
** See "Server voor MTinfo Secure - SwDS", v2.00, sections 5.7.3.2--5.7.3.8
|
|
*/
|
|
|
|
// Start a work instruction
|
|
// Parameters:
|
|
// 1 project identifier
|
|
// 2 project name
|
|
// 3 reason
|
|
// 4 desired state
|
|
// 5 device count
|
|
// 6 user count
|
|
// 7 user identifier (actor)
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WISTART "$WISTART"
|
|
#define TCP_N_WISTART (1 + 7)
|
|
#define TCPFMT_WISTART TCPID_WISTART ",%u,\"%s\",\"%s\",\"%s\",%u,%u,%u"
|
|
|
|
// Terminate a work instruction
|
|
// Parameters:
|
|
// 1 digital signature (hex encoded)
|
|
// Returns:
|
|
// status of the action indicated by TCPID_WISTART
|
|
#define TCPID_WIEND "$WIEND"
|
|
#define TCP_N_WIEND (1 + 1)
|
|
#define TCPFMT_WIEND TCPID_WIEND ",\"%s\""
|
|
// Replies (intermediate and final, with number of devices that succeeded,
|
|
// returned an error and those that timed out)
|
|
#define TCPFMT_WIEND_INTERMEDIATE TCPFMT_STATUS_FMT ",%u"
|
|
#define TCPFMT_WIEND_REPLY TCPFMT_STATUS ",\"%u,%u,%u"
|
|
|
|
// Add a device to the device list of a work instruction
|
|
// Parameters:
|
|
// 1 device identifier
|
|
// 2 flags
|
|
// 3 imei
|
|
// 4 serial number
|
|
// 5 id-code
|
|
// 6 verification code for an RS 3000
|
|
// 7 TCP-server that instantiates this device
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WIDEVICE "$WIDEVICE"
|
|
#define TCP_N_WIDEVICE (1 + 7)
|
|
#define TCPFMT_WIDEVICE TCPID_WIDEVICE ",%u,\"0x%04X\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\""
|
|
|
|
// Add a user to the list of allowed users for a work instruction
|
|
// Parameters:
|
|
// 1 user identifier
|
|
// 2 user name
|
|
// 3 i18n
|
|
// 4 tz
|
|
// 5 method of verification
|
|
// 6 encoded verification code _or_ phone number of SMS verification
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WIUSER "$WIUSER"
|
|
#define TCP_N_WIUSER (1 + 6)
|
|
#define TCPFMT_WIUSER TCPID_WIUSER ",%u,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\""
|
|
|
|
// Specify the user that makes a request to turn the switch on or off
|
|
// Parameters:
|
|
// 1 user identifier
|
|
// 2 method of verification
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WIREQ "$WIREQ"
|
|
#define TCP_N_WIREQ (1 + 2)
|
|
#define TCPFMT_WIREQ TCPID_WIREQ ",%u,\"%s\""
|
|
|
|
// Verify the user that makes a request to turn the switch on or off
|
|
// Parameters:
|
|
// 1 user identifier
|
|
// 2 method of verification
|
|
// 3 encoded verification code
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WIVERIFY "$WIVERIFY"
|
|
#define TCP_N_WIVERIFY (1 + 3)
|
|
#define TCPFMT_WIVERIFY TCPID_WIVERIFY ",%u,\"%s\",\"%s\""
|
|
|
|
// Add an e-mail or phone number to the list of people/entities that
|
|
// must receive an alarm messages when the verification protocol is
|
|
// violated.
|
|
// Parameters:
|
|
// 1 Method (the string "sms" or "e-mail")
|
|
// 2 E-mail address or phone number
|
|
// Returns:
|
|
// nothing (status is delayed until TCPID_WIEND)
|
|
#define TCPID_WIALARM "$WIALARM"
|
|
#define TCP_N_WIALARM (1 + 2)
|
|
#define TCPFMT_WIALARM TCPID_WIALARM ",\"%s\",\"%s\""
|
|
|
|
// Override default time-out
|
|
// Parameters:
|
|
// 1 Time-out in seconds
|
|
#define TCPID_WITO "$WITO"
|
|
#define TCP_N_WITO (1 + 1)
|
|
#define TCPFMT_WITO TCPID_WITO ",%u"
|
|
|
|
/*
|
|
** Commands for the CA Server
|
|
** See "CA Server - SwRS-SwAS-SwDS", v1.00, sections 5.6.2.2 and 5.7.2.2
|
|
*/
|
|
|
|
// Request to verify a certificate
|
|
// Parameters:
|
|
// 1 certificate to verify (PEM format, escaped)
|
|
// Returns:
|
|
// status and common name of the owner of the certificate:
|
|
// TCPSTAT_OK if the certificate verifies okay
|
|
// TCPERR_INVAL if not
|
|
// TCPERR_STALE if the validity of the certificate has expired
|
|
// TCPERR_UNKNOWN if the common name is unknown to MTinfo (Secure)
|
|
#define TCPID_CAVRFY "$CAVRFY"
|
|
#define TCP_N_CAVRFY (1 + 1)
|
|
#define TCPFMT_CAVRFY TCPID_CAVRFY ",\"%s\""
|
|
|
|
// Request to sign a certificate
|
|
// Parameters:
|
|
// 1 certificate request (PEM format, escaped)
|
|
// Returns:
|
|
// status and signed certificate (PEM format, escaped)
|
|
// TCPSTAT_OK if the certificate is signed
|
|
// TCPERR_ACCESS if not
|
|
#define TCPID_CASIGN "$CASIGN"
|
|
#define TCP_N_CASIGN (1 + 1)
|
|
#define TCPFMT_CASIGN TCPID_CASIGN ",\"%s\""
|
|
|
|
#endif /* _CP3000_CMD_H_COMMON */
|