ESP32-S3-Wroom and RF95 custom firmware

I have a board that already has an ESP32-S3-Wroom module and the RF95 lora board. However, I am doing something wrong with building the firmware…

Here is the URL to the schematics: https://raw.githubusercontent.com/Makerfabs/SenseLora-4G-Gateway/refs/heads/main/hardware/SenseLora%204G%20Gateway.png

Here is the URL to working Arduino code: SenseLora-4G-Gateway/example/Send_lora_data_to_datacake/Send_lora_data_to_datacake.ino at main · Makerfabs/SenseLora-4G-Gateway · GitHub

So I know the pins that I need to use. However, after I flash the device, the console log is just full of the following. I am able to see the device in the Android meshtastic app, but I can’t connect to it. If I have the app open, the following keep repeating. If I close the app, the log stops.

start advertising
*** App connected
55:63:36:8c:ef:ff
main loop started
*** App disconnected
start advertising
*** App connected
4a:66:b8:b8:b7:27
main loop started
*** App disconnected
start advertising
*** App connected
74:8c:c6:73:2c:c3
main loop started
*** App disconnected

Here is my platformio.ini file:

[env:private_hw]
extends = esp32_base
board = esp32doit-devkit-v1
build_flags =
  ${esp32_base.build_flags}
  -D PRIVATE_HW
  -faligned-new
  -std=c++17  ; Ensure C++17 standard
  -I variants/private_hw

Here is my variant.h file:

#ifndef PRIVATE_HW_VARIANT_H
#define PRIVATE_HW_VARIANT_H

// LoRa (SX1276/RF95) Pin Definitions
#define LORA_MOSI 11           // SPI MOSI for LoRa
#define LORA_MISO 13           // SPI MISO for LoRa
#define LORA_SCK 12            // SPI Clock for LoRa
#define LORA_CS 4              // LoRa Chip Select
#define LORA_RST 5             // LoRa Reset
#define LORA_DIO0 6            // LoRa DIO0
#define LORA_DIO1 7            // LoRa DIO1

// Additional parameters for LoRa radio module
#define FREQUENCY 868          // LoRa frequency in MHz
#define BANDWIDTH 125.0        // LoRa bandwidth in kHz
#define SPREADING_FACTOR 12    // LoRa spreading factor
#define CODING_RATE 6          // LoRa coding rate
#define OUTPUT_POWER 20        // LoRa output power in dBm
#define PREAMBLE_LEN 8         // LoRa preamble length
#define GAIN 0                 // LoRa gain

#define LORA_RESET LORA_RST  // Alias LORA_RESET to LORA_RST

// Use the RF95 module for LoRa
#define USE_RF95

// Other optional components for power, buttons, or sensors could go here

#endif // PRIVATE_HW_VARIANT_H

Can anyone help me identify what I might be doing wrong?

Making progress. I am now communicating with the radio, but it is unable to transmit:

INFO | 03:17:25 36 Telling client we have new packets 5

INFO | 03:17:25 36 BLE notify fromNum

DEBUG | 03:17:25 36 [RadioIf] Starting low level send (id=0xdd12d84a fr=0x94 to=0xff, WantAck=0, HopLim=3 Ch=0x8 encrypted rxtime=1728962245 hopStart=3 priority=10)

ERROR | 03:17:25 36 [RadioIf] startTransmit failed, error=-16

ERROR | 03:17:25 36 [RadioIf] NOTE! Recording critical error 11 at src/mesh/RadioLibInterface.cpp:481

DEBUG | 03:17:25 36 [RadioIf] Completed sending (id=0xdd12d84a fr=0x94 to=0xff, WantAck=0, HopLim=3 Ch=0x8 encrypted rxtime=1728962245 hopStart=3 priority=10)

INFO | 03:17:25 36 [RadioIf] getFromRadio=STATE_SEND_PACKETS

ERROR | 03:17:25 36 [RadioIf] Panic: can’t encode protobuf reason=‘bytes size exceeded’