[package]
name = "mbus-server"
version = "0.13.0"
edition.workspace = true
authors.workspace = true
license-file = "LICENSE"
repository.workspace = true
homepage.workspace = true
readme = "README.md"
keywords.workspace = true
categories.workspace = true
description = "Modbus server runtime providing request dispatch and response handling"
build = "build.rs"

[dependencies]
mbus-core.workspace = true
mbus-macros.workspace = true

heapless = { workspace = true }
log = { workspace = true, optional = true }

[features]
# By default, all Modbus function code services are enabled for ease of use.
# Users can disable default features to reduce binary size if specific services are not required.
default = [
    "coils",
    "holding-registers",
    "input-registers",
    "discrete-inputs",
    "fifo",
    "file-record",
    "diagnostics",
]

coils = ["mbus-core/coils"] # Enables Modbus Coil (FC 0x01, 0x05, 0x0F) services
holding-registers = [
    "mbus-core/holding-registers",
] # Enables holding-register services (FC 0x03, 0x06, 0x10)
input-registers = [
    "mbus-core/input-registers",
] # Enables input-register service (FC 0x04)
registers = ["holding-registers", "input-registers"] # Backward-compat alias
discrete-inputs = [
    "mbus-core/discrete-inputs",
] # Enables Modbus Discrete Input (FC 0x02) services
fifo = ["mbus-core/fifo"] # Enables Modbus FIFO Queue (FC 0x18) services
file-record = [
    "mbus-core/file-record",
] # Enables Modbus File Record (FC 0x14, 0x15) services
diagnostics = [
    "mbus-core/diagnostics",
] # Enables Modbus Diagnostics (FC 0x08) and Encapsulated Interface Transport (FC 0x2B) services
diagnostics-stats = [
    "diagnostics",
] # Enables server statistics tracking for FC 0x08 diagnostics counters
serial-ascii = [
    "mbus-core/serial-ascii",
] # Enables ASCII-sized ADU buffers (513 bytes) in mbus-core
logging = ["dep:log", "mbus-core/logging", "mbus-core/defmt-format"]
traffic = []
display = []

[[example]]
name = "broadcast"
required-features = ["coils", "holding-registers"]

[[example]]
name = "device_id"
required-features = ["diagnostics"]

[[example]]
name = "diagnostics"
required-features = ["diagnostics"]

[[example]]
name = "discrete_inputs"
required-features = ["discrete-inputs"]

[[example]]
name = "discrete_inputs_read"
required-features = ["discrete-inputs"]

[[example]]
name = "fifo"
required-features = ["fifo"]

[[example]]
name = "file_record"
required-features = ["file-record"]

[[example]]
name = "full_server"
required-features = [
    "coils",
    "discrete-inputs",
    "holding-registers",
    "input-registers",
    "fifo",
    "file-record",
    "diagnostics",
]

[[example]]
name = "holding_registers_read"
required-features = ["holding-registers"]

[[example]]
name = "read_write_registers"
required-features = ["holding-registers"]

[[example]]
name = "write_hooks"
required-features = ["coils", "holding-registers"]


[build-dependencies]
serde = { version = "1", features = ["derive"] }
toml = "0.8"
