<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Packet retransmission at client &amp;amp; loss at server</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115411/packet-retransmission-at-client-loss-at-server</link><description>Hello, 
 I am a student currently studying Bluetooth Low Energy (BLE). 
 I am working with two Adafruit nRF52832 boards (Adafruit Feather nRF52 Bluefruit LE - nRF52832, link to product: www.adafruit.com/.../3406) , setting up a 1-to-1 connection as a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Nov 2024 11:34:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115411/packet-retransmission-at-client-loss-at-server" /><item><title>RE: Packet retransmission at client &amp; loss at server</title><link>https://devzone.nordicsemi.com/thread/508793?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2024 11:34:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fc97939-1e4e-44d9-ab0d-8829b8f721ef</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Okay, do you have any further questions or can we close this ticket?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Packet retransmission at client &amp; loss at server</title><link>https://devzone.nordicsemi.com/thread/508668?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2024 13:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa291c2f-0a71-4aee-aaff-ab8c4f446e37</guid><dc:creator>Soonho</dc:creator><description>&lt;p&gt;Thank you for your response.&lt;br /&gt;I am currently programming an Adafruit nRF52832 board in the Arduino environment!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Packet retransmission at client &amp; loss at server</title><link>https://devzone.nordicsemi.com/thread/505877?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 11:54:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0242263e-7731-4a35-99a7-52f50388dafd</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I think the delay you&amp;#39;re seeing here is the random 0-10 ms delay mandated by the Bluetooth Core specification. It is an integral part of how Bluetooth works, and is there to avoid unnecessary data packet loss due to timing issues for example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Forgive me if I&amp;#39;m misunderstanding and you&amp;#39;re doing this within a connection, in which case I&amp;#39;ll need to know what SDK you&amp;#39;re on, and at what range and environment you&amp;#39;re doing the testing in. What could be helpful (if you have an nRF52 DK to spare) is to use it and Wireshark as a Bluetooth sniffer with the &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer firmware&lt;/a&gt; so we can see what exactly is going on over the air here.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Packet retransmission at client &amp; loss at server</title><link>https://devzone.nordicsemi.com/thread/505806?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 03:44:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d26e56a-25d4-49b4-809f-b69aefc50f4c</guid><dc:creator>Soonho</dc:creator><description>&lt;p&gt;&lt;span&gt;The client code had an error, and the correct code is as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;bluefruit.h&amp;gt;
#include &amp;lt;Adafruit_LittleFS.h&amp;gt;
#include &amp;lt;InternalFileSystem.h&amp;gt;
#include &amp;lt;Wire.h&amp;gt;

#define dataNum 2 // timestampe 포함
#define dataSize dataNum*4 // default: 20, maximum: 224
#define packetTime 8 // unit: 1.25ms
#define SLAVE_ADDRESS 0x61  // I2C 슬레이브 주소

BLEClientService        hrms(UUID16_SVC_HEART_RATE);
BLEClientCharacteristic hrmc(UUID16_CHR_HEART_RATE_MEASUREMENT);

float packetCount = 0;
uint8_t buffer[dataNum * sizeof(float)];

void setup()
{
  Serial.begin(115200);
  while ( !Serial ) delay(10);   // for nrf52840 with native usb

  Serial.println(&amp;quot;Bluefruit52 Peripheral Server&amp;quot;);
  Serial.println(&amp;quot;--------------------------------------\n&amp;quot;);

  Serial.println(&amp;quot;Initialize the Bluefruit nRF52 module&amp;quot;);
  // Change MTU size
  uint16_t requestedMtu = dataSize;
  Bluefruit.configCentralConn(requestedMtu+3, 4, BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT, BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT); // BLE_GAP_EVENT_LENGTH_DEFAULT = 3
  
  Bluefruit.begin(0, 1); // maximum connections as Peripheral = 0, Central = 1
  Bluefruit.setTxPower(4);
  Bluefruit.setName(&amp;quot;Bluefruit52 Central&amp;quot;);

  // Initialize HRM client
  hrms.begin();
  hrmc.begin();
  
  // Increase Blink rate to different from PrPh advertising mode
  Bluefruit.setConnLedInterval(250);
  
  // Callbacks for Central
  Bluefruit.Central.setConnInterval(packetTime, packetTime);
  Bluefruit.Central.setDisconnectCallback(disconnect_callback);
  Bluefruit.Central.setConnectCallback(connect_callback);

  /* Start Central Scanning
   * - Enable auto scan if disconnected
   * - Interval = 160 ms, window = 80 ms
   * - Don&amp;#39;t use active scan
   * - Filter only accept HRM service
   * - Start(timeout) with timeout = 0 will scan forever (until connected)
   */
  Bluefruit.Scanner.setRxCallback(scan_callback);
  Bluefruit.Scanner.restartOnDisconnect(true);
  Bluefruit.Scanner.setInterval(160, 80); // in unit of 0.625 ms
  Bluefruit.Scanner.filterUuid(hrms.uuid);
  Bluefruit.Scanner.useActiveScan(false);
  Bluefruit.Scanner.start(0);                   // // 0 = Don&amp;#39;t stop scanning after n seconds

  /*************************I2C***************************/
  Wire.setPins(25, 26);  // SCL = 25, SDA = 26 핀 설정
  Wire.begin(SLAVE_ADDRESS);  // 슬레이브 모드로 I2C 초기화
  Wire.onRequest(requestEvent);  // 마스터의 읽기 요청이 들어올 때 호출될 콜백 설정
  Wire.setClock(400000);  // Set I2C speed 나중에 필요하면 사용
}

