expected primary-expression before '(' token

it is adafruit example
Original example configure at the start up with predefined server name port etc

Now I have change if (subscription == openClose->subscribe)
to
if (subscription == openClose) since mqtt is a pointer

compiler runs and doesn't give any error on the code. it is now complaining about the boad

Error compiling for board Generic ESP8266 Module.

I am really confused

hope you can help

this is the original code

// LED will blink when in config mode

#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
//for LED status
#include <Ticker.h>
Ticker ticker;

#if defined(ESP8266)
#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
#else
#include <WiFi.h>
#endif
/*#include <ESPAsyncWebServer.h>
#include <ESPAsyncTCP.h>
#include <Hash.h>
#include <FS.h>*/
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"

//#define WIFI_SSID "<WiFi-F4B0>"
//#define WIFI_PASS "<49491500>"

/*#define MQTT_SERV "io.adafruit.com"
#define MQTT_PORT 1883
#define MQTT_NAME "behmadi"
#define MQTT_PASS "aio_hitc98ZLeJQLX5hX0SO1iZAoikz9" */
#define MQTT_SERV "io.adafruit.com"
#define MQTT_PORT  1883
#define MQTT_NAME "abc"
#define MQTT_PASS "XXXX"
//String MQTT_PORT = String(MQTT_PORT_C);
//int test = MQTT_PORT.toInt();
#ifndef LED_BUILTIN
#define LED_BUILTIN 13 // ESP32 DOES NOT DEFINE LED_BUILTIN
#endif

int LED = LED_BUILTIN;
int ledPin = 12;
//const char* WIFI_SSID =  "WiFi-F4B0"; //"AndroidAPC616";
//const char* WIFI_PASS = "49491500"; //"brmc3813"; 

//Set up MQTT and WiFi clients
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME, MQTT_PASS);

//Set up the feed you're subscribing to
Adafruit_MQTT_Subscribe OpenClose = Adafruit_MQTT_Subscribe(&mqtt, MQTT_NAME "/f/OpenClose");
void tick()
{
  //toggle state
  digitalWrite(LED, !digitalRead(LED));     // set pin to the opposite state
}

//gets called when WiFiManager enters configuration mode
void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());
  //if you used auto generated SSID, print it
  Serial.println(myWiFiManager->getConfigPortalSSID());
  //entered config mode, make led toggle faster
  ticker.attach(0.2, tick);
}


