How to use SPI with ESP32 XBEEPROS2C?

Hi guys,
I am trying to use XBEE PRO S2C on SPI with ESP32 using arduino ide. Since I could not find any useful resource except the datasheet, I have been trying to send data to and read data from SPI while sending random data from coordinator device by XCTU. Unfortunately I am not able to do that. Is there any suggestion for me to code this task. Can you help how to use SPI of XBee using arduino (or ESP) ? To get at least raw data is something for me, almost got burnt out. My current code is given below.
Thanks,

EDIT: I connected XBee to both Arduino and ESP32 individually. But I failed to receive or send any data through SPI bus. What can I try? Xbee modules are working with XCTU software. Also I configured SPI pins.
When I send packets from one module to another using XCTU then try reading SPI bus of other module only 0xFF is coming from SPI as data.

Any example code will be useful.

#include “SPI.h”
void setup() {

Serial.begin(115200);
Serial.println(“well boot is successfull”);
while(1){
if(Serial.available()){
Serial.println(“something”);
SPI.begin(18,19,23,5);
//SPI.begin();
Serial.println(“spi has begun”);
break;
}}
}

void loop() {

static uint8_t transmit_header[] = {
0x7e,
0,0,
0x10,
0,
0,0,0,0, 0,0,0,0,
0,0,
0,
0,
};
static char buffer[255];
static int count = 0;
int len = sprintf(buffer, “Count: %d”, count++);
uint8_t check = 0x10;
transmit_header[1] = ((len+14)>>8)&0xff;
transmit_header[2] = ((len+14)>>0)&0xff;
for(int i = 0; i < len; i++) {
check += buffer[i];
}
SPI.transfer(transmit_header, 17);
SPI.transfer((uint8_t*)buffer, len);
SPI.transfer(0xff - check);
Serial.println(count);
Serial.println(SPI.transfer(007) );

delay(1000);
}

The XBee S2C SPI is a SPI slave device. You need to connect it to a SPI master device. Also all data going in and out of the XBee modules UART must use the XBee API interface.

I connected XBee to both Arduino and ESP32 individually. But I failed to receive or send any data through SPI bus. What can I try? Xbee modules are working with XCTU software. Also I configured SPI pins.

As indicated, the XBee module is a SPI slave device. Your Arduino needs to be a SPI Master device and the XBee module needs to have its SPI lines enabled. You also need to connect the SPI lines as well.

Okey those are the facts that we already know and wrote the code accordingly but unable to work with it. So do you have a suggestion when you look at the code snippet ?

This is a hardware issue. Both devices are SPI slave devices. You need to connect them to an SPI Master device to communicate that way.

You should check for XBee SPI library for Arduino Nano. If couldn’t then you have a chance to design one. It wouldn’t be that difficult simple SPI communication.

There is absolutely no documentation for SPI communication on Digi’s website or XBee Pro S2C’s datasheet.