STM32 compile error PubSubClient callback

I'm using the PubSubClient to communicate from board to PC. I have a callback function which is compiling for the Uno (and working before I bricked it) but when trying to compile for the Nucleo I get this error.

"exit status 1
invalid conversion from 'byte*' {aka 'unsigned char*'} to 'const char*' [-fpermissive]" - highlighting the strtoul line

This is the function in question

void callback(char* topic, byte *payload, unsigned int length) {


unsigned long intervalLong;
  byte* p = (byte*)malloc(length);
  // Copy the payload to the new buffer
  memcpy(p,payload,length);
  client.publish("outputs", p, length);
  intervalLong = strtoul(p, NULL, 10);
  relayInterval = intervalLong;
 // Serial.print("Interval is: ");
 // Serial.println(relayInterval);
 // Serial.print("Tester: ");
 // Serial.println(tester);
  // Free the memory
  free(p);
}

Bump for visibility.

Try casting p to const char* as it's asking for.

I don’t know how to do that unfortunately, I’ve tried various things and I’m getting nowhere.

I tried to go a different route because I read that char* is the same as a char array, so I tried to convert it like this.

void callback(char* topic, byte* payload, unsigned int length) {
  unsigned long intervalLong;
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
   byte* p = (byte*)malloc(length);
  // Copy the payload to the new buffer
  memcpy(p,payload,length);
  client.publish("outTopic", p, length);
  for(int i = 0; i < length; i++) {
    intervalLong = ((unsigned long)p[i]);
  }
  Serial.print(intervalLong);
  // Free the memory
  free(p);
  
  Serial.println();
}

This compiles but it’s obviously not right - I’ve send it random numbers and it seems to return 48, I’ve sent it strings and it returns varying numbers also.

I just want to be able to alter my unsigned long value over the network.

try:

  intervalLong = strtoul((const char*)p, NULL, 10);

wildbill:
try:

  intervalLong = strtoul((const char*)p, NULL, 10);

Thanks man, I was sure I’d tried that, I must have missed the * on it. Still struggling to get my head around the pointers.

Cheers