Issues of making the development kit board a dongle

8个职位/0个新职位
Last post
wenkangl
Offline
最后一次露面:4年5个月前
加入:2016-06-23 13:01
Issues of making the development kit board a dongle

嗨对话框,

我试图写一个固件,使开发工具包板(基本)的狗。
I have written a desktop software that will communicate with the board via serial port.
我希望当软件向板发送命令时,板能够做出相应的响应。e、 g.扫描对等设备、连接到对等设备等。安装在板中的固件还可以发现它连接到的对等设备的服务和属性,并通过串行端口将这些报告给PC上的软件。它还可以从连接的对等设备接收通知数据,并再次向PC软件报告。
我已经阅读了DSP示例,但它发现了对等设备并通过设备名称连接到给定的设备(在代码中预先给出!!!!)。所以你会帮我一个忙,为我写一个指导线吗?谢谢!

我试着修改user\u sps\u host.c中的代码,将user\u on\u adv\u report\u ind函数修改如下,还修改了user\u on\u scanning\u completed函数,目的是在获得5台设备时停止扫描。

void user_on_adv_report_ind(struct gapm_adv_report_ind const * param)
{
// get device name
uint8 i=0, j=0;
uint8 len = sizeof(param-> report.data);
char dn [20] =“”;
for(i = 0; ireport.data [i]> = 0x20 && param-> report.data [i] <= 0x7e)
{
dn [j ++] = param-> report.data [i];
}
}
// get device address
len = sizeof(param-> report.addr.addr);
char add_buffer[13]=“”;
j = 0;
for(i = 0; ireport.adv_addr.addr [len - i - 1]);
add_buffer[j] = buffer[0];
add_buffer [j + 1] =缓冲器[1];
j = j + 2;
}
//获得rssi.
字符rssi[3];
Sprintf(RSSI,“%D”,Param-> Report.RSSI);
// form the packet that will send to the PC via UART2
字符包[44];
j = 0;
数据包[j ++] ='*';
packet[j++] = 'D';
数据包[j ++] ='n';
数据包[j++]=':';
对于(i=0;i<20;i++)
{
如果(dn[i]!=0x00)
{
数据包[j++]=dn[i];
}
}
packet[j++] = ',';
for(i=0; i<13; i++)
{
if(add_buffer[i] != 0x00)
{
packet[j++] = add_buffer[i];
}
}
packet[j++] = ',';
for(i=0; i<3; i++)
{
if(add_buffer[i] != 0x00)
{
packet[j++] = add_buffer[i];
}
}
数据包[j ++] ='\ r';
数据包[j ++] ='\ n';
//将数据包发送到PC
printf_string(数据包);

}

无效用户\u on \u扫描\u完成(uint8\t状态)
{
device_count++;
if(device_count <= 5)
{
用户_scan_start();
}
else
{
user_wait_for_cmd();
}
返回;
}

Here, I added a function called user_wait_for_cmd(), which is used to read the command, and is implemented as follows, and the uart2 read completed callback is used to recall the user_wait_for_cmd() . However, the program come up with an JLINK Error, that says Can not read registers ## while CPU is running. what is the problem for this implementation?

void user_wait_for_cmd(void)
{
uint8读取长度=25;
while(!read_success)
{
uart2_read((uint8_t *)buffer, read_length, uart2_read_completion_cb);
}
}

bool read_success ;
无效uart2\读取\完成\ cb(uint8\ t状态)
{
if(buffer[0]=='C' && buffer[1]=='M' && buffer[2]=='D')
{
read_success = true;
打印字符串(缓冲区);
}
else
{
read_success=false;
user_wait_for_cmd();
}
}

By the way, where can I buy a dongle for DA14580?

关键词:
设备:
mt_dialog.
Offline
最后一次露面:3个月4天前
Staff
加入:2015-06-08 11:34
嗨wenkangl,

嗨wenkangl,