/**************************************************************************/
void readTimedata(float (&amp;amp;timeData)[dataNum]) {
  timeData[0] = millis();              // timestamp를 imuData의 첫 번째 요소에 저장
  packetCount++;
  memcpy(buffer, timeData, sizeof(buffer));
  timeData[1] = packetCount;
  hrmc.write((uint8_t*)timeData, sizeof(timeData));
}

/**************************************************************************/
void loop() {
  float timeData[dataNum];

  if (Bluefruit.connected()) {
    readTimedata(timeData);
    // Serial.println(imuData[1]);
  }
}

/**********************************callback*********************************/
/**
 * Callback invoked when scanner pick up an advertising data
 * @param report Structural advertising data
 */
void scan_callback(ble_gap_evt_adv_report_t* report)
{
  // Since we configure the scanner with filterUuid()
  // Scan callback only invoked for device with hrm service advertised
  // Connect to device with HRM service in advertising
  Bluefruit.Central.connect(report);
}

/**
 * Callback invoked when an connection is established
 * @param conn_handle
 */
void connect_callback(uint16_t conn_handle)
{
  Serial.println(&amp;quot;Connected&amp;quot;);
  Serial.print(&amp;quot;Discovering Service ... &amp;quot;);

  // If HRM is not found, disconnect and return
  if ( !hrms.discover(conn_handle) )
  {
    Serial.println(&amp;quot;Found NONE&amp;quot;);

    // disconnect since we couldn&amp;#39;t find HRM service
    Bluefruit.disconnect(conn_handle);

    return;
  }

  // Once HRM service is found, we continue to discover its characteristic
  Serial.println(&amp;quot;Found it&amp;quot;);
  
  Serial.print(&amp;quot;Discovering characteristic ... &amp;quot;);
  if ( !hrmc.discover() )
  {
    // chr is mandatory, if it is not found (valid), then disconnect
    Serial.println(&amp;quot;not found !!!&amp;quot;);  
    Serial.println(&amp;quot;characteristic is mandatory but not found&amp;quot;);
    Bluefruit.disconnect(conn_handle);
    return;
  }
  Serial.println(&amp;quot;Found it&amp;quot;);

  // Get the reference to current connection
  BLEConnection* connection = Bluefruit.Connection(conn_handle);
  // Request MTU exchange for rx_client
  if (connection) {
    connection-&amp;gt;requestMtuExchange(dataSize + 3);  // Request MTU of 247 bytes
  }
}

/**
 * Callback invoked when a connection is dropped
 * @param conn_handle
 * @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h
 */
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
  (void) conn_handle;
  (void) reason;

  Serial.print(&amp;quot;Disconnected, reason = 0x&amp;quot;); Serial.println(reason, HEX);
}

void requestEvent() {
  // 요청이 있을 때 I2C 마스터에게 데이터를 전송
  Wire.write(buffer, sizeof(buffer));
}&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Packet retransmission at client &amp; loss at server</title><link>https://devzone.nordicsemi.com/thread/505782?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2024 17:20:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5f08124-e533-4356-88b2-39e1a70b2455</guid><dc:creator>Soonho</dc:creator><description>&lt;p&gt;Sorry for the wrong link to product&lt;/p&gt;
&lt;p&gt;&lt;span&gt;link to product:&amp;nbsp;&lt;/span&gt;&lt;a href="https://www.adafruit.com/product/3406"&gt;www.adafruit.com/.../3406&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>