This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: Declaring callback functions as member function of a class in C++, LWIP TCP.

Part Number: MSP432E401Y

I am getting an error when setting up the callback functions, I am trying to add TCP to existing C++ code, I want to place the call back functions within my Class.

 I am getting the error :

nonstandard form for taking the address of a member function

argument of type "void (ModemManager::*)(void *, err_t)" is incompatible with parameter of type "tcp_err_fn"

when calling tcp_recv(newpcb,echo_recv);

Here is my code:

err_t ModemManager::echo_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
{
err_t ret_err;
static struct echo_state *es;
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);

/* commonly observed practive to call tcp_setprio(), why? */
tcp_setprio(newpcb, TCP_PRIO_MIN);
// ModemOn = true;
es = (struct echo_state *)mem_malloc(sizeof(struct echo_state));
if (es != NULL)
{
es->state = ES_ACCEPTED;
es->pcb = newpcb;
es->retries = 0;
es->p = NULL;
/* pass newly allocated es to our callbacks */

tcp_arg(newpcb, es);
tcp_recv(newpcb,echo_recv);  // error here
tcp_err(newpcb, echo_error); // error here
tcp_sent(newpcb, echo_sent);// error here


char modemtest[3] = {'A' , 'C', 'K'};
char *ptrdata = modemtest;
tcp_write(newpcb, ptrdata,3, 1);
//ModemOn = true;

ret_err = ERR_OK;
}
else
{
ret_err = ERR_MEM;
}
return ret_err;
}

class ModemManager : public Manager
{
public:
ModemManager();
virtual ~ModemManager();
void process(TransitPacket::PacketType type, vector<char> data, struct tcp_pcb *tpcb);
err_t echo_accept(void *arg, struct tcp_pcb *newpcb, err_t err);
void echo_init(void);
err_t echo_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
void echo_error(void *arg, err_t err);
err_t echo_sent(void *arg, struct tcp_pcb *tpcb, u16_t len);

enum echo_states
{
ES_NONE = 0,
ES_ACCEPTED,
ES_RECEIVED,
ES_CLOSING
};

struct echo_state
{
u8_t state;
u8_t retries;
struct tcp_pcb *pcb;
/* pbuf (chain) to recycle */
struct pbuf *p;
};

};