256KB数据传输通过BLE,DA14681

Learn More常见问题解答教程

8 posts / 0 new
最后一篇
Mahmed106.
离线
最后一次露面:1 month 1 week ago
加入:2019-05-03 17:28
256KB数据传输通过BLE,DA14681

嗨对话框

我们正在使用基于DA14681的自定义板。在我们的应用程序中,正常的Scnerio是设备记录温度并将其存储在EEPROM中。在用户使用BLE应用程序连接设备后几天后。所有脱机数据都被转移到手机。

Our eeprom size is 256KB and packet size is 10 Bytes, so we need to send 25600 packets, and right now we are transferring data via a BLE service.

Here is the flow :

1 - Mobile app makes the connection with the device.

2 - 移动应用请求读取特定服务的读取特性。

3 - DA14681返回请求的数据字节。

因此,移动应用程序不断使读取请求和固件发送值。

在这种方法中,数据传输的速度非常慢。每秒大概2个数据包,这意味着将所有数据包发送到移动应用程序需要3.5小时。

My question is ,, is there a fast method to do it? Because 256 KB data is not too big to send in hours.. I m missing something here..

Device:
PM_DIALOG.
离线
最后一次露面:6小时40分钟前
员工
加入:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

请您可以共享您使用的代码片段,以便通过BLE传输数据?我假设您正在使用BLE通知或迹象。

谢谢,PM_DIALOG.

Mahmed106.
离线
最后一次露面:1 month 1 week ago
加入:2019-05-03 17:28
I was using a read request

I was using a read request from the app side to read the data.

Here is the code of that

