esp32 compile errors,

Im getting errors i normally do not get when compiling for esp8266,

sketch_sep13a:63:22: error: cast from 'char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]

   Udp.write((uint8_t)delimiter);

                      ^

sketch_sep13a:65:22: error: cast from 'char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]

   Udp.write((uint8_t)delimiter2);

                      ^

C:\Users\Laptop\Documents\Arduino\sketch_sep13a\sketch_sep13a.ino: In function 'void setup()':

sketch_sep13a:77:3: error: 'SPIFFS' was not declared in this scope

   SPIFFS.begin();

   ^
void sendCommand(IPAddress to, int data[], int size, char delimiter[], char delimiter2[]) {
  Udp.beginPacket(to, ServerPort);
  Udp.write((uint8_t)delimiter);
  Udp.write((byte *)data, size); //cast to bytes
  Udp.write((uint8_t)delimiter2);
  Udp.endPacket();
}

Whats wrong there

You told the compiler that delimiter is an array of char. Is it? I suspect not, but if it is, you can't cast that array to be a single byte.

wildbill:
You told the compiler that delimiter is an array of char. Is it? I suspect not, but if it is, you can't cast that array to be a single byte.

i tried multiple different way always ending in a conversion error, i dont know what to do,

void sendCommand(IPAddress to, int data[], int size, char delimiter[], char delimiter2[]) {
  Udp.beginPacket(to, ServerPort);
 // Udp.write(const char "hi");
 // Udp.write((byte *)data, size); //cast to bytes
 Udp.write(delimiter2);
  Udp.endPacket();
}

if i try to write a number it works. i cant get any thing else to work

any other ideas?

Forum ate my post. Can you show how you call this function?

wildbill:
Forum ate my post. Can you show how you call this function?

i just delete that function for now. this function has the same problem,

void handleWTRT1S() {
    Serial.println("f1 water");
  Udp.beginPacket(Client6, ServerPort);
  Udp.write("WCT1F1");
  Udp.write("1F1TCW");
  Udp.endPacket();
    server.send(200, "text/plane", "");
}
C:\ArduinoTemp\sketch\WaterController.h:65:21: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]

   Udp.write("1F1TCW");

                     ^

Odd. I think you need to post more than a snippet - I can't tell what's wrong there.

Hopefully then someone (not me) who is set up to compile for your hardware can try it.

wildbill:
Odd. I think you need to post more than a snippet - I can't tell what's wrong there.

Hopefully then someone (not me) who is set up to compile for your hardware can try it.

thats about it for the code. the function simply udp.write

wildbill:
Odd. I think you need to post more than a snippet - I can't tell what's wrong there.

Hopefully then someone (not me) who is set up to compile for your hardware can try it.

here i have minimized it,

#include <EEPROM.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <ESP32WebServer.h>


IPAddress local_IP(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress sta_local_IP(10, 0, 0, 232);
IPAddress sta_gateway(10, 0, 0, 1);
IPAddress sta_subnet(255, 0, 0, 0);
IPAddress Client6(192, 168, 4, 7); //Water controller

WiFiUDP Udp;
const char* ssid = "LCS2";
const char* password = "a1b2c3d5";

unsigned int ServerPort = 4220;
unsigned int localUdpPort = 4210;

struct {
  char  sta_ssid[15];
  char  sta_password[15];
  char  system_password[15];

} _EEPROM;

void setup() {
  WiFi.persistent(0);
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(_EEPROM.sta_ssid, _EEPROM.sta_password);
  WiFi.config(sta_local_IP, sta_subnet, sta_gateway);
  WiFi.softAP(ssid, password, 9, false, 15);
  WiFi.softAPConfig(local_IP, local_IP, subnet);

  Udp.begin(localUdpPort);
}

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

}
void handleWTRT1S() {
  Udp.beginPacket(Client6, ServerPort);
  Udp.write("WCT1F1");
  Udp.write("1F1TCW");
  Udp.endPacket();
}
C:\Users\Laptop\Documents\Arduino\sketch_sep13b\sketch_sep13b.ino: In function 'void handleWTRT1S()':

sketch_sep13b:49:21: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]

   Udp.write("WCT1F1");

                     ^

In file included from C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFi.h:39:0,

                 from C:\Users\Laptop\Documents\Arduino\sketch_sep13b\sketch_sep13b.ino:2:

C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFiUdp.h:64:10: note:   initializing argument 1 of 'virtual size_t WiFiUDP::write(uint8_t)'

   size_t write(uint8_t);

          ^

sketch_sep13b:50:21: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]

   Udp.write("1F1TCW");

                     ^

In file included from C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFi.h:39:0,

                 from C:\Users\Laptop\Documents\Arduino\sketch_sep13b\sketch_sep13b.ino:2:

C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFiUdp.h:64:10: note:   initializing argument 1 of 'virtual size_t WiFiUDP::write(uint8_t)'

   size_t write(uint8_t);

          ^


Multiple libraries were found for "WiFi.h"
 Used: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
 Not used: C:\Users\Laptop\Documents\Arduino\libraries\WiFi
Using library EEPROM at version 1.0.3 in folder: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\EEPROM 
Using library WiFi at version 1.0 in folder: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi 
Using library ESP32WebServer-master at version 1.0 in folder: C:\Users\Laptop\Documents\Arduino\libraries\ESP32WebServer-master 
Using library FS at version 1.0 in folder: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS 
exit status 1
invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]

Your UDP library has two write methods:

size_t WiFiUDP::write(uint8_t byte)

size_t WiFiUDP::write(const uint8_t *buffer, size_t size)

You will need to use the second one here I think, but you will have to pass a size and likely cast the string too to mollify the compiler.

wildbill:
Your UDP library has two write methods:

size_t WiFiUDP::write(uint8_t byte)

size_t WiFiUDP::write(const uint8_t *buffer, size_t size)




You will need to use the second one here I think, but you will have to pass a size and likely cast the string too to mollify the compiler.

how am i suppose to pass this data as const uint8_t from "string" or char array[]?

Like this:

 Udp.write(const uint8_t *)"WCT1F1",strlen("WCT1F1"));

That's a pretty filthy hack though. Better to write a function that takes a string and does the casting and strlen in one place. Better still if it takes a reference to a WiFiUDP object as well.

wildbill:
Like this:

 Udp.write(const uint8_t *)"WCT1F1",strlen("WCT1F1"));

That's a pretty filthy hack though. Better to write a function that takes a string and does the casting and strlen in one place. Better still if it takes a reference to a WiFiUDP object as well.

thankyou