As far as i know it goes along with the pro-dev kit, i dont think that is sold seperately. Some comments regarding the code you ve pasted, i can see that you are counting the devices that you ve discovered when user_on_scanning_completed() is invoked, that means that you are counting the scanning cycles of your device, every scan cycle lasts a few seconds and the user_on_scanning_complete is invoked either when you cancel the scanning procedure or when the scan operation completes. The advertising messages are comming as indications to the user_on_adv_report_ind() everytime the device gets a new advertising string. So in order to count devices scanned, what you must do is to check the bd address of the current advertising string and check the entries in your log (the place that you keep the recorded devices) and count up when you are placing a new entry in your log. Regarding the error that you are getting when applying the code for reading, i dont think that your implementation is responsible for it, check the default sleep mode of the device and make sure that the sleep mode is disabled (you cant have the sleep mode enabled and debug at the same time). Also you will have to consider the fact that the 580 when it sleeps all the peripherals are powered down including the UART, the DSPS for example uses the a flow control scheme in order to signal the external MCU when its allowed to send data or not, since if the data are sent while the 580 sleeps they will be lost.

谢谢mt_dialog.

wenkangl
Offline
最后一次露面:4年5个月前
加入:2016-06-23 13:01
谢谢MT,但我的目标不是

谢谢mt,

I have more questions on this topic, since my aim is more than counting the devices nearby.

no1。在da1458x_config_basic.h中,睡眠模式已被配置为活动:

#未定义CFG\u MEM\u MAP\u EXT\u SLEEP
#undef CFG_MEM_MAP_DEEP_SLEEP

然后我发送扫描命令(CMD_SCAN) to the DB, and the firmware did call the user_scan_start() and run the function to the end. However, after that, the user_on_adv_report_ind is NOT triggered, and moreover, when I sent a command of connection (CMD_CONNECT), the program called user_connect_to but the user_on_scanning_completed and user_on_connection are NOT triggered... so in this situation, what is wrong with my implementation.

我修改了uart2\u read\u completion\u cb函数如下
Char Buffer [25];
静态UINT8_T UART2_READ_IN_POGRONGER = 0;

无效uart2\读取\完成\ cb(uint8\ t状态)
{
if(buffer[0]=='C' && buffer[1]=='M' && buffer[2]=='D')
{
uart2_read_in_progress = 0;
打印字符串(缓冲区);
对命令()执行操作;
}
else
{
user_wait_for_cmd();
}
}

