cancel
Showing results for 
Search instead for 
Did you mean: 

X-CUBE-CLD-GEN generic MQTT UART ISSUE

NBreard
Associate

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));
  }

2 REPLIES 2
Guillaume K
ST Employee

when you answer to Security mode question you have to only type one character ("0", "1", "2" or "3"). There is no need to press return key after "0", "1", "2" or "3".

NBreard
Associate

thanks for your reply. In fact, i don't use the same terminal as your. Mine is cutecom 0.30.3 and before to send any input I have to specified either it will be followed by CR or LF or CR/LF or nothing. For me, the intuitive way is to press enter for sending a message and I think this could be tricky for a lot of user as the matter of the fact few terminal pretty used as the arduino one or docklight is working this way.