{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "redsea",
    "description": "Array of RDS groups from redsea",
    "definitions": {
        "pi": {
            "type": "string",
            "pattern": "^0x[0-9A-F]{4}$"
        },
        "grouptype": {
            "type": "string",
            "pattern": "^([0-9]|1[0-5])[AB]$"
        },
        "di": {
            "type": "object",
            "properties": {
                "compressed": {
                    "type": "boolean"
                },
                "artificial_head": {
                    "type": "boolean"
                },
                "stereo": {
                    "type": "boolean"
                },
                "dynamic_pty": {
                    "type": "boolean"
                }
            },
            "additionalProperties": false
        },
        "radiotext": {
            "type": "string",
            "maxLength": 64
        },
        "ps": {
            "type": "string",
            "minLength": 8,
            "maxLength": 8
        },
        "rtplus": {
            "type": "object",
            "properties": {
                "tags": {
                    "type": "array",
                    "items": {
                        "content-type": {
                            "type": "string",
                            "enum": [
                                "dummy_class",
                                "item.title",
                                "item.album",
                                "item.tracknumber",
                                "item.artist",
                                "item.composition",
                                "item.movement",
                                "item.conductor",
                                "item.composer",
                                "item.band",
                                "item.comment",
                                "item.genre",
                                "info.news",
                                "info.news.local",
                                "info.stockmarket",
                                "info.sport",
                                "info.lottery",
                                "info.horoscope",
                                "info.daily_diversion",
                                "info.health",
                                "info.event",
                                "info.scene",
                                "info.cinema",
                                "info.tv",
                                "info.date_time",
                                "info.weather",
                                "info.traffic",
                                "info.alarm",
                                "info.advertisement",
                                "info.url",
                                "info.other",
                                "stationname.short",
                                "stationname.long",
                                "programme.now",
                                "programme.next",
                                "programme.part",
                                "programme.host",
                                "programme.editorial_staff",
                                "programme.frequency",
                                "programme.homepage",
                                "programme.subchannel",
                                "phone.hotline",
                                "phone.studio",
                                "phone.other",
                                "sms.studio",
                                "sms.other",
                                "email.hotline",
                                "email.studio",
                                "email.other",
                                "mms.other",
                                "chat",
                                "chat.centre",
                                "vote.question",
                                "vote.centre",
                                "unknown",
                                "place",
                                "appointment",
                                "identifier",
                                "purchase",
                                "get_data"
                            ]
                        }
                    }
                },
                "data": {
                    "type": "string"
                },
                "item_running": {
                    "type": "boolean"
                },
                "item_toggle": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1
                }
            },
            "additionalProperties": false
        },
        "pin": {
            "type": "object",
            "properties": {
                "day": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 31
                },
                "time": {
                    "type": "string",
                    "pattern": "^[0-2][0-9]:[0-5][0-9]$"
                }
            },
            "additionalProperties": false
        },
        "tmc": {
            "type": "object",
            "oneOf": [
                {
                    "system_info": {
                        "type": "object",
                        "properties": {
                            "is_encrypted": {
                                "type": "boolean"
                            },
                            "is_on_alt_freq": {
                                "description": "Whether alternative frequencies carry TMC",
                                "type": "boolean"
                            },
                            "location_table": {
                                "description": "Location table number (LTN)",
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 63
                            },
                            "encryption_id": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 31
                            },
                            "scope": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                    "enum": [
                                        "inter-road",
                                        "national",
                                        "regional",
                                        "urban"
                                    ]
                                }
                            },
                            "gap": {
                                "description": "Number of groups between successive 8A groups",
                                "type": "integer",
                                "enum": [
                                    3,
                                    5,
                                    8,
                                    11
                                ]
                            },
                            "service_id": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 63
                            },
                            "delay_time": {
                                "description": "Position of the start of the activity/window sequence, referenced from the minute's edge, in seconds",
                                "type": "integer",
                                "enum": [
                                    0,
                                    1,
                                    2,
                                    3
                                ]
                            },
                            "activity_time": {
                                "description": "The time in a time slot during which 8A groups may be transmitted (seconds)",
                                "type": "integer",
                                "enum": [
                                    1,
                                    2,
                                    4,
                                    8
                                ]
                            },
                            "window_time": {
                                "description": "The time in a time slot during which transmission of 8A groups is suspended (seconds)",
                                "type": "integer",
                                "enum": [
                                    1,
                                    2,
                                    4,
                                    8
                                ]
                            }
                        },
                        "additionalProperties": false
                    },
                    "message": {
                        "type": "object",
                        "properties": {
                            "description": {
                                "description": "Human-readable message",
                                "type": "string"
                            },
                            "direction": {
                                "description": "Whether this event affects only one direction",
                                "type": "string",
                                "enum": [
                                    "single",
                                    "both"
                                ]
                            },
                            "extent": {
                                "description": "The event affects this many points from location",
                                "type": "string",
                                "pattern": "^(\\+|-)[0-9]+$"
                            },
                            "location": {
                                "description": "Location code (reference to a location database)",
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 65535
                            },
                            "encrypted_location": {
                                "description": "Location code in its encrypted form",
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 65535
                            },
                            "event_codes": {
                                "description": "Event codes (references to event code list)",
                                "type": "array",
                                "items": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 2047
                                }
                            },
                            "road_number": {
                                "type": "integer"
                            },
                            "span_from": {
                                "type": "string"
                            },
                            "span_to": {
                                "type": "string"
                            },
                            "coordinates": {
                                "description": "Affected point or route",
                                "type": "object",
                                "properties": {
                                    "lat": {
                                        "description": "Degrees North",
                                        "type": "number",
                                        "minimum": -90,
                                        "maximum": 90
                                    },
                                    "lon": {
                                        "description": "Degrees East",
                                        "type": "number",
                                        "minimum": -180,
                                        "maximum": 180
                                    }
                                }
                            },
                            "urgency": {
                                "description": "Message urgency: normal/urgent/extremely urgent",
                                "type": "string",
                                "enum": [
                                    "none",
                                    "U",
                                    "X"
                                ]
                            },
                            "update_class": {
                                "description": "Message replaces previous messages of this class",
                                "type": "integer"
                            }
                        },
                        "additionalProperties": false
                    }
                }
            ]
        }
    },
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "group": {
                "description": "Group type",
                "$ref": "#/definitions/grouptype"
            },
            "pi": {
                "description": "Program Identification code",
                "$ref": "#/definitions/pi"
            },
            "callsign": {
                "description": "Call sign letters for a North American (RBDS) station",
                "type": "string"
            },
            "callsign_uncertain": {
                "description": "Call sign letters for a North American (RBDS) station - probably erroneous due to a TMC workaround",
                "type": "string"
            },
            "channel": {
                "description": "Which channel of a multi-channel signal this group was received on",
                "type": "integer",
                "minimum": 1
            },
            "prog_type": {
                "description": "Program Type",
                "type": "string"
            },
            "tp": {
                "description": "Traffic Program flag",
                "type": "boolean"
            },
            "is_music": {
                "description": "Music/Speech flag",
                "type": "boolean"
            },
            "ta": {
                "description": "Traffic Announcement flag",
                "type": "boolean"
            },
            "radiotext": {
                "$ref": "#/definitions/radiotext"
            },
            "ps": {
                "description": "Program Service name",
                "$ref": "#/definitions/ps"
            },
            "country": {
                "description": "ISO country code",
                "type": "string",
                "minLength": 2,
                "maxLength": 2
            },
            "has_linkage": {
                "type": "boolean"
            },
            "di": {
                "description": "Decoder identification code",
                "$ref": "#/definitions/di"
            },
            "language": {
                "description": "Program language",
                "type": "string"
            },
            "radiotext_plus": {
                "$ref": "#/definitions/rtplus"
            },
            "tmc": {
                "description": "Traffic Message Channel",
                "$ref": "#/definitions/tmc"
            },
            "alt_kilohertz": {
                "description": "Alternative Frequencies",
                "type": "array",
                "items": {
                    "type": "integer"
                }
            },
            "prog_item_number": {
                "description": "A numeric identifier for the currently running program",
                "type": "integer",
                "minimum": 0,
                "maximum": 65535
            },
            "prog_item_started": {
                "description": "Program Item number (start time)",
                "$ref": "#/definitions/pin"
            },
            "bler": {
                "description": "Block Error Rate (averaged percentage of erroneous blocks)",
                "type": "integer",
                "minimum": 0,
                "maximum": 100
            },
            "debug": {
                "description": "Debug messages from redsea",
                "type": "array",
                "items": {
                    "type": "string"
                }
            },
            "tmc_id": {
                "type": "integer",
                "minimum": 0,
                "maximum": 4095
            },
            "ews": {
                "description": "Emergency Warning System channel number",
                "type": "integer",
                "minimum": 0,
                "maximum": 4095
            },
            "partial_radiotext": {
                "description": "Incompletely received RadioText",
                "$ref": "#/definitions/radiotext"
            },
            "partial_ps": {
                "description": "Incompletely received Program Service name",
                "$ref": "#/definitions/ps"
            },
            "partial_alt_kilohertz": {
                "description": "Incomplete list of Alternative Frequencies",
                "type": "array",
                "items": {
                    "type": "integer"
                }
            },
            "open_data_app": {
                "type": "object",
                "properties": {
                    "oda_group": {
                        "description": "The group that carries this Open Data Application",
                        "$ref": "#/definitions/grouptype"
                    },
                    "app_name": {
                        "type": "string"
                    },
                    "message": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 65535
                    }
                },
                "additionalProperties": false
            },
            "clock_time": {
                "description": "Time and date at transmitter (formatted to RFC 3339, section 5.6)",
                "type": "string",
                "pattern": "^....-..-..T..:..:..((\\+|-)..:..|Z)$"
            },
            "rx_time": {
                "description": "Time of demodulation/decoding",
                "type": "string"
            },
            "in_house_data": {
                "description": "The contents of these bits are defined by the operator",
                "type": "array",
                "items": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 65535
                }
            },
            "other_network": {
                "description": "Information about programs on other networks",
                "type": "object",
                "properties": {
                    "pi": {
                        "$ref": "#/definitions/pi"
                    },
                    "tp": {
                        "type": "boolean"
                    },
                    "ta": {
                        "type": "boolean"
                    },
                    "ps": {
                        "$ref": "#/definitions/ps"
                    },
                    "prog_type": {
                        "type": "string"
                    },
                    "alt_kilohertz": {
                        "type": "array",
                        "items": {
                            "type": "integer"
                        }
                    },
                    "kilohertz": {
                        "type": "integer"
                    },
                    "has_linkage": {
                        "type": "boolean"
                    },
                    "linkage_set": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 4095
                    },
                    "prog_item_number": {
                        "description": "A numeric identifier for the currently running program",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 65535
                    },
                    "prog_item_started": {
                        "$ref": "#/definitions/pin"
                    }
                },
                "required": [
                    "pi"
                ],
                "additionalProperties": false
            }
        },
        "required": [
            "pi"
        ],
        "additionalProperties": false
    }
}