This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to send more than 8 packets of data to nrf app?

Hello, I am using sdk12.2 and nrf52. I want to send more than 8 packets of data to nrf app. How can I do that? My code snippet is as follows:

enter code here

void data_send(void) { uint32_t err_code; //uint8_t sensor_data[10]; uint8_t sensor_data[20]; uint8_t dl_buffer[10000]; // uint16_t sensor_data[10]; uint16_t j=0; fds_flash_record_t flash_record; memset(sensor_data, 0, 20); memset(dl_buffer, 0, 6000); fds_record_desc_t record_desc; fds_find_token_t ftok ={0};//Important, make sure you zero init the ftok token uint8_t *data; // uint16_t *data;

	// Loop until all records with the given key and file ID have been found.
//	while (fds_record_find_in_file(file_read,&record_desc, &ftok) == FDS_SUCCESS)
	while (fds_record_find(file_read,rec_read,&record_desc, &ftok) == FDS_SUCCESS)	
	{
		err_code = fds_record_open(&record_desc, &flash_record);
		
		data = (uint8_t *) flash_record.p_data;

		for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)
		{
			
			NRF_LOG_INFO("Find Data: %d\r\n",data[i]);
			dl_buffer[j] = data[i];
    NRF_LOG_INFO("dl_buffer %d\r\n ",dl_buffer[j]);
			NRF_LOG_INFO("i %d\r\n ",i);
			NRF_LOG_INFO("j %d\r\n ",j);
			j++;
			
		}
		// Access the record through the flash_record structure.
		// Close the record when done.
		err_code = fds_record_close(&record_desc);
	}
	
		
	

				for (uint8_t i=0,k = 0;k<j;i++,k++)
			{
				sensor_data[i] = dl_buffer[k];
				NRF_LOG_INFO("sensor_data %d\r\n ",sensor_data[i]);
				//if (i == 18)
				if (/*((j < 18 ) && j > 6) || */(i == 18))
				{
					NRF_LOG_INFO("i %d\r\n ",i);
					//nrf_delay_ms(200);
					err_code = send_notification(sensor_data);
				
				if (err_code != NRF_SUCCESS &&
        err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
        err_code != NRF_ERROR_INVALID_STATE &&
					err_code != (NRF_ERROR_STK_BASE_NUM+NRF_ERROR_NO_MEM))
    {
        APP_ERROR_CHECK(err_code);
    }
			
					NRF_LOG_INFO("Send_notif_error: %d\r\n",err_code);
					//memset(sensor_data, 0, 20);
					i = 0;
				}
			}
	}

//}

Thanks,

Parents
  • First off I would recommend that you use the latest available SDK and corresponding Softdevice.

    If you want to send multiple packets you need to be aware that there are only a limited amount of TX buffers, when these are full you have to wait for a tx complete event before continuing transmission. You could also consider using DLE, so you can send longer packets. Search devzone to find out how to enable it.

Reply
  • First off I would recommend that you use the latest available SDK and corresponding Softdevice.

    If you want to send multiple packets you need to be aware that there are only a limited amount of TX buffers, when these are full you have to wait for a tx complete event before continuing transmission. You could also consider using DLE, so you can send longer packets. Search devzone to find out how to enable it.

Children
No Data
Related