Skip to content

Example for JSON RPC communication protocol

Ralf Wilke DH3WR edited this page Jun 11, 2018 · 3 revisions

NOTICE: THIS IS NOT IMPLEMENTED

JSON-RPC communication protocol between Unipager/DAPNET-Proxy and DAPNET-Core

Überarbeitung Ralf DH3WR 13.3.2018: Anpassung an JSON-RPC

Erklärung:

--> für eine Nachricht vom Client an der Server,
<-- für Nachricht an Client

Login Unipager:

--> { "jsonrpc": "2.0", "method": "login",
  "params": {
    "software": "Unipager",
    "version": "1.0.2",
    "type": "Audio",
    "callsign": "db0abc",
    "authkey": "VERYSECRET",
    "ntpsync": true
  },
  "id": 1}

Login DAPNET-Proxy with PR340:

  "params": {
    "software": "PR430",
    "version": "v0.57-SCP-#234567",
    "callsign": "db0abc",
    "authkey": "VERYSECRET",
    "proxyused": true,
    "proxyversion": "1.2.3",
    "ntpsync": true
  },
  "id": 1
}

Login DAPNET-Proxy with RPC/XOS:

--> { "jsonrpc": "2.0", "method": "login",
  "params": {
    "software": "RPC/XOS",
    "version": "v2.2.0pre32-SCP-#2345678",
    "callsign": "db0abc",
    "authkey": "VERYSECRET",
    "proxyused": true,
    "proxyversion": "1.2.3",
    "ntpsync": true
  },
  "id": 1
}

Login DAPNET-Proxy with uPSDrpc/XOS:

--> { "jsonrpc": "2.0", "method": "login",
  "params": {
    "software": "uPSDrpc/XOS",
    "version": "v1.0b-SCP-#2345678",
    "callsign": "db0abc",
    "authkey": "VERYSECRET",
    "proxyused": true,
    "proxyversion": "1.2.3",
    "ntpsync": true
  },
  "id": 1
}

Answer from DAPNET-CORE if credentials ok:

<-- { "jsonrpc": "2.0", "result": {"LoggedIn": true}, "id": 1}

Answer from DAPNET-CORE if callsign not found:

<-- {"jsonrpc": "2.0", "error": {"code": -32000, "message": "Transmitter callsign not found on DAPNET"}, "id": "1"}

Answer from DAPNET-CORE if callsign found, but credentials not right:

<-- {"jsonrpc": "2.0", "error": {"code": -32001, "message": "Transmitter callsign found on DAPNET, but AuthKey not correct"}, "id": "1"}

Answer from DAPNET-CORE NTP Sync is reported false:

<-- {"jsonrpc": "2.0", "error": {"code": -32002, "message": "NTP Sync on Transmitter or DAPNET-Proxy not working"}, "id": "1"}

Logout Unipager oder DAPNET-Proxy:

--> {"jsonrpc": "2.0", "method": "logout", "id": 2}
<-- {"jsonrpc": "2.0", "result": {"LoggedIn": false}, "id": 2}

Timeslot-Transfer

--> {"jsonrpc": "2.0", "method": "SetTimeslots",
  "params": {
    "enabledtimeslots": [
      false,
      true,
      false,
      true,
      false,
      true,
      false,
      true,
      false,
      true,
      true,
      true,
      true,
      true,
      true,
      true
    ],
  },
  "id": 3
}

Answer if all ok

<-- {"jsonrpc": "2.0", "result": {"TimeslotsSet": true}, "id": 3}

Answer if parsing error

<-- {"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request on setting timeslots"}, "id": 3}

Send paging call to transmitter

--> {"jsonrpc": "2.0", "method": "QueueMessage",
  "params": {
    "Type": "AlphaNum" (or "numeric")
    "Baudrate": 1200,
    "RIC": 1234567,
    "Functional-Bits": 0 (or 1 or 2 or 3)
    "Message": "Message",
    "PrioLevel": 0, ( from 0 to 4, 4 is the most urgent)
  ],
  "id": 4
}

(Keine Zusammenfassung für mehrere Nachrichten mit mehreren RICS. So ist man max. flexibel.)

<-- {"jsonrpc": "2.0", "result": {"MessageQueued": true, "QueueLenght": [0,10,2,3,1]}, "id": 4}

Queue-Prioritätsklassen-Beschreibung:

0: Rubriken-Namen 1: Rubriken-Inhalte 2: Persönliche Calls (über API /call) und Skyper-Aktivierungsrufe 3: Uhrzeit-Aussendungen 4: Persönliche Call mit High-Prio-Flag (über API /call)

Keepalive ping from Core to Transmitter

(Erfordert bidirectionales JSON-RPC, vielleicht das hier: https://github.com/nbarraille/JJsonRpc/tree/master/src/com/nbarraille/jjsonrpc/example oder timeout für Sender auf dem Core, wenn kein Ping vom Sender kommt.)

--> {"jsonrpc": "2.0", "method": "ping", "id": 5}
<-- {"jsonrpc": "2.0", "result": "pong", "id": 5}

Status update from Transmitter to DAPNET-CORE

Könnte immer vor und nach einem Sendevorgang vom Sender kommen

--> {"jsonrpc": "2.0", "method": "StatusUpdate",
  "params": {
    "transmitting": true, (oder false)
    "QueueLenght": [0,10,2,3,1],
    "TXedCalls": 12345
  },
  "id": 6
}
<-- {"jsonrpc": "2.0", "result": "StatusUpdateOK", "id": 5}

Telemetrie

Parameter optional, was nicht da ist, wird vom Core mit NULL besetzt Gute Frage, ob das auch der Unipager bereit stellt. Eigentlich eher andere Programme. Mal nachdenken, wie man das machen könnte.

--> {"jsonrpc": "2.0", "method": "TelemetrieUpdate",
  "params": {
    "voltage": "12.2",
    "current": "2.3",
    "swr": "1.2",
    "forwardPower: "20.2",
    "reflectedPower: "0.4",
    "temperatureAmbient: "25.3",
    "temperaturePA: "34.3"
  },
  "id": 7
}
<-- {"jsonrpc": "2.0", "result": "TelemetrieUpdateOK", "id": 7}