静态void handle_read_req(ble_service_t * svc,const ble_evt_gatts_read_req_t * evt){
sftemps_service_t *sftemps = (sftemps_service_t *) svc;

if (evt->handle == sftemps->temperature_count_h)
{
uint16_t ccc_val = rand()%100; // get_sf_temp_num_records_device();

// ble_storage_get_u16(evt-> conn_idx,bcs-> bcs_ccc_h,&ccc_val);

// we're little-endian, ok to write directly from uint16_t
ble_gatts_read_cfm(EVT-> CONN_IDX,EVT->句柄,ATT_ERROR_OK,
sizeof(ccc_val),&ccc_val);
}
否则if(evt-> handle == sftemps-> wheremer_data_h)
{
// uint32_t ccc_val = rand()%100; // get_sf_temp_records_device();

// ble_storage_get_u16(evt-> conn_idx,bcs-> bcs_ccc_h,&ccc_val);

// we're little-endian, ok to write directly from uint16_t

if(ReadPacketNumber==0) // 1st packet Header // Add exception of restart but data in flash
{
// ReadPacketNumFromFlash=read_packetNumbers_from_Flash();
// printf("PN %d",ReadPacketNumFromFlash);
#if noflashdummycode.
R_PTR_PacketNumber = 50;//rand()%100;
M24ElapsedTime = R_PTR_PacketNumber*3;
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
LoggingPacket[1]=0x11;
LoggingPacket[2]=0x12;
loggingpacket [3] = M24 elapsedtime >> 24;
loggingpacket [4] = M24 elapeTime >> 16;
LoggingPacket[5]=M24ElapsedTime >> 8;
loggingpacket [6] = m24elapsedtime&0xff;
loggingpacket [7] = r_ptr_packetnumber >> 8;
loggingpacket [8] = r_ptr_packetnumber&0xff;
loggingpacket [9] = loggingpacket [0];
for(int by = 1; by <9; by ++)
{
loggingpacket [9] ^ = loggingpacket [by];
}
ReadPacketNumber ++; //在下次迭代中读取下一个数据包
r_ptr_chipno = 1;//选择芯片一个,因为它是开始
R_PTR_ReadAddress = 0;//0xF9C9; // Start from chip 0 and address 0
#else
r_ptr_packetnumber = read_packetnumbers_from_m24flash();
m24elapsedtime = Readelapsedtimefromm24Flash();
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
LoggingPacket[1]=0x11;
LoggingPacket[2]=0x12;
loggingpacket [3] = M24 elapsedtime >> 24;
loggingpacket [4] = M24 elapeTime >> 16;
LoggingPacket[5]=M24ElapsedTime >> 8;
loggingpacket [6] = m24elapsedtime&0xff;
loggingpacket [7] = r_ptr_packetnumber >> 8;
loggingpacket [8] = r_ptr_packetnumber&0xff;
loggingpacket [9] = loggingpacket [0];
for(int by = 1; by <9; by ++)
{
loggingpacket [9] ^ = loggingpacket [by];
}
ReadPacketNumber ++; //在下次迭代中读取下一个数据包
r_ptr_chipno = 1;//选择芯片一个,因为它是开始
R_PTR_ReadAddress = 0;//0xF9C9; // Start from chip 0 and address 0
#万一
}
#if 1
否则if(ReadPacketNumber> 0 &&(ReadPacketNumber {
#if noflashdummycode.
Dummy_R_PTR_PacketNumber=ReadPacketNumber;
dummy_m24elapsedtime = dummy_r_ptr_packetnumber * 3;
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
loggingpacket [1] = 0x12;
loggingpacket [2] = 0x13;
memset(M24CurrentPacket,0x00,sizeof(M24CurrentPacket));
loggingpacket [3] = 0;
loggingpacket [4] = dummy_r_ptr_packetnumber ++;
loggingpacket [5] = dummy_m24elapsedtime >> 24;
loggingpacket [6] = dummy_m24elapsedtime >> 16;
loggingpacket [7] = dummy_m24 elaptime >> 8;
loggingpacket [8] = dummy_m24elapedtime;
LoggingPacket[9]=rand()%60;
LoggingPacket[10]=rand()%9;
LoggingPacket[11]=LoggingPacket[0];
for(int by = 1; by <11; by ++)
{
loggingpacket [11] ^ = loggingpacket [by];
}
ReadPacketNumber ++; //在下次迭代中读取下一个数据包
#else
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
loggingpacket [1] = 0x12;
loggingpacket [2] = 0x13;
memset(M24CurrentPacket,0x00,sizeof(M24CurrentPacket));
// printf(“cn%d - 添加%d”,r_ptr_chipno,r_ptr_readaddress);
// fflush(stdout);
SequentialReadM24FLASH(((r_ptreadaddress&0xff00)>> 8),(r_ptr_readddress),8,r_ptr_chipno);
R_PTR_ReadAddress+=8;
for(uint8_t TempBuffFill=3;TempBuffFill<11;TempBuffFill++)
{
LoggingPacket[TempBuffFill] = M24CurrentPacket[TempBuffFill-3];
// LoggingPacket[TempBuffFill] = M24_I2C_AD_read((R_PTR_ReadAddress & 0xFF),(R_PTR_ReadAddress & 0xFF00),R_PTR_ChipNo);
// printf(“\ n%d”,r_ptr_readaddress);
// R_PTR_ReadAddress++;
}
// readpacketnumber =(loggingpacket [3] * 10)+ loggingpacket [4];//如果数据包编号写入和读取索引之间存在不匹配
LoggingPacket[11]=LoggingPacket[0];
for(int by = 1; by <11; by ++)
{
loggingpacket [11] ^ = loggingpacket [by];
}
ReadPacketNumber ++; //在下次迭代中读取下一个数据包
if(r_ptr_readaddress> = 0xf9f6 && r_ptr_chipno <4)// 0xf9f6是最后64k / 15 = 4266的地址
{
R_PTR_ChipNo++;
r_ptr_readaddress = 0;
}
#万一
}
否则if(readpacketnumber> r_ptr_packetnumber)//页脚
{
#if noflashdummycode.
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
LoggingPacket[1]=0x13;
LoggingPacket[2]=0x14;
loggingpacket [3] = 0xDA;
ReadPacketNumber=0;
loggingstatus = loggingstopped;
#else
memset(LoggingPacket,0x00,sizeof(LoggingPacket));
LoggingPacket[0]=0xCD;
LoggingPacket[1]=0x13;
LoggingPacket[2]=0x14;
loggingpacket [3] = 0xDA;
if(PassCodeVerification == 1)
{
M24FlashPacketNumber=0;
resetpacketnumberinm24flash(); //照顾从应用程序中读取的高速可以预防它
LoggingStatus=LoggingStopped;
flash_full = 0;
ResetElaspedTimeInM24Flash();// take care as high speed read from app may pre-empt it
m24 elapsedtime = 0;
PauseElapsedTimeCounting=ET_PAUSE;
ResetChipNoInM24Flash();// take care as high speed read from app may pre-empt it
}
ReadPacketNumber=0;

// flashpacketnumber = 1;
// Elapsed_Time=0;
#万一
}
#万一
ble_gatts_read_cfm(EVT-> CONN_IDX,EVT->句柄,ATT_ERROR_OK,
sizeof(loggingpacket)和loggingpacket);
#if enable_uart_printf.
printf(“Flsh-RD%d-%d \ n”,ReadPacketNumber,R_PTR_PacketNumber);
#万一
}
其他
{

BLE_GATTS_READ_CFM(EVT-> CONN_IDX,EVT->句柄,ATT_ERROR_READ_NOT_PERMITTED,0,
空值);
}

The app continuously makes a read request and DA14681 send data in response.

我还尝试了通知方法,它比上述方法更好,但也需要很多时间。我想知道使用DA14681在BLE上发送大块数据的方法

PM_DIALOG.
离线
最后一次露面:6小时40分钟前
员工
加入:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Thanks for your response. Let me check it and I’ll get back to you/

谢谢,PM_DIALOG.

PM_DIALOG.
离线
最后一次露面:6小时40分钟前
员工
加入:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

在连接间隔期间,设备可以发送的数据量密切相关,密切依赖于中央允许外设发送的数据包数。要这样做,请检查数据事务时是否会在交换有多少数据包?是否有可能使用BLE Sniffer工具,以便我们可以了解交易期间在空中发生的情况?在第一个读取请求之后是否有通知使能?

Keep in mind that according to the BLE specifications, up to 251 bytes in one packet can be sent in one packet. What is the max data length for the packets received/transmitted? So check dg_configBLE_DATA_LENGTH_RX_MAX and dg_configBLE_DATA_LENGTH_TX_MAX macros. The ble_gap_mtu_size_set() could be used to set the appropriate mtu_size. Please note that the specific API should be called before the attribute database creation because the device configuration is going to be modified, which will result in clearing the current attribute database (if it exists).

A couple of things reggaridng the pure performance might the following:

  • 连接时间间隔。最低允许间歇雨刷al that can be used is 7.5ms. What is the connection interval is used in the application code? Either the Central can set the connection interval or the Peripheral can request to have a specific connection interval and it’s up to the Central to accept or not (connection update parameters).
  • Slave latency. What you please indicate this? The lowest latency value could be used which is equal to zero (0).
  • The number of packets per connection interval. This might be limited by the Central and affect the performance. What is the Central that is used? Is it another DA14681, or a smartphone?

谢谢,PM_DIALOG.

Mahmed106.
离线
最后一次露面:1 month 1 week ago
加入:2019-05-03 17:28
谢谢你的详细回复

谢谢你的详细回复。现在我明白了。根据您的问题,以下是答案:

1 - 750ms is the connection interval

2 - 从等待时间为0

3 - Central是一个智能手机

Mahmed106.
离线
最后一次露面:1 month 1 week ago
加入:2019-05-03 17:28
所以这意味着我减少了我的

所以它意味着我将连接间隔减少到7ms,我的吞吐量会增加?

PM_DIALOG.
离线
最后一次露面:6小时40分钟前
员工
加入:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Yes please try to use a smaller connection interval than 750ms and send data via notifications. According to BLE specifications, the connection interval should be from 7.5ms (Conn_Interval_Min) to 5sec (Conn_Interval_Max).

谢谢,PM_DIALOG.