{
  "$schema": "https://springfield-ham-radio.com/schemas/radio-config-v1.json",
  "id": {
    "model": "baofeng-uv5r",
    "name": "Baofeng UV-5R",
    "manufacturer": "Baofeng"
  },
  "version": "1.0.0",
  "description": "UV-5R and UV-5RE Plus models",
  "capabilities": {
    "memoryRead": true,
    "memoryWrite": true,
    "channelProgramming": true,
    "settingsProgramming": true
  },
  "metadata": {
    "author": "Springfield Ham Radio",
    "license": "MIT",
    "homepage": "https://springfield-ham-radio.com",
    "repository": "https://gitlab.com/springfield-ham-radio/drivers/radio-module-baofeng"
  },
  "settingsSchema": {
    "model": "baofeng-uv5r",
    "settingsSchema": {
      "$ref": "../src/shared/schemas/settings-schema.json"
    },
    "channelSchema": {
      "$ref": "../src/shared/schemas/channel-schema.json"
    }
  },
  "codec": {
    "type": "shared",
    "reference": "../src/shared/codecs/baofeng-codec.ts",
    "config": {
      "channelMemorySegment": {
        "startAddress": 0,
        "endAddress": 6143
      },
      "settingsMemorySegment": {
        "startAddress": 7872,
        "endAddress": 8191
      },
      "memorySegmentSize": 64,
      "magicNumber": [
        80,
        187,
        255,
        32,
        18,
        7,
        37
      ],
      "receiveFrequencyOffset": 0,
      "transmitFrequencyOffset": 4,
      "receiveToneOffset": 8,
      "transmitToneOffset": 10,
      "powerOffset": 12,
      "channelSize": 16,
      "numberChannels": 128,
      "radioSettingsSchemaPath": "../src/shared/schemas/settings-schema.json",
      "channelSettingsSchemaPath": "../src/shared/schemas/channel-schema.json"
    }
  },
  "serialConfig": {
    "baudRate": 9600,
    "dataBits": 8,
    "stopBits": 1,
    "parity": "none"
  },
  "memoryConfig": {
    "chunkSize": 64,
    "segments": {
      "channels": {
        "startAddress": 0,
        "endAddress": 6143
      },
      "settings": {
        "startAddress": 7872,
        "endAddress": 8191
      }
    }
  },
  "readMemory": [
    {
      "sendReceive": {
        "description": "Send magic number",
        "send": [80, 187, 255, 32, 18, 7, 37],
        "receive": {
          "type": "exact",
          "value": 6,
          "length": 1
        }
      }
    },
    {
      "sendReceive": {
        "description": "Get radio identifier",
        "send": [2],
        "receive": {
          "type": "variable",
          "length": 8
        }
      }
    },
    {
      "sendReceive": {
        "description": "Begin clone operation",
        "send": [6],
        "receive": {
          "type": "exact",
          "value": 6,
          "length": 1
        }
      }
    },
    {
      "readSegment": {
        "description": "Read channels segment",
        "segments": ["channels"],
        "startChunk": {
          "send": ["S", "address:2", "segment.chunkSize"],
          "receive": {
            "type": "pattern",
            "pattern": [
              "X",
              {
                "field": "address",
                "size": 2
              },
              {
                "field": "length",
                "size": 1
              },
              {
                "field": "data",
                "size": 0
              }
            ]
          }
        },
        "endChunk": {
          "send": [6],
          "receive": {
            "type": "exact",
            "value": 6,
            "length": 1
          }
        }
      }
    },
    {
      "readSegment": {
        "description": "Read settings segment",
        "segments": ["settings"],
        "startChunk": {
          "send": ["S", "address:2", "segment.chunkSize"],
          "receive": {
            "type": "pattern",
            "pattern": [
              "X",
              {
                "field": "address",
                "size": 2
              },
              {
                "field": "length",
                "size": 1
              },
              {
                "field": "data",
                "size": 0
              }
            ]
          }
        },
        "endChunk": {
          "send": [6],
          "receive": {
            "type": "exact",
            "value": 6,
            "length": 1
          }
        }
      }
    }
  ],
  "writeMemory": [
    {
      "sendReceive": {
        "description": "Send magic number",
        "send": [80, 187, 255, 32, 18, 7, 37],
        "receive": {
          "type": "exact",
          "value": 6,
          "length": 1
        }
      }
    },
    {
      "writeSegment": {
        "description": "Write all memory segments (single chunk per segment)",
        "segments": ["channels", "settings"],
        "send": ["X", "segment.startAddress:2", "segment.chunkSize"],
        "data": "segment.data",
        "receive": {
          "type": "exact",
          "value": 6,
          "length": 1
        }
      }
    }
  ]
}
