Files
player/Project/Src/MyApp/ble_rpc.c
2025-07-05 19:47:28 +08:00

51 lines
968 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "ble_rpc.h"
#include "ble_demo.h"
#include "string.h"
// 获取指定index函数的帮助请保证str的空间大于128
int rpc_get_help(void *obj,char *str,int index)
{
int rx_len=128;
int rc;
uint8_t tx_table[sizeof(int)+1];
tx_table[0]=0x00;//get_help函数的序号是0
memcpy(&tx_table[1],&index,sizeof(index));
rc=ble_user_cmd_get(obj,tx_table,sizeof(tx_table),(uint8_t *)str,&rx_len);
return rc;
}
int rpc_get_fun1(void *obj,int *out,int a,int b)
{
int rx_len=sizeof(int);
int rc;
uint8_t tx_table[sizeof(int)+sizeof(int)+1];
tx_table[0]=0x01;
memcpy(&tx_table[1],&a,sizeof(int));
memcpy(&tx_table[1+sizeof(int)],&b,sizeof(int));
rc=ble_user_cmd_get(obj,tx_table,sizeof(tx_table),(uint8_t *)out,&rx_len);
return rc;
}
int rpc_set_fun2(void *obj,int a)
{
int rc;
uint8_t tx_table[sizeof(int)+1];
tx_table[0]=0x02;
memcpy(&tx_table[1],&a,sizeof(int));
rc=ble_user_cmd_set(obj,tx_table,sizeof(tx_table));
return rc;
}