Skip to main content
added 54 characters in body
Source Link
Avamander
  • 624
  • 2
  • 11
  • 35

I solved this problem. The reason for this is because main ardunioArduino is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code  :

iIn main ardunioArduino file you have to declare function like this :

extern "C" void TurnOn(); void TurnOn() { digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH); }

extern "C" void TurnOn();
void TurnOn()
{
    digitalWrite(RELAY_SONOFF, HIGH);     
    digitalWrite(LED_SONOFF, HIGH);
}

and use this function in c code  :

void TurnOn(); EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device) { (void)device; TurnOn(); (void)printf("Turning fan on.\r\n"); return EXECUTE_COMMAND_SUCCESS; }

void TurnOn();
EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device)
{
    (void)device;
    TurnOn();
    (void)printf("Turning fan on.\r\n");
    return EXECUTE_COMMAND_SUCCESS;
}

I solved this problem. The reason for this is because main ardunio is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code  :

i main ardunio file you have to declare function like this :

extern "C" void TurnOn(); void TurnOn() { digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH); }

and use this function in c code  :

void TurnOn(); EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device) { (void)device; TurnOn(); (void)printf("Turning fan on.\r\n"); return EXECUTE_COMMAND_SUCCESS; }

I solved this problem. The reason for this is because main Arduino is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code:

In main Arduino file you have to declare function like this :

extern "C" void TurnOn();
void TurnOn()
{
    digitalWrite(RELAY_SONOFF, HIGH);     
    digitalWrite(LED_SONOFF, HIGH);
}

and use this function in c code:

void TurnOn();
EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device)
{
    (void)device;
    TurnOn();
    (void)printf("Turning fan on.\r\n");
    return EXECUTE_COMMAND_SUCCESS;
}
Source Link

I solved this problem. The reason for this is because main ardunio is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code :

i main ardunio file you have to declare function like this :

extern "C" void TurnOn(); void TurnOn() { digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH); }

and use this function in c code :

void TurnOn(); EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device) { (void)device; TurnOn(); (void)printf("Turning fan on.\r\n"); return EXECUTE_COMMAND_SUCCESS; }