void setup()
{
  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  // put your setup code here, to run once:
  Serial.begin(115200);
  
  //set led pin as output
  pinMode(LED, OUTPUT);
  // start ticker with 0.5 because we start in AP mode and try to connect
  ticker.attach(0.6, tick);

  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wm;
  //reset settings - for testing
  // wm.resetSettings();

  //set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
  wm.setAPCallback(configModeCallback);

  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  if (!wm.autoConnect()) {
    Serial.println("failed to connect and hit timeout");
    //reset and try again, or maybe put it to deep sleep
    ESP.restart();
    delay(1000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  ticker.detach();
  //keep LED on
  digitalWrite(LED, LOW);
  
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);

  /*//Connect to WiFi
  Serial.print("\n\nConnecting Wifi... ");
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print (".");
  }

  Serial.println("OK!");
*/
  //Subscribe to the onoff feed
  mqtt.subscribe(&OpenClose);

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()
{
  MQTT_connect();
  
  //Read from our subscription queue until we run out, or
  //wait up to 5 seconds for subscription to update
  Adafruit_MQTT_Subscribe * subscription;
  while ((subscription = mqtt.readSubscription(5000)))
  {
    //If we're in here, a subscription updated...
    if (subscription == &OpenClose)
    {
      //Print the new value to the serial monitor
      Serial.print("openClose: ");
      Serial.println((char*) OpenClose.lastread);
      
      //If the new value is  "ON", turn the light on.
      //Otherwise, turn it off.
      if (!strcmp((char*) OpenClose.lastread, "ON"))
      {
        //Active low logic
        digitalWrite(ledPin, HIGH);
      }
      else
      {
        digitalWrite(ledPin, LOW);
      }
    }
  }

  // ping the server to keep the mqtt connection alive
  if (!mqtt.ping())
  {
    mqtt.disconnect();
  }
}


/***************************************************
  Adafruit MQTT Library ESP8266 Example

  Must use ESP8266 Arduino from:
    https://github.com/esp8266/Arduino

  Works great with Adafruit's Huzzah ESP board & Feather
  ----> https://www.adafruit.com/product/2471
  ----> https://www.adafruit.com/products/2821

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Tony DiCola for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

void MQTT_connect() 
{
  int8_t ret;

  // Stop if already connected.
  if (mqtt.connected()) 
  {
    return;
  }

  Serial.print("Connecting to MQTT... ");

  uint8_t retries = 3;
  while ((ret = mqtt.connect()) != 0) // connect will return 0 for connected
  { 
       Serial.println(mqtt.connectErrorString(ret));
       Serial.println("Retrying MQTT connection in 5 seconds...");
       mqtt.disconnect();
       delay(5000);  // wait 5 seconds
       retries--;
       if (retries == 0) 
       {
         // basically die and wait for WDT to reset me
         while (1);
       }
  }
  Serial.println("MQTT Connected!");
}

Post the code. Copy and paste the error too.

aarg:
I'm saying that "void setup" or "void loop" are improper names for functions. They aren't "voids", they are functions that return a void type don't return any value.

Wildbill this is the latest one

#include <FS.h>                  

#if defined(ESP8266)
#include <ESP8266WiFi.h>       
#else
#include <WiFi.h>
#endif

//for LED status
#include <Ticker.h>
Ticker ticker;

//needed for library
#include <DNSServer.h>
#include <ESPAsyncWebServer.h>
#include <ESPAsyncWiFiManager.h>        
#include <WiFiManager.h>
#include <ArduinoJson.h>                  
#include <stdio.h>
#include <string.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"


char MQTT_SERV[40] = "io.adafruit.com";
char MQTT_PORT_C[6] = "1883";
char MQTT_NAME[20] = "ABC";
char MQTT_PASS[33] = "XXX";

char static_ip[16] = "";
char static_gw[16] = "";
char static_sn[16] = "";

WiFiClient client;
void MQTT_connect();
Adafruit_MQTT_Client *mqtt;
Adafruit_MQTT_Subscribe *openClose;

//unsigned int mqtt_port = atoi (MQTT_PORT_C);
//char* mqtt_serv = MQTT_SERV;
//char* mqtt_name = MQTT_NAME;
//char* mqtt_pass = MQTT_PASS;
//#define mqtt_port 1883
//#define mqtt_serv "my server"
//#define mqtt_name "my name"
//#define mqtt_pass "my pass"
#ifndef LED_BUILTIN
#define LED_BUILTIN 13 // ESP32 DOES NOT DEFINE LED_BUILTIN
#endif
int LED = LED_BUILTIN;
int ledPin = 12;

//flag for saving data
bool shouldSaveConfig = false;
AsyncWebServer server(80);
DNSServer dns;

void tick()
{
  //toggle state
  digitalWrite(LED, !digitalRead(LED));     // set pin to the opposite state
}
//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}




void Read_Config() {
  if (SPIFFS.begin()) {
    Serial.println("mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

          strcpy(MQTT_SERV, json["MQTT_SERV"]);
          strcpy(MQTT_PORT_C, json["MQTT_PORT_C"]);
          strcpy(MQTT_NAME, json["MQTT_NAME"]);
          strcpy(MQTT_PASS, json["MQTT_PASS"]);


          if (json["ip"]) {
            Serial.println("setting custom ip from config");
            //static_ip = json["ip"];
            strcpy(static_ip, json["ip"]);
            strcpy(static_gw, json["gateway"]);
            strcpy(static_sn, json["subnet"]);
            //strcat(static_ip, json["ip"]);
            //static_gw = json["gateway"];
            //static_sn = json["subnet"];
            Serial.println(static_ip);


          } else {
            Serial.println("no custom ip in config");
          }
        } else {
          Serial.println("failed to load json config");
        }
        configFile.close();
      }
    }
  } else {
    Serial.println("failed to mount FS");
  }
  //end read
}
void Save_Cust_Para() {
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    //DynamicJsonDocument json(1024);
    json["MQTT_SERV"] = MQTT_SERV;
    json["MQTT_PORT_C"] = MQTT_PORT_C;
    json["MQTT_NAME"] = MQTT_NAME;
    json["MQTT_PASS"] = MQTT_PASS;

    json["ip"] = WiFi.localIP().toString();
    json["gateway"] = WiFi.gatewayIP().toString();
    json["subnet"] = WiFi.subnetMask().toString();

    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }

    json.prettyPrintTo(Serial);
    //serializeJson(json, Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }

}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println();
  //set led pin as output
  pinMode(LED, OUTPUT);

  ticker.attach(0.6, tick);


  Serial.println("mounting FS...");

  Read_Config();

  Serial.println(static_ip);
  Serial.println(MQTT_NAME);
  Serial.println(MQTT_SERV);
  Serial.println(MQTT_PASS);


  
  AsyncWiFiManagerParameter custom_MQTT_SERV("server", "mqtt server", MQTT_SERV, sizeof(MQTT_SERV));
  AsyncWiFiManagerParameter custom_MQTT_PORT_C("port", "mqtt port", MQTT_PORT_C, 6);
  AsyncWiFiManagerParameter custom_MQTT_NAME("name", "mqtt name", MQTT_NAME, sizeof(MQTT_NAME) );
  AsyncWiFiManagerParameter custom_MQTT_PASS("pass", "mqtt pass", MQTT_PASS, sizeof(MQTT_PASS));


  AsyncWiFiManager wifiManager(&server, &dns);

  wifiManager.setSaveConfigCallback(saveConfigCallback);

  //set static ip
  IPAddress _ip, _gw, _sn;
  _ip.fromString(static_ip);
  _gw.fromString(static_gw);
  _sn.fromString(static_sn);

  wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);

  //add all your parameters here
  wifiManager.addParameter(&custom_MQTT_SERV);
  wifiManager.addParameter(&custom_MQTT_PORT_C);
  wifiManager.addParameter(&custom_MQTT_NAME);
  wifiManager.addParameter(&custom_MQTT_PASS);

  
  wifiManager.setMinimumSignalQuality();

  
  
  if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
    Serial.println("failed to connect and hit timeout");
    delay(3000);
  
    ESP.reset();
    delay(5000);
  }

  
  Serial.println("connected...yeey :)");
  ticker.detach();
 
  digitalWrite(LED, LOW);

  pinMode(ledPin, OUTPUT);
 
  strcpy(MQTT_SERV, custom_MQTT_SERV.getValue());
  strcpy(MQTT_PORT_C, custom_MQTT_PORT_C.getValue());
  strcpy(MQTT_NAME, custom_MQTT_NAME.getValue());
  strcpy(MQTT_PASS, custom_MQTT_PASS.getValue());
  unsigned int mqtt_port = atoi (MQTT_PORT_C);
  char* mqtt_serv = MQTT_SERV;
  String S_MQTT_NAME(MQTT_NAME);
  char* feed = "/f/openClose";
  //int mqtt_name_len = S_MQTT_NAME.length() + feed.length() +1;
  char* mqtt_name;
  strcpy(mqtt_name, MQTT_NAME);
  strcat(mqtt_name, feed);
  puts(mqtt_name);

  char* mqtt_pass = MQTT_PASS;


  
  mqtt = new Adafruit_MQTT_Client(&client, mqtt_serv, mqtt_port, mqtt_name, mqtt_pass);

  
  openClose = new Adafruit_MQTT_Subscribe(mqtt, mqtt_name );

  
  Save_Cust_Para();

  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  Serial.println(WiFi.gatewayIP());
  Serial.println(WiFi.subnetMask());


  
  mqtt->subscribe(openClose);

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()
{
  MQTT_connect();


  Adafruit_MQTT_Subscribe * subscription;
  while ((subscription = mqtt->readSubscription(5000)))
  {
   
    if (subscription == openClose)
    {
      
      Serial.print("openClose: ");
      Serial.println((char*) openClose->lastread);

      
      if (!strcmp((char*) openClose->lastread, "ON"))
      {
        //Active low logic
        digitalWrite(ledPin, HIGH);
      }
      else
      {
        digitalWrite(ledPin, LOW);
      }
    }
  }

  // ping the server to keep the mqtt connection alive
  if (!mqtt->ping())
  {
    mqtt->disconnect();
  }
}


void MQTT_connect()
{
  int8_t ret;

  // Stop if already connected.
  if (mqtt->connected())
  {
    return;
  }

  Serial.print("Connecting to MQTT... ");

  uint8_t retries = 3;
  while ((ret = mqtt->connect()) != 0) 
  {
    Serial.println(mqtt->connectErrorString(ret));
    Serial.println("Retrying MQTT connection in 5 seconds...");
    mqtt->disconnect();
    delay(5000);  // wait 5 seconds
    retries--;
    if (retries == 0)
    {
      
      while (1);
    }
  }
  Serial.println("MQTT Connected!");
}
  char* mqtt_name;
  strcpy(mqtt_name,MQTT_NAME);
  strcat(mqtt_name,feed);
  puts(mqtt_name);

Your pointer mqtt_name is uninitialized. You need to allocate some space...

char mqtt_name[20];

I am still getting the same error with

char mqtt_name[20];

or

char* mqtt_name;

exit status 1
Error compiling for board Generic ESP8266 Module.

That's what it says at the very end of the list of compilation errors. The useful information is above it.

Error file is too big.
I have attached it

errorfile.txt (27.6 KB)

That was silly. I always though error is the last line. I started looking at the error file and I have big problems.
thanks wildbill to pointing it out

Thank you Wildbill

you really put me in right directions

looking at the error file really opened a lots of door. I had duplicate declaration because of incompatible librarys

I wish I knew about error file before.

All fixed and it is compiled.

I check how it is running and let you know

After all these issue, code loaded fine,
Just found out SPIFFSEditor only except per defined up to 3 parameter.

this is so pain full.

wildbill, do you how to add an extra parameter for my mqtt_name

i have some idea but won't be clean by combining name and token and then split it before passing to adafruit

Thanks
Behzad

Hi there,
I have decided t build the project again from scratch and see where would be the error.

code is now just reading config files using WiFiManager. config file.

// LED will blink when in config mode

#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h>
//for LED status
#include <Ticker.h>
Ticker ticker;

#ifndef LED_BUILTIN
#define LED_BUILTIN 13 // ESP32 DOES NOT DEFINE LED_BUILTIN
#endif

//-------------------------------------
//define your default values here, if there are different values in config.json, they are overwritten.
//length should be max size + 1
char mqtt_server[40];
char mqtt_port[6] = "8080";
char blynk_token[70] = "YOUR USERNAME,TOKEN";
//default custom static IP
char static_ip[16] = "10.0.1.56";
char static_gw[16] = "10.0.1.1";
char static_sn[16] = "255.255.255.0";
//adafruit mqtt parameters
char MQTT_SERV[40] = "io.adafruit.com";
char MQTT_PORT_C[6] = "1883";
char MQTT_NAME[20] = "ABC";
char MQTT_PASS[33] = "XXX";
//--------------------------------------

int LED = LED_BUILTIN;
bool shouldSaveConfig = false;
void tick()
{
  //toggle state
  digitalWrite(LED, !digitalRead(LED));     // set pin to the opposite state
}

//gets called when WiFiManager enters configuration mode
void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());
  //if you used auto generated SSID, print it
  Serial.println(myWiFiManager->getConfigPortalSSID());
  //entered config mode, make led toggle faster
  shouldSaveConfig = true;
  ticker.attach(0.2, tick);
}


void Read_config(){
  //clean FS, for testing
  //SPIFFS.format();

  //read configuration from FS json
  Serial.println("mounting FS...");

  if (SPIFFS.begin()) {
    Serial.println("mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

          strcpy(mqtt_server, json["mqtt_server"]);
          strcpy(mqtt_port, json["mqtt_port"]);
          strcpy(blynk_token, json["blynk_token"]);

          if (json["ip"]) {
            Serial.println("setting custom ip from config");
            //static_ip = json["ip"];
            strcpy(static_ip, json["ip"]);
            strcpy(static_gw, json["gateway"]);
            strcpy(static_sn, json["subnet"]);
            //strcat(static_ip, json["ip"]);
            //static_gw = json["gateway"];
            //static_sn = json["subnet"];
            Serial.println(static_ip);
            /*            Serial.println("converting ip");
                        IPAddress ip = ipFromCharArray(static_ip);
                        Serial.println(ip);*/
          } else {
            Serial.println("no custom ip in config");
          }
        } else {
          Serial.println("failed to load json config");
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");
  }
  //end read
}
void setup() {
  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  // put your setup code here, to run once:
  Serial.begin(115200);
  
  //set led pin as output
  pinMode(LED, OUTPUT);
  // start ticker with 0.5 because we start in AP mode and try to connect
  ticker.attach(0.6, tick);
  
  Read_config();
  Serial.println(static_ip);
  Serial.println(blynk_token);
  Serial.println(mqtt_server);


  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
  WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 5);
  WiFiManagerParameter custom_blynk_token("blynk", "user name, blynk token", blynk_token, 70);
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wm;
  //reset settings - for testing
  // wm.resetSettings();

  //set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
  wm.setAPCallback(configModeCallback);
