another non-class type errpr question

Hi,
It seems the error for a non-class type happens a lot. I haven't found an answer to my particular instance. I'm trying to parse UDP strings for setting pwm outputs for led dimming. Should be an easy
task, but I keep getting the dreaded non-class type error. The error says "request for member 'substring' in 'packetBuffer', which is of non-class type 'char [20]'
'
I've tried various parsing methods and they all give the same type of error. Any help would be greatly appreciated. Thanks.

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
//int level = 0;
#define Dim1 12
// wifi connection variables
const char* ssid = "VIRUS DEMON";
const char* password = "765432112367890";
boolean wifiConnected = false;

// NETWORK: Static IP details...
IPAddress ip(192, 168, 123, 35);
IPAddress gateway(192, 168, 123, 1);
IPAddress subnet(255, 255, 255, 0);

// UDP variables
unsigned int localPort = 1234;
WiFiUDP UDP;
boolean udpConnected = false;
char packetBuffer[20]; //buffer to hold incoming packet,
char newbuffer[10];
char ReplyBuffer[] = "acknowledged"; // a string to send back
char load, brightness;
void setup() {
// Initialise Serial connection
Serial.begin(115200);
pinMode(Dim1, OUTPUT);
analogWrite(Dim1, 0);
analogWriteRange(255);
WiFi.config(ip, gateway, subnet);

// Initialise wifi connection
wifiConnected = connectWifi();

// only proceed if wifi connection successful
if(wifiConnected){
udpConnected = connectUDP();

}
}

void loop() {
// check if the WiFi and UDP connections were successful
if(wifiConnected){
if(udpConnected){

// if there’s data available, read a packet
int packetSize = UDP.parsePacket();
if(packetSize)
{
Serial.println("");
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = UDP.remoteIP();
for (int i =0; i < 4; i++)
{
Serial.print(remote[i], DEC);
if (i < 3)
{
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(UDP.remotePort());

// read the packet into packetBufffer
UDP.read(packetBuffer,20);
Serial.println("Contents:");
Serial.println(packetBuffer);
if(strstr(packetBuffer,"one")){
for (int i = 0; i < 10; i++) {
  if (packetBuffer.substring(i, i+1) == ",") {
   load = packetBuffer.substring(0, i).toInt();           These two lines are that are making the error
   brightness = packetBuffer.substring(i+1).toInt();
    break;
  }
}

//level=atoi(brightness);
analogWrite(Dim1,brightness);  
}

for( int i = 0; i < 20;  ++i )// clear the buffer
   packetBuffer[i] = (char)0;

// send a reply, to the IP address and port that sent us the packet we received
UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
UDP.write(ReplyBuffer);
UDP.endPacket();


}
delay(10);

}

}

}

// connect to UDP – returns true if successful or false if not
boolean connectUDP(){
boolean state = false;

Serial.println("");
Serial.println("Connecting to UDP");

if(UDP.begin(localPort) == 1){
Serial.println("Connection successful");
state = true;
}
else{
Serial.println("Connection failed");
}

return state;
}
// connect to wifi – returns true if successful or false if not
boolean connectWifi(){
boolean state = true;
int i = 0;
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");

// Wait for connection
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 10){
state = false;
break;
}
i++;
}
if (state){
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("");
Serial.println("Connection failed.");
}
return state;
}

substring may be used with a variable of type String, but packetBuffer is not of that type. Don't do this:

packetBuffer.substring(i, i+1)

Oh, and avoid using String. It is wasteful and harmful on most Arduinos.

UNTESTED: You might try:

 packetBuffer[i]

as in

  if (packetBuffer[i] == ',') {
   load = atoi(packetBuffer) ;
   brightness = atoi(packetBuffer[i+1]) ;

After all, packetBuffer is an array of characters and should be treated as an array.

Be a good boy and repost your code - BUT THIS TIME AUTO FORMAT IT FIRST!

Second post the error message!

Mark