X-CUBE-CLD-GEN generic MQTT UART ISSUE
Hello I'd like to report a bug concerning the GENERIC MQTT Project.
In this project one must use a serial terminal to configure wifi point by giving ssid, connexion mode ( WEP, WPA,or WPA2)
and a password.
The bug is that the password typing sequence is bypass and the connexion failed.
After looking at the code the issue is that you have to ended your message by '\n' in the code snippet in line 18, you do a getchar, so get one char but there is still a '\n' char pending. When getInputString function is used, it begins with another getchar call. the pending '\n' is read and saw as and end of frame and discard the typing password sequence
int updateWiFiCredentials(void)
{
wifi_config_t wifi_config;
int ret = 0;
memset(&wifi_config, 0, sizeof(wifi_config_t));
printf("\nEnter SSID: ");
getInputString(wifi_config.ssid, USER_CONF_WIFI_SSID_MAX_LENGTH);
msg_info("You have entered %s as the ssid.\n", wifi_config.ssid);
printf("\n");
char c;
do
{
printf("\rEnter Security Mode (0 - Open, 1 - WEP, 2 - WPA, 3 - WPA2): \b");
c = getchar();
}
while ( (c < '0') || (c > '3'));
wifi_config.security_mode = c - '0';
msg_info("\nYou have entered %d as the security mode.\n", wifi_config.security_mode);
if (wifi_config.security_mode != 0)
{
printf("Enter password: ");
c = getchar();
getInputString(wifi_config.psk, sizeof(wifi_config.psk));
}