//set static ip
  IPAddress _ip, _gw, _sn;
  _ip.fromString(static_ip);
  _gw.fromString(static_gw);
  _sn.fromString(static_sn);

  wm.setSTAStaticIPConfig(_ip, _gw, _sn);

  //add all your parameters here
  wm.addParameter(&custom_mqtt_server);
  wm.addParameter(&custom_mqtt_port);
  wm.addParameter(&custom_blynk_token);

  //reset settings - for testing
  //wifiManager.resetSettings();

  //set minimu quality of signal so it ignores AP's under that quality
  //defaults to 8%
  wm.setMinimumSignalQuality();

  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //in seconds
  //wifiManager.setTimeout(120);
  
  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  if (!wm.autoConnect("AutoConnectAP")) {
    Serial.println("failed to connect and hit timeout");
    //reset and try again, or maybe put it to deep sleep
    ESP.restart();
    delay(5000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  ticker.detach();
  //keep LED on
  digitalWrite(LED, LOW);
  //read updated parameters
  strcpy(mqtt_server, custom_mqtt_server.getValue());
  strcpy(mqtt_port, custom_mqtt_port.getValue());
  strcpy(blynk_token, custom_blynk_token.getValue());

  //save the custom parameters to FS
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["mqtt_server"] = mqtt_server;
    json["mqtt_port"] = mqtt_port;
    json["blynk_token"] = blynk_token;

    json["ip"] = WiFi.localIP().toString();
    json["gateway"] = WiFi.gatewayIP().toString();
    json["subnet"] = WiFi.subnetMask().toString();

    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }

    json.prettyPrintTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }

  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  Serial.println(WiFi.gatewayIP());
  Serial.println(WiFi.subnetMask());
  //Star seting up MQTT Adafruit_MQTT_Client
  unsigned int MQTT_PORT = atoi (mqtt_port);
  char* MQTT_SERV = mqtt_server;

  //int init_size = strlen(blynk_token);
  //char* MQTT_NAME_LEN = strchr(blynk_token , ',');
  //char* MQTT_NAME = blynk_token.substring(0, MQTT_NAME_LEN-blynk_token+1);
  //char* MQTT_PASS = blynk_token.substring(MQTT_NAME_LEN-blynk_token+2 , init_size);
  char *strings[2];
  char *ptr = NULL;
  byte index = 0;
  ptr = strtok(blynk_token, ",");  // takes a list of delimiters
  while (ptr != NULL)
  {
    strings[index] = ptr;
    index++;
    ptr = strtok(NULL, ",");  // takes a list of delimiters
  }

  char* MQTT_NAME = strings[0];
  char* MQTT_PASS = strings[1];

  char* feed = "/f/openClose";
  //int mqtt_name_len = S_MQTT_NAME.length() + feed.length() +1;
  char* MQTT_NAME_FEED;
  strcpy(MQTT_NAME_FEED, MQTT_NAME);
  strcat(MQTT_NAME_FEED, feed);
  puts(MQTT_NAME_FEED);
  Serial.println("adafruit config");
  Serial.println(MQTT_SERV);
  Serial.println(MQTT_PORT);
  Serial.println(MQTT_NAME);
  Serial.println(MQTT_NAME_FEED);
  Serial.println(MQTT_PASS);
}

