diff --git a/NEWS b/NEWS index 8c9b8ecb7..5409bba58 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ Version 5.x -- future * Change FT1000MP Mark V model names to align with FT1000MP Version 4.6 + * Hamlib now starts a multicast server that sends out rig information. Does not receive commands yet. + See README.multicast + * rigctld has new -b/bind-all option to try all interfaces -- restores original behavior. This was done to fix duplicate rigctld instances on Windows * Yaesu rigs can now use send_morse to send keyer message 1-5 or a CW message up to 50 chars (which will use memory 1) * rig set level METER can now take SWR,COMP,ALC,IC/ID,DB,PO,VDD,TEMP arguments to set which meter to display diff --git a/README.multicast b/README.multicast index 2ccf4c6d1..ead2dd410 100644 --- a/README.multicast +++ b/README.multicast @@ -1,13 +1,69 @@ -Planned for version 5.0 -- comments/suggestions about this are more than welcome +Planned for version 4.6 -- comments/suggestions about this are more than welcome +Example of multicast packet as of 2023-10-20 +=================================================================== +{ + "app": "Hamlib", + "version": "4.6~git 2023-10-20T16:52:59Z SHA=d87671", + "seq": 183, + "time": "2023-10-20T20:13:53.139869-0000", + "crc": 0, + "rig": { + "id": "FLRig:127.0.0.1:12345:30508", + "status": "OK", + "errorMsg": "", + "name": "FLRig", + "split": false, + "splitVfo": "VFOA", + "satMode": false, + "modelist": "AM CW USB LSB FM CWR PKTLSB PKTUSB " + }, + "vfos": [ + { + "name": "VFOA", + "freq": 14074270, + "mode": "PKTUSB", + "width": 3, + "ptt": false, + "rx": true, + "tx": true + }, + { + "name": "VFOB", + "freq": 14074500, + "mode": "", + "width": 0, + "ptt": false, + "rx": false, + "tx": false + } + ], + "spectra": [ + { + "id": 0, + "name": "?", + "type": "FIXED", + "minLevel": 0, + "maxLevel": 0, + "minStrength": 0, + "maxStrength": 0, + "centerFreq": 0, + "span": 0, + "lowFreq": 0, + "highFreq": 0, + "length": 0, + "data": "" + } + ] +} +=========================================================== Multicast UDP broadcast containing rig snapshot data Bidirectional rig control and status Choice of token pairs or JSON All packets will be tagged with ID=[unique name] -- so multiple rigs can broadcast/rx on the same port -Will be able to set freq, mode, width, ptt, satmode, and split to start since those are common to many apps. +Will eventually be able to set freq, mode, width, ptt, satmode, and split to start since those are common to many apps. More functions will be added as time goes on. Broadcast packet contents to be based on get_rig_info output -This will be the text format of name=value pairs Can be multiple VFO lines Parsers should allow for unknown tags that may be added in the future diff --git a/src/rig.c b/src/rig.c index 1ca1a7546..1530767cd 100644 --- a/src/rig.c +++ b/src/rig.c @@ -881,6 +881,7 @@ int HAMLIB_API rig_open(RIG *rig) value_t parm_value; //unsigned int net1, net2, net3, net4, net5, net6, net7, net8, port; int is_network = 0; + int retval = 0; ENTERFUNC2; @@ -1450,7 +1451,7 @@ int HAMLIB_API rig_open(RIG *rig) if (rig->caps->get_freq) { - int retval = rig_get_freq(rig, RIG_VFO_A, &freq); + retval = rig_get_freq(rig, RIG_VFO_A, &freq); if (retval == RIG_OK && rig->caps->rig_model != RIG_MODEL_F6K) { @@ -1484,6 +1485,21 @@ int HAMLIB_API rig_open(RIG *rig) memcpy(&rs->dcdport_deprecated, &rs->dcdport, sizeof(hamlib_port_t_deprecated)); rig_flush_force(&rs->rigport, 1); // if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL) multicast_init(rig, "224.0.0.1", 4532); +// multicast_init(rig, "224.0.0.1", 4532); + char *multicast_addr = "224.0.0.1"; + int multicast_port = 4532; + enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE | + RIG_MULTICAST_SPECTRUM; + retval = network_multicast_publisher_start(rig, multicast_addr, + multicast_port, items); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: network_multicast_server failed: %s\n", __FILE__, + rigerror(retval)); + // we will consider this non-fatal for now + } + RETURNFUNC2(RIG_OK); } diff --git a/src/snapshot_data.c b/src/snapshot_data.c index 0405af716..b6da46bd0 100644 --- a/src/snapshot_data.c +++ b/src/snapshot_data.c @@ -1,5 +1,7 @@ +#include +#define _XOPEN_SOURCE 700 +#include #include - #include #include "misc.h" #include "snapshot_data.h" @@ -19,8 +21,8 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig) char buf[1024]; // TODO: need to assign rig an ID, e.g. from command line - snprintf(buf, sizeof(buf), "%s:%s", rig->caps->model_name, - rig->state.rigport.pathname); + snprintf(buf, sizeof(buf), "%s:%s:%d", rig->caps->model_name, + rig->state.rigport.pathname, getpid()); node = cJSON_AddStringToObject(rig_node, "id", buf);