This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-09-10

TWESTG_CMD_u32CmdOp() Command Explanation

TWESTG_CMD_u32CmdOp() Command Explanation (for internal developers)
    This section explains the commands for TWESTG_CMD_u32CmdOp().

    TWESTG_CMD_u32CmdOp() Command Explanation (for Internal Developers)

    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 the 0x80000000 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.

    ParameterTypeDescription
    u8Opuint8Specifies the processing content.
    pBufInTWE_tsBuffer *Input sequence.
    pBufOutTWE_tsBuffer *Specifies the storage area for output data. NULL can be specified for some processes. The state on processing failure is undefined in principle.
    psFinalTWESTG_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 ValueValueStatus
    TWE_APIRET_SUCCESSb0..b7 → u8Op, others depend on processingOn success
    TWE_APIRET_FAILb0..b7 → u8Op, others depend on processingOn 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 ColumnData TypeValueContent
    [0]OCTET0x01Get module’s SID.
    OtherUndefined
    Subsequent data is undefined
    Output Column ([0] == 0x01)Data TypeValueContent
    [0..3]BE_DWORDModule’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 ColumnData TypeValueContent
    [0]OCTET0x01Change the setting specified by ID.
    [1]OCTETNot 0x00Setting ID
    [2..]Data type dependent
    Configuration Data
    Setting IDContentInput DataRemarks
    0x01Application IDBE_DWORD (uint32_t)
    0x02Logical ID (8bit)OCTET (uint8_t)
    0x03ChannelOCTET (uint8_t)
    0x04Multiple ChannelsBE_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
    0x05Radio Output and RetransmissionOCTET (uint8_t)Upper 4 bits: retransmission count, Lower 4 bits: output setting (0..3, 3 is highest output)
    0x06, 0x08, 0x09, 0x0AOption (32bit)BE_DWORD (uint32_t)
    0x07UART SettingsBE_WORD (int16_t)Input configuration data in internal format as-is.
    BE_DWORDSpecifies baud rate (9600 … 250000). Other communication conditions are 8N1.
    BE_DWORD OCTET OCTET OCTETSpecifies 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 ColumnData TypeValueContent
    [0]OCTET0x01(QTYP) Get the setting specified by ID.
    [1]OCTETNot 0x00Setting ID
    Output for QTYP==1
    Remarks
    [0]OCTETData 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 IDContentInput DataRemarks
    0x01Application IDBE_DWORD (uint32_t)
    0x02Logical ID (8bit)OCTET (uint8_t)
    0x03ChannelOCTET (uint8_t)
    0x04Multiple ChannelsBE_WORD(uint16_t)b0: ch11, b1: ch12, …, b15: ch16
    0x05Radio Output and RetransmissionOCTET (uint8_t)Upper 4 bits: retransmission count, Lower 4 bits: output setting (0..3, 3 is highest output)
    0x06, 0x08, 0x09, 0x0AOption (32bit)BE_DWORD (uint32_t)
    0x07UART SettingsBE_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). The TRUE specified in the third argument means that the saved configuration information is not loaded. Ensure that the application’s TWEINTRCT_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.