# BAP Opcodes and Function IDs Reference This document provides a comprehensive reference for BAP protocol opcodes and standardized function IDs used across LSGs (Logical Service Groups). ## Opcodes Overview BAP uses opcodes to define the type of operation being performed in a message. Each opcode belongs to one of four function classes: - **Property**: Single value operations (get/set individual parameters) - **Array**: Multi-element operations (handle lists, tables, or indexed data) - **Method**: Action-based operations (start/stop processes, execute commands) - **Cache**: Bulk data operations (synchronize entire data sets) ## Opcode Reference Table | Opcode | Property | Array | Method | Cache | Direction | Description | |--------|----------|-------|---------|--------|-----------|-------------| | **0x0** | Set | SetArray | Start | – | ASG → FSG | Write data or initiate action | | | Reset | | | | FSG → ASG | Reset to default state | | **0x1** | Get | GetArray | Abort | GetAll | ASG → FSG | Read data or cancel operation | | **0x2** | SetGet | SetGetArray | StartResult | – | ASG → FSG | Write then read back | | **0x3** | HeartbeatStatus | ChangeArray | Processing | – | FSG → ASG | Keep-alive or notify changes | | **0x4** | Status | StatusArray | Result | StatusAll | FSG → ASG | Report current state | | **0x5** | StatusAck | – | – | – | FSG → ASG | Acknowledge status receipt | | **0x6** | Ack | – | – | – | ASG → FSG | General acknowledgement | | **0x7** | Error | Error | Error | Error | Both | Error notification | ### Opcode Usage Details #### Property Operations - **Set (0x0)**: ASG requests FSG to change a single parameter value - **Get (0x1)**: ASG requests current value from FSG - **SetGet (0x2)**: ASG sets a value and immediately requests confirmation - **Status (0x4)**: FSG reports current value (response to Get or spontaneous update) #### Array Operations Arrays handle indexed or multi-element data structures: - **SetArray/GetArray**: Access specific array elements by index - **SetGetArray**: Modify array element and receive updated value - **StatusArray**: Report array element values - **ChangeArray**: Notify that array contents have changed ##### Array Transaction Rules - FSG must echo ASG_ID and TAID from GetArray in StatusArray response - For SetGetArray responses, set MSB of ASG_ID if content changed - When MSB is set, all ASGs must process the StatusArray message - Array index values > 0x7 are reserved and shall not be used #### Method Operations - **Start (0x0)**: Begin a process or action - **Abort (0x1)**: Cancel ongoing operation - **StartResult (0x2)**: Start and wait for immediate result - **Processing (0x3)**: Indicate operation in progress - **Result (0x4)**: Final outcome of method execution #### Cache Operations - **GetAll (0x1)**: Request complete data set from FSG - **StatusAll (0x4)**: FSG sends entire cached state ### HeartbeatStatus (0x3) - Sent periodically at configured intervals - Lower priority than other commands but guaranteed transmission - Properties appear in function ID order in traces - Critical for connection monitoring and timeout detection ### Transaction ID (TAID) *MQB Only* - Identifies request/response pairs (e.g., GetArray/StatusArray) - Unique within ASG_ID scope - TAID = 0 reserved for FSG-initiated StatusArray (no preceding request) - ASG must never generate TAID = 0 - PQ BAP: Simpler correlation using (LSG_ID + FCT_ID + OpCode) MQB BAP: Added TAID for more sophisticated request/response tracking ## Standardized Function IDs These function IDs are defined in the BAP standard and commonly implemented across different LSGs: | FCT ID | Name | Direction | Parameter | Data | Description | | -------- | ------------------ | --------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ | | **0x01** | GetAll | ASG ↔ FSG | | | Request all function data for initialization | | **0x02** | BAP_Config | ASG ↔ FSG | BAP_Version_major , BAP_Version_minor , LSG-Class, LSG-Sub-Class, LSG-Version_major, LSG-Version_minor | op_codes: Get (empty), Status (data), Reset (data), HeartbeatStatus (data), <br>Error (errorCode) | Exchange BAP protocol version and capabilities | | **0x03** | FunctionList | ASG → FSG | FctList = bitmask of supported FCTs | op_codes: Get (noParam), Status (FctList), HeartbeatStatus (FctList), Error (errorCode) | Query list of supported functions for this LSG | | **0x04** | HeartBeat | ASG ↔ FSG | HeartBeatTime (byte, scale=100, unit=ms, 0..25500ms) | ‘HeartBeatTime’ * 100ms = time in unit ‘milliseconds, ms’. If a heart beat error occurs for a BAP-connection, it is reported on function HeartBeat (0x04) <br> <br>op_codes: Get (noParam), Status (HeartBeatTime), HeartbeatStatus (HeartBeatTime), Error (errorCode) | Keep-alive signal to detect connection loss | | 0x0E | FSG-Setup | FSG → ASG | | | | | **0x0F** | FSG_OperationState | FSG → ASG | | | Report FSG operational status (normal, standby, error) | ### Function ID Ranges Beyond standardized IDs, each LSG defines custom function IDs: - **0x01-0x11**: Reserved for BAP standard functions ## Implementation Notes ### Message Priority 1. Error messages (opcode 0x7) - Highest priority 2. Method results (opcode 0x4 for methods) 3. Property/Array responses 4. HeartbeatStatus - Lowest priority but guaranteed ### Timing Considerations - Responses should be sent within 100ms of request - HeartbeatStatus interval typically 1-5 seconds - Method timeouts defined per-function (see LSG docs) ### Error Handling - Invalid opcode → Error response with appropriate error code - Unsupported function → Error with FCT_NOT_SUPPORTED - See [[BAP Error Codes]] for complete error reference ## Related Documentation - [[BAP Protocol Overview]] - Understanding the complete protocol - [[BAP Header and Multi-frame]] - Message structure and framing - [[System Initialization]] - Startup sequence using these opcodes - Individual LSG documentation for function-specific details