modem: add test VTY command to send CHANNEL REQUEST
Do not call grr_tx_chan_req() unconditionally from grr_rx_bcch(). Add a special (hidden, expert mode) VTY command for that. Change-Id: I049a8d7f58ae9703d06dff235973ba376702c873 Related: OS#5500
This commit is contained in:
parent
1612c8f862
commit
b29a26c620
|
@ -1,6 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct msgb;
|
||||
struct osmocom_ms;
|
||||
struct lapdm_entity;
|
||||
|
||||
int modem_grr_rslms_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx);
|
||||
int modem_grr_tx_chan_req(struct osmocom_ms *ms, uint8_t chan_req);
|
||||
uint8_t modem_grr_gen_chan_req(bool single_block);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include <l1ctl_proto.h>
|
||||
|
||||
/* Generate an 8-bit CHANNEL REQUEST message as per 3GPP TS 44.018, 9.1.8 */
|
||||
static uint8_t grr_gen_chan_req(bool single_block)
|
||||
uint8_t modem_grr_gen_chan_req(bool single_block)
|
||||
{
|
||||
uint8_t rnd = (uint8_t)rand();
|
||||
|
||||
|
@ -76,7 +76,7 @@ static bool grr_match_req_ref(struct osmocom_ms *ms,
|
|||
return false;
|
||||
}
|
||||
|
||||
static int grr_tx_chan_req(struct osmocom_ms *ms, bool single_block)
|
||||
int modem_grr_tx_chan_req(struct osmocom_ms *ms, uint8_t chan_req)
|
||||
{
|
||||
struct gsm322_cellsel *cs = &ms->cellsel;
|
||||
struct gsm48_rrlayer *rr = &ms->rrlayer;
|
||||
|
@ -88,7 +88,7 @@ static int grr_tx_chan_req(struct osmocom_ms *ms, bool single_block)
|
|||
if (!cs->sel_si.gprs.supported)
|
||||
return -ENOTSUP;
|
||||
|
||||
rr->cr_ra = grr_gen_chan_req(single_block);
|
||||
rr->cr_ra = chan_req;
|
||||
memset(&rr->cr_hist[0], 0x00, sizeof(rr->cr_hist));
|
||||
|
||||
LOGP(DRR, LOGL_NOTICE, "Sending CHANNEL REQUEST (0x%02x)\n", rr->cr_ra);
|
||||
|
@ -209,10 +209,6 @@ static int grr_rx_bcch(struct osmocom_ms *ms, struct msgb *msg)
|
|||
LOGP(DRR, LOGL_INFO, "BCCH message (type=0x%02x): %s\n",
|
||||
si_type, gsm48_rr_msg_name(si_type));
|
||||
|
||||
/* HACK: request an Uplink TBF here (one phase access) */
|
||||
if (ms->rrlayer.state == GSM48_RR_ST_IDLE)
|
||||
grr_tx_chan_req(ms, false);
|
||||
|
||||
switch (si_type) {
|
||||
case GSM48_MT_RR_SYSINFO_1:
|
||||
return grr_handle_si1(ms, msg);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <osmocom/bb/common/vty.h>
|
||||
#include <osmocom/bb/common/apn.h>
|
||||
#include <osmocom/bb/common/ms.h>
|
||||
#include <osmocom/bb/modem/grr.h>
|
||||
#include <osmocom/bb/modem/vty.h>
|
||||
|
||||
static struct cmd_node apn_node = {
|
||||
|
@ -52,6 +53,34 @@ int modem_vty_go_parent(struct vty *vty)
|
|||
return vty->node;
|
||||
}
|
||||
|
||||
#define MS_NAME_DESC "Name of MS (see \"show ms\")\n"
|
||||
#define TEST_CMD_DESC "Testing commands for developers\n"
|
||||
#define GRR_CMDG_DESC "GPRS RR specific commands\n"
|
||||
|
||||
/* testing commands */
|
||||
DEFUN_HIDDEN(test_grr_tx_chan_req,
|
||||
test_grr_tx_chan_req_cmd,
|
||||
"test MS_NAME grr tx-chan-req (1phase|2phase)",
|
||||
TEST_CMD_DESC MS_NAME_DESC GRR_CMDG_DESC
|
||||
"Send a CHANNEL REQUEST (RACH) to the network\n"
|
||||
"One-phase packet access (011110xx or 01111x0x or 01111xx0)\n"
|
||||
"Two-phase (single block) packet access (01110xxx)\n")
|
||||
{
|
||||
struct osmocom_ms *ms;
|
||||
uint8_t chan_req;
|
||||
|
||||
if ((ms = l23_vty_get_ms(argv[0], vty)) == NULL)
|
||||
return CMD_WARNING;
|
||||
|
||||
chan_req = modem_grr_gen_chan_req(argv[1][0] == '2');
|
||||
if (modem_grr_tx_chan_req(ms, chan_req) != 0) {
|
||||
vty_out(vty, "Failed to send a CHANNEL REQUEST%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* per APN config */
|
||||
DEFUN(cfg_ms_apn, cfg_ms_apn_cmd, "apn APN_NAME",
|
||||
"Configure an APN\n"
|
||||
|
@ -232,6 +261,7 @@ int modem_vty_init(void)
|
|||
if ((rc = l23_vty_init(config_write, NULL)) < 0)
|
||||
return rc;
|
||||
install_element_ve(&l23_show_ms_cmd);
|
||||
install_element_ve(&test_grr_tx_chan_req_cmd);
|
||||
install_element(CONFIG_NODE, &l23_cfg_ms_cmd);
|
||||
|
||||
install_element(MS_NODE, &cfg_ms_apn_cmd);
|
||||
|
|
Loading…
Reference in New Issue