TWESTG_CMD_u32CmdOp() Command Explanation
TWESTG_CMD_u32CmdOp()
.TWESTG_CMD_u32CmdOp() Command Explanation (for Internal Developers)
TWESTG_CMD_u32CmdOp()
function provides common procedures with applications (firmware) implemented using the TWENETstgs library. However, this information relates to the internal implementation of the library and is not intended for use by general users.Overview
The TWESTG_CMD_u32CmdOp()
function in twesettings_cmd.[ch]
is intended to execute 0xdb
commands. This function includes processes such as obtaining module various information, obtaining configuration information, reflecting configuration information, and resetting. Many processes call the configuration-related helper function TWEINTRCT_cbu32GenericHandler()
.
Data Types
TWE_APIRET
: Success if the0x80000000
bit is set, failure if not. The remaining 31 bits are used for parameters.TWE_tsBuffer
: A structure containing a pointer to the buffer, the sequence length, and the maximum buffer length.TWESTG_tsFinal
: The management structure for configuration-related settings.
TWESTG_CMD_u32CmdOp()
TWE_APIRET TWESTG_CMD_u32CmdOp(uint8 u8Op, TWE_tsBuffer *pBufIn, TWE_tsBuffer *pBufOut, TWESTG_tsFinal *psFinal)
Performs processing corresponding to u8Op
. Input data pBufIn
and output data pBufOut
are used depending on the process. The last parameter specifies the configuration management structure psFinal
.
Parameter | Type | Description |
---|---|---|
u8Op | uint8 | Specifies the processing content. |
pBufIn | TWE_tsBuffer * | Input sequence. |
pBufOut | TWE_tsBuffer * | Specifies the storage area for output data. NULL can be specified for some processes. The state on processing failure is undefined in principle. |
psFinal | TWESTG_tsFinal * | Specifies the configuration information management structure. |
The u8Op
overview is as follows:
E_TWESTG_CMD_OP_ACK = 0xF0 ACK processing
E_TWESTG_CMD_OP_QUERY_MODULE_INFO = 0xF1 Acquisition of SID, etc.
E_TWESTG_CMD_OP_APPLY_SETTINGS = 0xF2 Apply settings (do not save)
E_TWESTG_CMD_OP_QUERY_SETTINGS = 0xF3 Read settings
E_TWESTG_CMD_OP_MODULE_CONTROL = 0xF8 Various processes related to settings
E_TWESTG_CMD_OP_REVERT = 0xFD Revert settings
E_TWESTG_CMD_OP_SAVE = 0xFE Save settings
E_TWESTG_CMD_OP_DO_MDDULE_RESET = 0xFF, Module reset
The return value indicates success or failure. Parameters may be set depending on the process.
Return Value | Value | Status |
---|---|---|
TWE_APIRET_SUCCESS | b0..b7 → u8Op, others depend on processing | On success |
TWE_APIRET_FAIL | b0..b7 → u8Op, others depend on processing | On failure |
Processing
E_TWESTG_CMD_OP_ACK (F0)
Performs an ACK response. The input sequence is output as-is.
Example
(None) -> 01 : If no input, 01 is returned.
112233 -> 112233 : If 112233, it is returned as-is in the output.
E_TWESTG_CMD_OP_QUERY_MODULE_INFO (F1)
Retrieves various module information.
Input Column | Data Type | Value | Content |
---|---|---|---|
[0] | OCTET | 0x01 | Get module’s SID. |
Other | Undefined | ||
Subsequent data is undefined |
Output Column ([0] == 0x01) | Data Type | Value | Content |
---|---|---|---|
[0..3] | BE_DWORD | Module’s SID. |
E_TWESTG_CMD_OP_APPLY_SETTINGS(F2)
Modifies configuration information.
- Configuration information will not be applied until it is saved and the module is reset.
- The behavior of the application in an unapplied state is undefined.
- If you transition to interactive mode in an undefined state, the changed data will be discarded.
- Even when attempting to change to the same content as existing data, this process returns a successful return value. However, if a save (
E_TWESTG_CMD_OP_SAVE
) is executed, no actual save will occur. - This process does not write to the output (
pBufOut
).
Input Column | Data Type | Value | Content |
---|---|---|---|
[0] | OCTET | 0x01 | Change the setting specified by ID. |
[1] | OCTET | Not 0x00 | Setting ID |
[2..] | Data type dependent |
Configuration Data
Setting ID | Content | Input Data | Remarks |
---|---|---|---|
0x01 | Application ID | BE_DWORD (uint32_t) | |
0x02 | Logical ID (8bit) | OCTET (uint8_t) | |
0x03 | Channel | OCTET (uint8_t) | |
0x04 | Multiple Channels | BE_WORD(uint16_t) | b0: ch11, b1: ch12, …, b15: ch16 |
BE_DWORD(uint32_t) | Bitwise OR of 1UL << ch (e.g., for 11, 13 it’s `1UL « 11 | ||
0x05 | Radio Output and Retransmission | OCTET (uint8_t) | Upper 4 bits: retransmission count, Lower 4 bits: output setting (0..3, 3 is highest output) |
0x06, 0x08, 0x09, 0x0A | Option (32bit) | BE_DWORD (uint32_t) | |
0x07 | UART Settings | BE_WORD (int16_t) | Input configuration data in internal format as-is. |
BE_DWORD | Specifies baud rate (9600 … 250000). Other communication conditions are 8N1. | ||
BE_DWORD OCTET OCTET OCTET | Specifies all parameters: - Baud rate (DWORD) - Data bits (7 or 8) - Parity (‘N’ or ‘E’ or ‘O’) - Stop bits (1 or 2) |
Example
01011234BEEF Sets Application ID (0x01) to 0x1234BEEF.
010212 Sets Channel (0x02) to 0x12 (18).
E_TWESTG_CMD_OP_QUERY_SETTINGS(F3)
Retrieves configuration information.
Input Column | Data Type | Value | Content |
---|---|---|---|
[0] | OCTET | 0x01 | (QTYP) Get the setting specified by ID. |
[1] | OCTET | Not 0x00 | Setting ID |
Output for QTYP==1
Remarks | ||
---|---|---|
[0] | OCTET | Data type (uint8_t: 1, int8_t: 2, uint16_t: 3, int16_t: 4, uint32_t: 5, int32_t: 6, uint8_t[]: 0x80 (lower 5 bits are data length)) |
[...] | Data type dependent (Integer types WORD, DWORD are Big Endian order) |
Setting ID | Content | Input Data | Remarks |
---|---|---|---|
0x01 | Application ID | BE_DWORD (uint32_t) | |
0x02 | Logical ID (8bit) | OCTET (uint8_t) | |
0x03 | Channel | OCTET (uint8_t) | |
0x04 | Multiple Channels | BE_WORD(uint16_t) | b0: ch11, b1: ch12, …, b15: ch16 |
0x05 | Radio Output and Retransmission | OCTET (uint8_t) | Upper 4 bits: retransmission count, Lower 4 bits: output setting (0..3, 3 is highest output) |
0x06, 0x08, 0x09, 0x0A | Option (32bit) | BE_DWORD (uint32_t) | |
0x07 | UART Settings | BE_WORD (int16_t) | Internal format configuration data. b15: 1 for 7bit, 0 for 8bit. b14: 1 for STOPBIT=2, 0 for 1. b12,13: 0->NONE, 1->ODD, 2->EVEN. b0..b11->Baud rate / 100. |
Example
0101 -> 051234BEEF -> Application ID (uint32_t 0x1234beef)
0102 -> 010D -> Channel (uint8_t 13)
E_TWESTG_CMD_OP_REVERT (0xFD)
By executing E_TWESTG_CMD_OP_SAVE
immediately after this command, the configuration information is reverted to its initial values.
- Calls
TWEINTRCT_cbu32GenericHandler(psIntr, E_TWEINRCT_OP_REVERT, TRUE, 0, NULL)
. TheTRUE
specified in the third argument means that the saved configuration information is not loaded. Ensure that the application’sTWEINTRCT_cbu32GenericHandler()
is correctly implemented.
No input data, no output data.
E_TWESTG_CMD_OP_SAVE (0xFE)
When configuration information is changed, it is saved to non-volatile memory.
- If attempting to overwrite or change to the same values that are already set, no save is performed. The function returns
TWE_APIRET_SUCCESS_W_VALUE(0x100 | E_TWESTG_CMD_OP_SAVE)
. - If a save is performed, a reset should be carried out promptly (operation with changed settings without reset is undefined).
No input data, no output data.
E_TWESTG_CMD_OP_DO_MDDULE_RESET (0xFF)
Resets the module.
No input data, no output data.