Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/overlay-ppp-cmux-linux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ CONFIG_SM_CMUX=y
CONFIG_SM_PPP=y

CONFIG_MODEM_CMUX_MTU=127
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE=536
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=399

# With CMUX, the UART buffers should be at least the size of the
# CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE
CONFIG_SM_UART_RX_BUF_COUNT=3
CONFIG_SM_UART_RX_BUF_SIZE=256
CONFIG_SM_UART_TX_BUF_SIZE=768
CONFIG_SM_UART_RX_BUF_SIZE=532
CONFIG_SM_UART_TX_BUF_SIZE=532

# When using PPP, disable commands of IP-based protocols to save flash space.
CONFIG_SM_FTPC=n
Expand Down
17 changes: 12 additions & 5 deletions app/scripts/sm_start_ppp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ fi
stty -F $MODEM $BAUD pass8 raw crtscts clocal

echo "Wait modem to boot"
chat -t5 "" "AT" "OK" <$MODEM >$MODEM || true

echo "Attach CMUX channel to modem..."
ldattach -c $'AT#XCMUX=1\r' GSM0710 $MODEM
if chat -t5 "" "AT" "OK" <$MODEM >$MODEM; then
echo "Modem is in AT mode"
echo "Attach CMUX channel to modem..."
ldattach -c $'AT#XCMUX=1\r' GSM0710 $MODEM
else
echo "Modem not responding, try CMUX resync..."
printf "\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9" > $MODEM
printf "\xF9\x03\xEF\x05\xC3\x01\xF2\xF9" > $MODEM
echo "Attach CMUX channel to modem..."
ldattach GSM0710 $MODEM
fi

sleep 1
stty -F $AT_CMUX clocal
Expand All @@ -58,4 +65,4 @@ chat $CHATOPT -t$TIMEOUT "" "AT#XPPP=1" "OK" >$AT_CMUX <$AT_CMUX
chat $CHATOPT -t$TIMEOUT "" "AT+CFUN=1" "OK" "\c" "#XPPP: 1,0" >$AT_CMUX <$AT_CMUX

pppd $PPP_CMUX noauth novj nodeflate nobsdcomp debug noipdefault passive +ipv6 noremoteip \
local linkname nrf91 defaultroute defaultroute-metric -1 persist lcp-echo-interval 0
local linkname nrf91 defaultroute defaultroute-metric -1 lcp-echo-interval 0
23 changes: 13 additions & 10 deletions app/src/sm_cmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static struct {

/* CMUX */
struct modem_cmux instance;
uint8_t cmux_receive_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
uint8_t cmux_transmit_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
uint8_t cmux_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
uint8_t cmux_transmit_buf[MODEM_CMUX_WORK_BUFFER_SIZE];

/* CMUX channels (Data Link Connection Identifier); index = address - 1 */
struct cmux_dlci {
Expand Down Expand Up @@ -111,6 +111,9 @@ static void dlci_pipe_event_handler(struct modem_pipe *pipe,

case MODEM_PIPE_EVENT_CLOSED:
LOG_INF("DLCI %u%s closed.", dlci->address, is_at ? " (AT)" : "");
if (is_at) {
k_sem_give(&cmux.tx_sem);
}
break;

case MODEM_PIPE_EVENT_RECEIVE_READY:
Expand All @@ -120,8 +123,7 @@ static void dlci_pipe_event_handler(struct modem_pipe *pipe,
break;

case MODEM_PIPE_EVENT_TRANSMIT_IDLE:
if (is_at &&
cmux.dlcis[cmux.at_channel].instance.state == MODEM_CMUX_DLCI_STATE_OPEN) {
if (is_at) {
k_sem_give(&cmux.tx_sem);
}
break;
Expand Down Expand Up @@ -162,14 +164,15 @@ static int cmux_write_at_channel_block(const uint8_t *data, size_t *len)
ret = modem_pipe_transmit(cmux.dlcis[cmux.at_channel].pipe, data + sent,
*len - sent);
if (ret < 0) {
if (ret != -EPERM) {
/* Pipe is open, but failed. */
LOG_ERR("DLCI %u (AT) transmit failed (%d).",
INDEX_TO_DLCI(cmux.at_channel), ret);
}
*len = sent;
LOG_ERR("DLCI %u (AT) transmit failed (%d).",
INDEX_TO_DLCI(cmux.at_channel), ret);
return ret;
} else if (ret == 0) {
if (cmux.dlcis[cmux.at_channel].instance.state !=
MODEM_CMUX_DLCI_STATE_OPEN) {
/* Drop URC when pipe is closed */
return 0;
}
/* Pipe TX buffer full. Wait for transmit idle event. */
k_sem_take(&cmux.tx_sem, K_FOREVER);
} else {
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ manifest:
- name: nrf
remote: ncs
repo-path: sdk-nrf
revision: v3.2.0-preview2
revision: pull/25308/head
import: true