2025-06-27 00:32:57 +08:00
|
|
|
|
#include "ble_demo.h"
|
|
|
|
|
#include "ble_rpc.h"
|
2025-10-18 13:58:40 +08:00
|
|
|
|
#include "rtthread.h"
|
|
|
|
|
#include "stdio.h"
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
|
|
static void test_thread(void *t);
|
2025-10-18 13:58:40 +08:00
|
|
|
|
void test_init(void) {
|
2025-06-27 00:32:57 +08:00
|
|
|
|
rt_thread_t t;
|
2025-10-18 13:58:40 +08:00
|
|
|
|
// t=rt_thread_create("test_thread", test_thread, RT_NULL, 2048, 15, 20);
|
|
|
|
|
// rt_thread_startup(t);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
static void test_thread(void *t) {
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
ble_struct *ble = malloc(sizeof(ble_struct));
|
2025-06-27 00:32:57 +08:00
|
|
|
|
ble_init(ble);
|
2025-10-18 13:58:40 +08:00
|
|
|
|
ble_set_name(ble, "ble_test");
|
2025-06-27 00:32:57 +08:00
|
|
|
|
ble_set_slave(ble);
|
2025-10-18 13:58:40 +08:00
|
|
|
|
ble_set_data_transport(ble, 1);
|
|
|
|
|
char *rx_table = malloc(128);
|
|
|
|
|
rpc_get_help(ble, rx_table, 0);
|
|
|
|
|
printf("%s\r\n", rx_table);
|
|
|
|
|
rpc_get_help(ble, rx_table, 1);
|
|
|
|
|
printf("%s\r\n", rx_table);
|
|
|
|
|
rpc_get_help(ble, rx_table, 2);
|
|
|
|
|
printf("%s\r\n", rx_table);
|
|
|
|
|
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int out;
|
2025-10-18 13:58:40 +08:00
|
|
|
|
int a = 0, b = 0;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int rc;
|
2025-10-18 13:58:40 +08:00
|
|
|
|
while (1) {
|
|
|
|
|
rc = rpc_get_fun1(ble, &out, a, b);
|
|
|
|
|
// sprintf(rx_table,"rc=%d,a=%d,b=%d,out=%d\r\n",rc,a,b,out);
|
|
|
|
|
// printf("rc=%d,a=%d,b=%d,out=%d\r\n",rc,a,b,out);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2025-10-18 13:58:40 +08:00
|
|
|
|
// ble_send_data(ble,1,(uint8_t *)rx_table,strlen(rx_table));
|
|
|
|
|
rpc_set_fun2(ble, 1);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
rt_thread_delay(500);
|
2025-10-18 13:58:40 +08:00
|
|
|
|
rpc_set_fun2(ble, 0);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
rt_thread_delay(500);
|
2025-10-18 13:58:40 +08:00
|
|
|
|
a += 1;
|
|
|
|
|
b += 2;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|