您好!
我将使用 CC2340R5 simplelink_lowpower_f3_sdk_7_40_00_64示例代码 basic_ble。
我正在使用外设模式与 APK 建立连接。 每当 APK 向 BLE 发送任何请求时、针对该请求、我需要将相同的请求写入与 BLE 的 UART 相连的控制器以进行响应。
控制器随后针对同一请求发送响应。
目前、我可以通过 UART_2向控制器发送请求、但无法读取 UART_2上发送的响应。
以下是我的 UART 配置代码:
1)这是我创建的 UART 初始化位置的线程。 (我从 Resource Explorer 中给出的示例代码 uart2callback 中获取参考。)
void mainThread()
{
char input;
const char echoPrompt[] = "Echoing characters:\r\n";
UART2_Params uartParams;
int32_t semStatus;
uint32_t status = UART2_STATUS_SUCCESS;
uint8_t tempbuf[64] = {0};
/* Create semaphore */
// semStatus = sem_init(&sem, 0, 0);
// if (semStatus != 0)
// {
// /* Error creating semaphore */
// // while (1) {}
// }
/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_CALLBACK;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 115200;
uart_handle = UART2_open(CONFIG_DISPLAY_UART, &uartParams);
}
2)这是回调函数。 不执行任何操作。
void callbackFxn(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
{
if (status != UART2_STATUS_SUCCESS)
{
/* RX error occured in UART2_read() */
// while (1) {}
}
numBytesRead = count;
// sem_post(&sem);
}
3) uart_handle 取全局。 我从 APK 中获取请求的位置调用这两个函数。
UART2_write(uart_handle, newValue, len, NULL);
UART2_read(uart_handle, newValue, sizeof(newValue), NULL);
在这里、UART 写入工作正常。 我在 UART 上得到的是准确的数据、但在读取时却找不到任何数据。
我已经禁用了 Menu_start()函数;
我在这里缺少什么吗?
此致、
Rushikesh。