Skip to content

Commit ca65359

Browse files
committed
Added warning for long SMS
Added warning for attempting to send SMS larger than the configured maximum size. Signed-off-by: Jared Baumann <[email protected]>
1 parent eb8c42d commit ca65359

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

samples/tmo_shell/src/tmo_shell.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,14 @@ int sock_sendsms(const struct shell *shell, size_t argc, char **argv)
11201120
shell_error(shell, "Socket %d not found", sd);
11211121
return -EINVAL;
11221122
}
1123-
// shell_print(shell, "About to call fcntl to send sms, phone: %s, msg: %s\n", argv[2], argv[3]);
1124-
snprintf(sms.phone, SMS_PHONE_MAX_LEN, "%s", argv[2]);
1125-
snprintf(sms.msg, CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN + 1, "%s", argv[3]);
1123+
if (strlen(argv[3]) > CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN) {
1124+
shell_warn(shell, "SMS message exceeds limit (%d>%d), truncating message",
1125+
strlen(argv[3]), CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN);
1126+
}
1127+
strncpy(sms.phone, argv[2], SMS_PHONE_MAX_LEN);
1128+
strncpy(sms.msg, argv[3], CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN + 1);
11261129
ret = fcntl_ptr(sock_idx, SMS_SEND, &sms);
1127-
// printf("returned from fcntl, ret = %d\n", ret);
1130+
11281131
return ret;
11291132
}
11301133

0 commit comments

Comments
 (0)