hlog: set the current tx & rx mode from rig announcements

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
1 files changed, 20 insertions(+), 0 deletions(-)

M hlog/contest.c
M hlog/contest.c +20 -0
@@ 48,6 48,7 @@ 
 #include <hlog-lua/xlua.h>
 #include <hlog-rpc/announce.h>
 #include <hlog-rpc/announce-sub.h>
+#include <hlog-rpc/rig-mode.h>
 
 #include "common/config.h"
 #include "common/databases.h"

          
@@ 122,6 123,8 @@ static struct rig_info {
 	uint64_t tx_freq;
 	uint64_t rx_freq;
 	uint64_t power;
+	enum hrig_mode tx_mode;
+	enum hrig_mode rx_mode;
 } rig_info;
 static struct lock rig_lock;
 static LOCK_CLASS(rig_lc);

          
@@ 341,6 344,8 @@ static void handle_rig_notification(enum
 	rig_info.tx_freq = tx_freq;
 	rig_info.rx_freq = rx_freq;
 	rig_info.power = power;
+	rig_info.tx_mode = tx_mode;
+	rig_info.rx_mode = rx_mode;
 	MXUNLOCK(&rig_lock);
 }
 

          
@@ 370,6 375,17 @@ static void __set_rig_info(struct qso_si
 	__set_rig_info((side), (power), \
 		       qso_get_power, qso_set_power_val, qso_clear_power)
 
+static void __set_rig_info_mode(struct qso_side *side, enum hrig_mode mode)
+{
+	const char *modename;
+
+	modename = hamlib_mode_name(mode);
+	if (!modename)
+		qso_clear_mode(side);
+	else
+		qso_set_mode(side, modename);
+}
+
 static void set_rig_info(void)
 {
 	struct rig_info info;

          
@@ 381,10 397,14 @@ static void set_rig_info(void)
 	__set_rig_info_freq(&contact->tx, info.tx_freq);
 	__set_rig_info_freq(&contact->rx, info.rx_freq);
 	__set_rig_info_power(&contact->tx, info.power);
+	__set_rig_info_mode(&contact->tx, info.tx_mode);
+	__set_rig_info_mode(&contact->rx, info.rx_mode);
 
 	__set_rig_info_freq(&template->tx, info.tx_freq);
 	__set_rig_info_freq(&template->rx, info.rx_freq);
 	__set_rig_info_power(&template->tx, info.power);
+	__set_rig_info_mode(&template->tx, info.tx_mode);
+	__set_rig_info_mode(&template->rx, info.rx_mode);
 }
 
 /*