Hi all
I have this issue it`s a chicken egg scenario:
1- I managed to setup a BT server as per the BT_SPP_ACCEPTOR example; it compiles and works no problem
2- I can also connect to the ACCEPTOR with the BT terminal on my Phone and send data; no problem
HERE is the issue
I want to send asynchronous data to the connected device BUT there is No WAY of sending data from say the UART0
for now I have a simple loop in app_main()
That tries to send hello world to the BT terminal; but I keep getting
BT_BTC: btc_spp_write unable to find RFCOMM slot!
More Info:
I create a global structure as follows >>>>>>>>> esp_spp_cb_param_t *paramT;
as soon as the BT App connects to the ACCEPTOR
static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
.....
case ESP_SPP_OPEN_EVT:
paramT = param;
break;
....
it copies the parameters to the structure; so now I have a complete BT structure:
This write works 100% from within the
static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
..
case ESP_SPP_DATA_IND_EVT:
printf("Val received:\r\n");
for(size_t i=0; i < (param->data_ind.len)-2; i++)
{
char val = param->data_ind.data;
printf("%c",val);
}
printf("\r\n");
sprintf(bda_str,"Hello\r\n");
esp_spp_write(param->data_ind.handle, strlen((const char*)bda_str), (u_int8_t *)bda_str);
waitWrite = true; //set a flag to say to main parms captured to test dummy write
..
HOWEVER it cannot write data to the BT from the app_main with the same parmT structure copied just now !!!!
..
while (1)
{
if(waitWrite == true)
{ printf("Wait true\r\n");
waitWrite = false;
sprintf(bda_str,"Dummy\r\n");
esp_spp_write(paramT->data_ind.handle, strlen(bda_str), (u_int8_t *)bda_str); //dummy write
}
vTaskDelay(5000/portTICK_PERIOD_MS);
}
NO WAY does it wants to write; YET from the function immediately after a receive it writes 100%
BT_BTC: btc_spp_write unable to find RFCOMM slot! from app_main
Please give some advise
Tx Ben
BT Classic SPP how to write async data error - BT_BTC: btc_spp_write unable to find RFCOMM slot!(solved)
Re: BT Classic SPP how to write async data error - BT_BTC: btc_spp_write unable to find RFCOMM slot!(solved)
So I managed to solve the issue
I was a simple matter of defining a variable
static uint32_t btHandle=0;
then filling it with the handle at the correct event
......
case ESP_SPP_START_EVT:
if (param->start.status == ESP_SPP_SUCCESS) {
btHandle = param->start.handle;
.....
Then the handle could be used as async transmitter; here in app_main() I have a loop that sends a counter to the BT Terminal on my phone once the connection is made...
while (1)
{
if(btHandle != 0 && waitWrite == true)
{
count++;
sprintf(bda_str,"Count:%d\r\n",count);
esp_spp_write(btHandle, strlen(bda_str), (u_int8_t *)bda_str); //dummy write
printf("%ld\r\n",btHandle);
}
vTaskDelay(500/portTICK_PERIOD_MS);
}
I was a simple matter of defining a variable
static uint32_t btHandle=0;
then filling it with the handle at the correct event
......
case ESP_SPP_START_EVT:
if (param->start.status == ESP_SPP_SUCCESS) {
btHandle = param->start.handle;
.....
Then the handle could be used as async transmitter; here in app_main() I have a loop that sends a counter to the BT Terminal on my phone once the connection is made...
while (1)
{
if(btHandle != 0 && waitWrite == true)
{
count++;
sprintf(bda_str,"Count:%d\r\n",count);
esp_spp_write(btHandle, strlen(bda_str), (u_int8_t *)bda_str); //dummy write
printf("%ld\r\n",btHandle);
}
vTaskDelay(500/portTICK_PERIOD_MS);
}
Who is online
Users browsing this forum: Gaston1980, Google [Bot], Majestic-12 [Bot] and 248 guests