void loop() {
  // put your main code here, to run repeatedly:

}

it complies ok and run well until I press save on the AP then it just print series of hex code over and over again I am posting one cycle of serial output file is one cycle after the last line start from top
I have to wait 5 minutes before I can post again

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3664, room 16 
tail 0
chksum 0xee
csum 0xee
vcc1cc0b2
~ld
mounting FS...
mounted file system
reading config file
opened config file
{"mqtt_server":"Servername","mqtt_port":"8080","blynk_token":"Myname,2456fghjhvfdddfggh","ip":"10.0.1.56","gateway":"10.0.1.1","subnet":"255.255.255.0"}
parsed json
setting custom ip from config
10.0.1.56
10.0.1.56
Myname,2456fghjhvfdddfggh
Servername
*WM: [3] allocating params bytes: 20
*WM: [2] Added Parameter: server
*WM: [2] Added Parameter: port
*WM: [2] Added Parameter: blynk
*WM: [1] AutoConnect 
*WM: [2] Connecting as wifi client... 
*WM: [3] STA static IP: 10.0.1.56
*WM: [2] Custom static IP/GW/Subnet/DNS 
*WM: [2] Custom STA IP/GW/Subnet 
*WM: [1] STA IP set: 10.0.1.56
*WM: [1] Connecting to SAVED AP: WiFi-F4B0
*WM: [3] Using Password: 49*****
*WM: [3] WiFi station enable 
*WM: [3] enableSTA PERSISTENT ON 
*WM: [1] connectTimeout not set, ESP waitForConnectResult... 
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] AutoConnect: SUCCESS 
*WM: [1] STA IP Address: 10.0.1.56
connected...yeey :)
local ip
10.0.1.56
10.0.1.1
255.255.255.0

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (29):
epc1=0x4021f387 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffb70 end: 3fffffc0 offset: 0190
3ffffd00:  3ffe88d0 00ffffff 0101000a 4021b994  
3ffffd10:  3ffe88d0 00001f90 3ffeef08 40202e8f  
3ffffd20:  00000000 00000000 3fff07bc 3fff07bf  
3ffffd30:  3fff07c0 3fff0794 3fff07a4 3fff07a4  
3ffffd40:  3fff07ac 3fff07b8 3fff07b8 4021a540  
3ffffd50:  00000000 4021a540 00000000 4021a540  
3ffffd60:  00000000 4021a540 3801000a 4021a540  
3ffffd70:  0101000a 4021a540 00ffffff 4021a540  
3ffffd80:  00000000 feef5035 6e2d6f6e fe007465  
3ffffd90:  86efeffe feefef00 feefeffe 80efeffe  
3ffffda0:  feefef00 feefeffe 80efeffe feefef00  
3ffffdb0:  feefeffe 80efeffe 00000000 00000000  
3ffffdc0:  00000000 00000000 00000000 00000001  
3ffffdd0:  00505345 feefeffe 83efeffe feefef03  
3ffffde0:  00000000 00000000 00000000 000007d0  
3ffffdf0:  00010000 00000000 0050ef00 feefef07  
3ffffe00:  00000008 00000000 00000000 01000001  
3ffffe10:  00010101 01010001 feef0100 3ffe86ea  
3ffffe20:  3ffe86ea feefef00 feefeffe 80efeffe  
3ffffe30:  feef0001 00007530 feefef00 feefef00  
3ffffe40:  feefeffe 80efeffe feef0100 00000000  
3ffffe50:  feef0100 00000000 00000003 00000005  
3ffffe60:  3fff07c4 feef0301 3ffeef08 40201264  
3ffffe70:  3ffe8538 40219810 402197fc feefeffe  
3ffffe80:  feefeffe 00000000 feefeffe feefeffe  
3ffffe90:  feefeffe 00000000 feefeffe feefeffe  
3ffffea0:  feefeffe 00000000 feefeffe feefeffe  
3ffffeb0:  feefeffe 00000000 feefeffe feefeffe  
3ffffec0:  feefeffe 00000000 feefeffe 3ffe8548  
3ffffed0:  3ffe854f 40219810 402197fc feefeffe  
3ffffee0:  feefeffe feefeffe feefeffe feefeffe  
3ffffef0:  3ffe8831 3ffe8837 3fff0744 00000046  
3fffff00:  00000001 3ffe86ea 3ffe882c 3ffe8827  
3fffff10:  3fff0734 00000005 00000001 3ffe86ea  
3fffff20:  3ffe8820 3ffe881b 3fff0704 00000028  
3fffff30:  00000001 3ffe86ea 4021a540 0101000a  
3fffff40:  feefeffe feefeffe 4021a540 3801000a  
3fffff50:  feefeffe feefeffe feefeffe feefeffe  
3fffff60:  feefeffe 4021a540 00ffffff 4021a540  
3fffff70:  0101000a 4021a540 3801000a feefeffe  
3fffff80:  feefeffe feefeffe 3ffe854f feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3ffef03c  
3fffffa0:  3fffdad0 00000000 3ffeeff8 402109b0  
3fffffb0:  feefeffe feefeffe 3ffe85ac 40100ced  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
  char* MQTT_NAME_FEED;

