Skip to main content
edited tags
Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59
Source Link

How can I assign the value of a char array to a uint8_t array?

I have a char array variable that has a value. I need to send this value through LoRa. The library I use for the LoRa implementation accepts an array of uint8_t. How can I pass the value of a char[] to a uint8_t[] variable (and the opposite)?

if (Udp.parsePacket()) {
  int udp_received = Udp.available();
  char udp_buffer[udp_received + 1];
  Udp.read(udp_buffer, udp_received);
  udp_buffer[udp_received] = '\0';

  uint8_t udp_to_lora[] = "???";
  rf95.send(udp_to_lora, sizeof(udp_to_lora));
  rf95.waitPacketSent();

}

I need to pass the udp_buffer to uint8_t udp_to_lora[].