void user_wait_for_cmd(void)
{
uint8读取长度=25;
uart2\u read\u in\u progress=1;
uart2_read((uint8_t *)buffer, read_length, uart2_read_completion_cb);
while(uart2_read_in_progress);
}
收到命令的行动如下
void action \u on \u命令(void)
{
char cmdid [] = {buffer [4],缓冲区[5]};
uint8 CMD\u ID=(uint8)strtol(cmdid,NULL,16);
uint8 hexdata[16]={0};
uint8 i=7;
而((缓冲区[i]='\\'&&buffer[i+1]=='r'))
{
hexdata [I-7] =缓冲器[i];
i++;
}
switch(CMD_ID)
{
case CMD_SCAN:
{
//0x00个
用户_scan_start();
休息;
}
case CMD_CONNECT:
{
//0x01型
uint8 peer_addr[6]={0x00};
for(i=0; i<6; i++)
{
char temp[]={hexdata[2*i],hexdata[2*i+1]};
uint8 part\u add=(uint8)strtol(temp,NULL,16);
对等地址[5-i]=部分地址;
}
user_connect_to(0x00,peer_addr);
休息;
}
}
}
user_connect_to如下
void user\u connect\u to(uint8\u t peer\u addr\u type,uint8\u t*peer\u addr)
{
app_easy_gap_start_connection_to_set(peer_addr_type,peer_addr,ms_to_doubleslots(user_con_intv));
app_easy_gap_start_connection_to();
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

NO2. Then I came up with another idea. That is, even if I solved the problem described above, it still can't be satisfying. Because I hope DA14580 could handle at least two tasks asynchronously, that is, it keeps monitoring the command sent from PC ( and the DA14580 should always be monitoring the command sent by PC) and meanwhile doing something else.
例如,它监视来自PC的命令,同时接收连接的外围设备发送的通知数据,并将数据发送到PC。
另一个例子:当DB接收到通知数据时,我向DB发送停止通知命令。DB应停止上传接收到的通知数据,并将停止通知命令发送到连接的外围设备,并且连接的外围设备将相应地进行。
为此,如果我想使用DSPS项目,我应该怎么做?问题是集中在中心端(加密狗),外围端的任务已经完成^_^

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

no3。由于加密狗没有单独出售,您是否可以推荐一个适用于DA14580的人?ConnectBlue?

谢谢!

mt_dialog.
Offline
最后一次露面:3个月4天前
Staff
加入:2015-06-08 11:34
嗨wenkangl,

嗨wenkangl,

NO1: The definitions that you ve changed affects the memory mapping of your device and not the sleeping mode (its mentioned in the comment above "Sleep mode memory map configuration."), To change the default sleep mode you have to change the app_default_sleep_mode in the user_config.h file with ARCH_SLEEP_OFF, this is the reason for the error that JLink reports after a few seconds while you are in debug mode. Regarding the fact that the user_on_adv_report_ind is not triggered (i suppose that you are trying to catch the advertising indication by using a breakpoint), if indeed the new scanning procedure has started you wont be able to catch that advertising event via a breakpoint since your debugger is de-attached from your 580. Please check the above and if indeed you had disabled sleep and the proper functions are called when the corresponding commands are sent from UART check if the advertising device is actually advertising and can accept connections.

No3:从对话框提供的加密狗不是通用的加密狗,您可以连接到Windows机器并被识别为蓝牙模块,它只是一个580,带有Atmel微控制器,用作USB端口的桥梁,仅接受UART命令通过GTL(Propriale Protocol)。我怀疑一般的BLE模块是您想要的,虽然我无法提出建议,但我想支持支持4.0规范的任何BLE加密狗,但在我们使用的大多数应用程序(测试)中我们正在使用Android雷竞技安卓下载手机。

NO2:DSPS示例监视UART并服务于DSPS\u任务(从中心发送通知和接受写命令)。当UART中的数据可用时,会发生中断,执行ISR,代码负责UART的FIFO并正确处理数据,它不会轮询UART以将此视为附加任务。您可以以这个实现为例进行研究。

谢谢mt_dialog.

wenkangl
Offline
最后一次露面:4年5个月前
加入:2016-06-23 13:01
谢谢,山

谢谢,山

至于NO2,您提到的ISR是UART2.c中的UART2\u Handler(void),接收数据的DSPS\u任务是UART2\u rec\u data\u avail\u ISR吗?如果是的话,我应该把我定义的操作放在哪里?你的意思是我应该直接修改uart2\u rec\u data\u avail\u isr吗?

你能详细解释一下DSPS\u任务吗?

非常感谢!

wenkangl
Offline
最后一次露面:4年5个月前
加入:2016-06-23 13:01
And as I read through the

当我通读代码时,我发现uart2_env.rx.callback是在uart2_read中分配的,当接收到可用时,uart2_rec_data_avail_isr()被执行,并且定义的回调被执行。然后在uart2\u rec\u data\u avail\u isr()中,回调指针将被清除。如果我的理解是对的?如果是这样,是否意味着我需要调用uart2\u read来接收命令,而不是在PC上发送命令并调用操作\u on \u command()?

mt_dialog.
Offline
最后一次露面:3个月4天前
Staff
加入:2015-06-08 11:34
嗨wenkangl,

嗨wenkangl,

DSP和实现的脱胶机制使用不同的UART(580中有两个相同的UART模块),因此每个UART都有单独的ISR处理程序。如何处理您的中断和数据,这取决于您的应用程序以及您想要实现它的方式。关于DSPS_Task(Task_sps_server更加确切)是DSPS设备的配置文件任务,您可以在UM-B-038串行端口服务应用程序文档中找到更多信息。

是的,您的理解是正确的,在UART2获取数据上的数据后,您将清除回调,您只需调用UART2_READ()即可继续执行任何您正在做的事情,并且当您在UART中获取数据时,中断将继续进行中断,当您达到您的数据的大小时,您的回调(在调用UART读取时设置的一个)将被调用并通知您所指定的数据已到达,并且将禁用UART中断。这意味着如果您的命令具有指定大小,则可以在等待它时设置每个命令的大小,或者您可以指定将读取第一个字节作为命令大小的命令格式(读取一个字节为大小)和然后根据该特定大小命令设置回调,或者您可以始终等待一个字节并等待命令的终端字符(指示命令结束),有相当少的选项如何实现这一目标但是我在上面提到的,这取决于你希望如何实现的方式。

谢谢mt_dialog.

wenkangl
Offline
最后一次露面:4年5个月前
加入:2016-06-23 13:01
谢谢mt,

谢谢mt,

因此要监视UART,我必须经常调用UART2_READ(),并且我的解决方案到数据包的大小是这样,我使用固定的长度分组(25如代码中所示),并且该命令将是预先的- 处理使其始终为25(在数据包的末尾添加0,因此它的长度为25)。我正试图得到中央工作。