A string pointer, not initialized to anything.

  strcpy(MQTT_NAME_FEED, MQTT_NAME);
  strcat(MQTT_NAME_FEED, feed);

Writing to random memory, whatever the uninitialised string pointer happens to be pointing at.

I showed you how to allocate a buffer for this properly in an earlier post. See #45

I couldn't believe it pcbpc. I had to try it several times. such a small thing created a big headache
thanks a lot

Thanks to pcbbc, wildbill and PaulMurrayCbr.

your contribution and help resolve the issue. it was combinations of lib conflict , bad coding and not being familiar with Arduino.

Cheers guys I am closing this post

The issue is now back
OP1= new Adafruit_MQTT_Subscribe(mqtt, MQTT_FEED1);

I have been trying to construct MQTT_FEED to include account name and feed

account name is uploaded from WiFiconfig in to string(0).

....
  WiFiClient client;

  Adafruit_MQTT_Client *mqtt;
  Adafruit_MQTT_Subscribe *OP1;
....
void setup () {
.....
  char *strings[2];
  string[0] = "behmadi"
  const char* MQTT_NAME  = strings[0];

  const char* feed1 =  "/feeds/op1";
  char MQTT_NAME_FEED1[20] = "\0";
  strcat(MQTT_NAME_FEED1,MQTT_NAME);
 
  strcat(MQTT_NAME_FEED1,feed1);
  delay(200);
  String s1((const __FlashStringHelper*) MQTT_NAME_FEED1);
  const char* MQTT_FEED1 = s1.c_str();
   Serial.println(MQTT_FEED1); //"prints -- behmadi/feeds/op1 ---- in serial monitor
......
   mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME, MQTT_PASS);
   OP1 = new Adafruit_MQTT_Subscribe(mqtt, MQTT_NAME_FEED1);
   mqtt->subscribe(OP1);
