so Im tring to use interactive command to output my personal content
NRF_CLI_CMD_REGISTER(devices_ccc, NULL, "List available devices.", cmd_devices_display_ccc);
static void cmd_devices_display_ccc(nrf_cli_t const * p_cli, size_t argc, char ** argv)
{
if (argc >= 2)
{
if (nrf_cli_help_requested(p_cli))
{
nrf_cli_help_print(p_cli, NULL, 0);
return;
}
else
{
nrf_cli_fprintf(p_cli,
NRF_CLI_ERROR,
"%s:%s%s\n",
argv[0],
" bad parameter ",
argv[1]);
return;
}
}
// Print connectable devices from scan data.
scanned_device_t * p_device_list = scan_device_info_get();
device_list_print_ccc(p_cli, p_device_list);
}
static void device_list_print_ccc(nrf_cli_t const * p_cli, scanned_device_t * p_device)
{
for (uint8_t i = 0; i < DEVICE_TO_FIND_MAX; i++)
{
if (p_device[i].is_not_empty)
{
// nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Devicekkk");
char buffer[ADDR_STRING_LEN];
// char buffer_data[ p_device[i].format.datalen_int];
int_addr_to_hex_str(buffer, BLE_GAP_ADDR_LEN, p_device[i].addr);
// int_to_hex_str(buffer_data,p_device[i].format.datalen_int, p_device[i].dev_name,p_device[i].format.fulldata);
if(p_device[i].cnt_type == T_APPLE){
// nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, ",%d,%s,%s,%02x%x%x%x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n"
// , p_device[i].cnt_type, buffer, p_device[i].dev_name ,p_device[i].uuid[0],p_device[i].uuid[1],p_device[i].uuid[2]
// ,p_device[i].uuid[3],p_device[i].uuid[4],p_device[i].uuid[5],p_device[i].uuid[6],p_device[i].uuid[7],p_device[i].uuid[8]
//,p_device[i].uuid[9],p_device[i].uuid[10],p_device[i].uuid[11],p_device[i].uuid[12],p_device[i].uuid[13],p_device[i].uuid[14]
//,p_device[i].uuid[15]);
nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%d,%s,%s,%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x \n"
, p_device[i].cnt_type, buffer, p_device[i].dev_name ,p_device[i].uuid[0],p_device[i].uuid[1],p_device[i].uuid[2]
,p_device[i].uuid[3],p_device[i].uuid[4],p_device[i].uuid[5],p_device[i].uuid[6],p_device[i].uuid[7],p_device[i].uuid[8]
,p_device[i].uuid[9],p_device[i].uuid[10],p_device[i].uuid[11],p_device[i].uuid[12],p_device[i].uuid[13],p_device[i].uuid[14]
,p_device[i].uuid[15]);
for(int t=0;t<p_device[i].format.datalen_int;t++){
// nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL,"%.2x",p_device[i].format.fulldata[t]);
// nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL,"\n");
}
}else{
nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%d,%s, %s\n" , p_device[i].cnt_type, buffer,p_device[i].dev_name );
for(int t=0;t<p_device[i].format.datalen_int;t++){
// nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL,"%.2x",p_device[i].format.fulldata[t]);
//nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL,"\n");
}
}
}
// printf("uuidcountfromcli_m: %d \n",uuid_lsb);
}
// int a=uuid_lsb;
}
same as the device command which out put the device message
but i want to find the function which put all the character into a buffer before it output to the uart
also want to know when did the code call the Uart I only found
1. it called nrf_cli_fprintf
void nrf_cli_fprintf(nrf_cli_t const * p_cli,
nrf_cli_vt100_color_t color,
char const * p_fmt,
...)
{
ASSERT(p_fmt);
ASSERT(p_cli);
ASSERT(p_cli->p_ctx && p_cli->p_iface && p_cli->p_name);
va_list args = {0};
va_start(args, p_fmt);
#if NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS)
if ((p_cli->p_ctx->internal.flag.use_colors) &&
(color != p_cli->p_ctx->vt100_ctx.col.col))
{
nrf_cli_vt100_colors_t col;
vt100_colors_store(p_cli, &col);
vt100_color_set(p_cli, color);
nrf_fprintf_fmt(p_cli->p_fprintf_ctx, p_fmt, &args);
vt100_colors_restore(p_cli, &col);
}
else
#endif // NRF_MODULE_ENABLED(NRF_CLI_VT100_COLORS)
{
nrf_fprintf_fmt(p_cli->p_fprintf_ctx, p_fmt, &args);
}
va_end(args);
}
2.it called void nrf_fprintf_fmt
void nrf_fprintf_fmt(nrf_fprintf_ctx_t * const p_ctx,
char const * p_fmt,
va_list * p_args)
{
ASSERT(p_ctx != NULL);
ASSERT(p_ctx->fwrite != NULL);
ASSERT(p_ctx->p_io_buffer != NULL);
ASSERT(p_ctx->io_buffer_size > 0);
if (p_fmt == NULL)
{
return;
}
char c;
int32_t v;
uint32_t NumDigits;
uint32_t FormatFlags;
uint32_t FieldWidth;
do
{
c = *p_fmt;
p_fmt++;
if (c == 0u)
{
break;
}
if (c == '%')
{
//
// Filter out flags
//
FormatFlags = 0u;
v = 1;
do
{
c = *p_fmt;
switch (c)
{
case '-':
FormatFlags |= NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY;
p_fmt++;
break;
case '0':
FormatFlags |= NRF_CLI_FORMAT_FLAG_PAD_ZERO;
p_fmt++;
break;
case '+':
FormatFlags |= NRF_CLI_FORMAT_FLAG_PRINT_SIGN;
p_fmt++;
break;
default:
v = 0;
break;
}
} while (v);
//
// filter out field width
//
FieldWidth = 0u;
do
{
if (c == '*')
{
/*lint -save -e64 -e56*/
FieldWidth += va_arg(*p_args, unsigned);
/*lint -restore*/
p_fmt++;
break;
}
c = *p_fmt;
if ((c < '0') || (c > '9'))
{
break;
}
p_fmt++;
FieldWidth = (FieldWidth * 10u) + (c - '0');
} while (1);
//
// Filter out precision (number of digits to display)
//
NumDigits = 0u;
c = *p_fmt;
if (c == '.')
{
p_fmt++;
do
{
c = *p_fmt;
if ((c < '0') || (c > '9'))
{
break;
}
p_fmt++;
NumDigits = NumDigits * 10u + (c - '0');
} while (1);
}
//
// Filter out length modifier
//
c = *p_fmt;
do
{
if ((c == 'l') || (c == 'h'))
{
p_fmt++;
c = *p_fmt;
}
else
{
break;
}
} while (1);
//
// Handle specifiers
//
/*lint -save -e64*/
switch (c)
{
case 'c':
{
char c0;
v = va_arg(*p_args, int32_t);
c0 = (char)v;
buffer_add(p_ctx, c0);
break;
}
case 'd':
case 'i':
v = va_arg(*p_args, int32_t);
int_print(p_ctx,
v,
10u,
NumDigits,
FieldWidth,
FormatFlags);
break;
case 'u':
v = va_arg(*p_args, int32_t);
unsigned_print(p_ctx,
(uint32_t)v,
10u,
NumDigits,
FieldWidth,
FormatFlags);
break;
case 'x':
case 'X':
v = va_arg(*p_args, int32_t);
unsigned_print(p_ctx,
(uint32_t)v,
16u,
NumDigits,
FieldWidth,
FormatFlags);
break;
case 's':
{
char const * p_s = va_arg(*p_args, const char *);
string_print(p_ctx, p_s, FieldWidth, FormatFlags);
break;
}
case 'p':
v = va_arg(*p_args, int32_t);
buffer_add(p_ctx, '0');
buffer_add(p_ctx, 'x');
unsigned_print(p_ctx, (uint32_t)v, 16u, 8u, 8u, 0);
break;
case '%':
buffer_add(p_ctx, '%');
break;
#if NRF_MODULE_ENABLED(NRF_FPRINTF_DOUBLE)
case 'f':
{
double dbl = va_arg(*p_args, double);
float_print(p_ctx,
dbl,
NumDigits,
FieldWidth,
FormatFlags,
false);
break;
}
case 'F':
{
double dbl = va_arg(*p_args, double);
float_print(p_ctx,
dbl,
NumDigits,
FieldWidth,
FormatFlags,
true);
break;
}
#endif
default:
break;
}
/*lint -restore*/
p_fmt++;
}
else
{
buffer_add(p_ctx, c);
}
} while (*p_fmt != '\0');
if (p_ctx->auto_flush)
{
nrf_fprintf_buffer_flush(p_ctx);
}
}
3.after the buffer it flush
void nrf_fprintf_buffer_flush(nrf_fprintf_ctx_t * const p_ctx)
{
ASSERT(p_ctx != NULL);
if (p_ctx->io_buffer_cnt == 0)
{
return;
}
p_ctx->fwrite(p_ctx->p_user_ctx,
p_ctx->p_io_buffer,
p_ctx->io_buffer_cnt);
p_ctx->io_buffer_cnt = 0;
}
but i did not find anything which it called the Uart when it output the string
anyone knows?
the reason why om doing this is because i want to set the uart rx by myself to connect other device

i found out p_io_buffer is the buffer which send the message but there are no function later on how did it send?
and i found out after the write command it bump into the function under but how? when did this fuction been called
void nrf_cli_print_stream(void const * p_user_ctx, char const * p_data, size_t data_len)
{
cli_write((nrf_cli_t const *)p_user_ctx,
p_data,
data_len,
NULL);
}