trxcon: trx_if_close(): power the transceiver off if needed

Currently it may happen that the transceiver (e.g. fake_trx.py) remains
powered on when we loose a L1CTL client connection.  This is going to
be fixed in change [1] re-implementing the trxcon_fsm.  For now let's
ensure that the transceiver is properly powered off by sending
"CMD POWEROFF" from trx_if_close().

Change-Id: I9c5178907304b36ec3de0ee31b7f7a9ed2e31c16
Related: [1] Ifaf63ead9dd180181358e771367b2a686ba159ca
This commit is contained in:
Vadim Yanitskiy 2022-07-25 22:16:11 +07:00 committed by fixeria
parent 38c4f7294b
commit 40d66990e0
1 changed files with 6 additions and 0 deletions

View File

@ -768,6 +768,8 @@ void trx_if_flush_ctrl(struct trx_instance *trx)
void trx_if_close(struct trx_instance *trx)
{
static const char cmd_poweroff[] = "CMD POWEROFF";
/* May be unallocated due to init error */
if (!trx)
return;
@ -780,6 +782,10 @@ void trx_if_close(struct trx_instance *trx)
/* Flush CTRL message list */
trx_if_flush_ctrl(trx);
/* Power off if the transceiver is up */
if (trx->powered_up && trx->trx_ofd_ctrl.fd >= 0)
send(trx->trx_ofd_ctrl.fd, &cmd_poweroff[0], sizeof(cmd_poweroff), 0);
/* Close sockets */
trx_udp_close(&trx->trx_ofd_ctrl);
trx_udp_close(&trx->trx_ofd_data);