....
}

I have tried many ways combining the two, all attempt resulted the combined "behmadi/feeds/op1" in my serial print.
My IO dashboard displays
"MQTT ERROR: rejected, not a valid topic format"
or
"MQTT ERROR: aedes_FNQbOxBN9C9T 60.240.148.110 PUBLISH to topic rejected, topic is not a recognized format"

if I change " const char* MQTT_FEED1 = s1.c_str(); " line in above code to "const char* MQTT_FEED1 = "behmadi/feeds/op1;"

it works perfectly

if I use "OP1= new Adafruit_MQTT_Subscribe(mqtt, MQTT_NAME "/feeds/op1"); it results in compile error "expected ')' before string constant"

anyone knows how to construct this to include username and feed

You seem to be tying yourself in an awful mess...

// no idea what this array is for since you are just populating it with a pointer to one static string
  char *strings[2];
// missing semicolon
  string[0] = "behmadi"
// why do you need this variable? Anywhere you want this just write strings[0] or indeed "behmadi"
  const char* MQTT_NAME  = strings[0];
// why do you need this variable... 
  const char* feed1 =  "/feeds/op1";
  char MQTT_NAME_FEED1[20] = "\0";
  strcat(MQTT_NAME_FEED1,MQTT_NAME);
// just write strcat(MQTT_NAME_FEED1, "/feeds/op1"); here
  strcat(MQTT_NAME_FEED1,feed1);
  delay(200);
