Topic

FAQ
Login Register
Bluetooth - JSON data exchange
Feb 20, 2023 03:42

/

A

/A


Hi everyone,

I designed my own PCB. I don't use any kit. I downloaded the SDK for a single connection. This set contains a lot of examples. I chose "B85m_sample" but this example runs a HID device. Also, my mobile phone cannot connect to my device.
My project assumes a simple data exchange between my device and the mobile application. The data will be sent in JSON format.
Can anyone point me the way which example from SDK is best to use? How to configure "define" sets to prepare the device for simple communication (not as HID)?


Now my configuration is:

/////////////////// FEATURE SELECT /////////////////////////////////

#define BLE_REMOTE_PM_ENABLE 0

#define PM_DEEPSLEEP_RETENTION_ENABLE 0

#define BLE_REMOTE_SECURITY_ENABLE 0

#define BLE_REMOTE_OTA_ENABLE 0

#define REMOTE_IR_ENABLE 0

#define REMOTE_IR_LEARN_ENABLE 0

#define BATT_CHECK_ENABLE 0 //must enable       I disabled it becouse i don't use battery

#define BLE_AUDIO_ENABLE 0

#define BLT_APP_LED_ENABLE 0

#define BLT_TEST_SOFT_TIMER_ENABLE 0

#define UNUSED_GPIO_PULLDOWN_ENABLE 0

#define FIRMWARE_CHECK_ENABLE 0 //flash firmware_check

#define FIRMWARES_SIGNATURE_ENABLE 0 //firmware check

#define AUDIO_TRANS_USE_2M_PHY_ENABLE 0


Thanks for the answers.

Best regards.



4 replies
TL_Soyo Feb 20, 2023 14:12
0
/A

Hi, 

  you can use  b85m_module project,It provides the sample ble UART function(SPP),can use it to transmit JSON data,also,it is not support HID Servece.Of course you'd better visit the wiki to download the BLE hand book for more information about the project

wes58 Feb 20, 2023 14:35
0
/A

That's what I am doing to send data from the phone and send data back from TLSR chip:

I am not using json.


#define MTU_SIZE_SETTING 200
typedef enum{
ATT_H_START = 0,
...
...
...

//add this !!!!
//// Custom RxTx ////
/**********************************************************************************************/
RxTx_PS_H, //UUID: 2800, VALUE: 1F10 RxTx service uuid
RxTx_CMD_OUT_CD_H, //UUID: 2803, VALUE: Prop: read | write_without_rsp
RxTx_CMD_OUT_DP_H, //UUID: 1F1F, VALUE: RxTxData
RxTx_CMD_OUT_DESC_H, //UUID: 2902, VALUE: RxTxValueInCCC
ATT_END_H,
}ATT_HANDLE;
// RxTx Char
const u16 my_RxTxUUID = 0x1f1f;
const u16 my_RxTx_ServiceUUID = 0x1f10;
RAM u8 my_RxTx_Data[16];
RAM u8 RxTxValueInCCC[2];
//// RxTx attribute values
static const u8 my_RxTxCharVal[5] = {
CHAR_PROP_READ | CHAR_PROP_NOTIFY | CHAR_PROP_WRITE_WITHOUT_RSP,
U16_LO(RxTx_CMD_OUT_DP_H), U16_HI(RxTx_CMD_OUT_DP_H),
U16_LO(0x1f1f), U16_HI(0x1f1f)
};
// Include attribute (Battery service)
//static u16 include[3] = {BATT_PS_H, BATT_LEVEL_INPUT_CCB_H, SERVICE_UUID_BATTERY};
const attribute_t my_Attributes[] = {
{ATT_END_H - 1, 0,0,0,0,0}, // total num of attribute
...
...
...
//add this !!!
////////////////////////////////////// RxTx ////////////////////////////////////////////////////
// RxTx Communication
{4,ATT_PERMISSIONS_READ,2,2,(u8*)(&my_primaryServiceUUID), (u8*)(&my_RxTx_ServiceUUID), 0},
{0,ATT_PERMISSIONS_READ, 2,sizeof(my_RxTxCharVal),(u8*)(&my_characterUUID), (u8*)(my_RxTxCharVal), 0}, //prop
{0,ATT_PERMISSIONS_RDWR, 2,sizeof(my_RxTx_Data),(u8*)(&my_RxTxUUID), (u8*)&my_RxTx_Data, &RxTxWrite, 0},
{0,ATT_PERMISSIONS_RDWR, 2,sizeof(RxTxValueInCCC),(u8*)(&clientCharacterCfgUUID), (u8*)(RxTxValueInCCC), 0}, //value
};
//send ble data
void ble_send_Notify(u8 * pu8Data, int length){
if(device_in_connection_state == 1){ // connected
int n;
u8 txBuf[30];
u8 *p = txBuf;
for(n = 0; n < length; n++){
*p++ = pu8Data[n];
}
bls_att_pushNotifyData(RxTx_CMD_OUT_DP_H, txBuf, length);
}
}
//receive ble data
static int RxTxWrite(void * p){
rf_packet_att_data_t *req = (rf_packet_att_data_t*)p;
u8 len = req->rf_len - 9;
u8 cmd = req->dat[1];
//received data in req->data[]
return 0;
}
void user_ble_init(void){
...
...
//set mtu size if you want to receive send large data
blc_att_setRxMtuSize(MTU_SIZE_SETTING);
...

}

krzysztof [Author] Feb 20, 2023 19:17
0
/A

Thank you so match wes58,

which example do you use? B85m_sample or maybe B85_modul?


Best regards

wes58 Feb 21, 2023 13:37
0
/A

It has been a while since I used BLE SDK, but at the time I think I used feature_test example. Currently I am using the same code with ZigBee BLE concurrent SDK So, I think is should work with any example where your device is a Slave.