51 lines
992 B
C
51 lines
992 B
C
#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;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|