// no idea what this nonsense is all about. No strings in flash here...
// as far as I can see Serial.println(MQTT_NAME_FEED1); would have been fine
  String s1((const __FlashStringHelper*) MQTT_NAME_FEED1);
  const char* MQTT_FEED1 = s1.c_str();
   Serial.println(MQTT_FEED1); //"prints -- behmadi/feeds/op1 ---- in serial monitor
// my guess is there is probably something important here you don’t show us
// or just that the whole unfathomable mess above broke something
......
   mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME, MQTT_PASS);
   OP1 = new Adafruit_MQTT_Subscribe(mqtt, MQTT_NAME_FEED1);
   mqtt->subscribe(OP1);
....

This really isn’t rocket science. Define some char[] buffers of suitable size, copy the strings you want into them with strcpy and/or strcat, call the required functions.

And why you feel the need to use the same names for the parameters (all upper case) when the are no longer #defines is beyond me.

But anyway, why not just...

mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERV, MQTT_PORT,  "behmadi", MQTT_PASS);
OP1 = new Adafruit_MQTT_Subscribe(mqtt,  "behmadi/feeds/op1");
mqtt->subscribe(OP1);

if I use "OP1= new Adafruit_MQTT_Subscribe(mqtt, MQTT_NAME "/feeds/op1"); it results in compile error "expected ')' before string constant"

Yes, this syntax only works when you have...

#define MQTT_NAME "behmadi"

Because it then effectively becomes...

OP1= new Adafruit_MQTT_Subscribe(mqtt, "behmadi" "/feeds/op1");

Which the compiler then treats as...

OP1= new Adafruit_MQTT_Subscribe(mqtt, "behmadi/feeds/op1");

But you cannot combine runtime strings this way.

Thanks for your reply

username is from

// The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
  WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 5);
  WiFiManagerParameter custom_blynk_token("blynk", "user name,blynk token", blynk_token, 70);

when configured, custom_blynk_token has both username and token

once they get separated in to const char* MQTT_NAME and char* MQTT_PASS

MQTT_NAME need to be combined to /feeds/op1

MQTT_NAME works in (eg:behmadi")

mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME, MQTT_PASS);

and connects to adafruit IO

why can't be combined to /feeds/op1 to create

I need to enter log in as different username