faq-da1458x-software-peripherals

Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. 我们将在未来几天内修复bug/优化搜索和标记。
How i can enable the sleeping feature on the 580 ?

The low energy of the 580 lies in between the connection or the advertising intervals. When the module has nothing to do, i.e an upcoming BLE event in the near future it will switch in sleep mode automatically if the user has turned the sleeping feature on. In order for the user to turn on the sleeping feature he has to:

  • 在user_config.h中的SDK5中,在Arch_ext_sleep_on中设置App_default_sleep_mode变量,用于扩展睡眠或arch_deep_sleep_on以进行深度睡眠。
  • 在SDK3的da14580#config文件中,定义CFGŠu EXTŠu SLEEP或CFGŠu DEEPŠu SLEEP定义。

After setting these definitions or variables as indicated above the module will go in sleep mode after each BLE event (connection event or advertising event).

The user is able to change the default sleeping mode i.e. switch between each sleep mode (off, extended, deep mode) during runtime via using the functions:

  • arch\u disable\u sleep:禁用睡眠模式。
  • arch_set_extended_sleep: enable the exteded sleep mode.
  • ARCH_SET_DEEP_SLEEP:启用深度睡眠功能。

Important note:启用睡眠模式时,您不会使用keil才能调试代码,在调试休眠功能时应始终关闭。如果睡觉和调试580将保持闲置并等到调试器分离,或者您将在CPU运行时无法读取“JLINK错误:无法读取寄存器XX(XXX)”

Would it be possible to control DA14580 with an external processor? DA14580可用作单个处理器解决方案或外部处理器。在外部处理器解决方案中,在DA14580上运行蓝牙低能量堆栈和配置文件。自定义应用程序层部署在外部处理器上。DA14580上的外部应用程序和配置文件/堆栈之间的通信是通过对话框提供的外部处理器接口。外部处理器接口可以物理映射在UART或SPI上。
DIALE是否提供了任何蓝牙低能量曲线? 对话框为客户开发了一组SIG合格的配置文件。配置文件作为SDK的一部分以源代码格式交付。用户同意对话框软件许可证后,这些配置文件可以自由地用作用户应用程序的一部分。亚博国际官网平台网址
What happens when the DA14580 loses connection, e.g due to supervision timeout.

当DA14580失去连接(例如,由于监控超时)时会发生什么情况?如何将其配置为立即重新播发。。

If the connection is lost due to supervision timeout and other reasons, GAP layer will send GAPC_DISCONNECT_IND message to an application task. In GAPC_DISCONNECT_IND handler, developers can set their application to start advertising again.

If developers want to start the stack fresh, then GAPM_RESET_CMD can be sent to GAP layer by an application task

DA14580是否支持AES-128加密应用程序级的应用程序数据?

DA14580 supports AES-128 encryption and decryption to secure a BLE link once the encryption is enabled in paring/bonding procedure. This is handled by the Dialog stack and developers are not required to implement any proprietary encryption/decryption algorithm.

如果开发人员希望通过加密应用程序数据添加额外的安全性,如果使用DA14580集成AES-128硬件块也可以实现这一点。差距API,即GAPM_USE_ENC_BLOCK_CMD可以访问AES-128硬件块并提供加密应用程序数据的目的。API的Operant 2是明文,Oprant 1是用于加密的钥匙。加密完成后,应用软件将从具有加密数据的堆栈接收GapM_USE_ENC_BLOCK_IND消息。加密数据可以通过各种开源工具进行破译,例如,http://seit.unsw.adfa.edu.au/staff / sites/lpb/src/aescalc/.

At application level, DA14580 does not support deciphering by using AES-128 hardware block.

How to debug with UART?

1)必须在da14580_config.h中定义

#define cfg_printf.
#定义CFG\u禁用\u RTS\u CTS

2) Add the folder of the app_console.c in the project from DA14580_SDK_3.0.2.1\DA14580_SDK_3.0.2.1\dk_apps\src\modules\app\src\app_utils \app_console

3)包含AppHeTalk文件夹的路径,从目标-> C/C++ + TAG>选项中包含路径。

4)在Periph_init中,添加:

SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock for UART 1
SetWord16 (UART_LCR_REG 0 x80);/ /设置为accs DLH and DLL register
// divisor = 1000000 / 115200 = 9
setword16(Uart_ier_dlh_reg,(9&0xff >> 8)); //设置高字节
setword16(UART_RBR_THR_DLL_REG,9&0xFF); //设置低字节
SetWord16(UART_LCR_REG,3); // no parity, 1 stop bit 8 data length and clear bit 8
setBits16(UART_MCR_REG,UART_SIRE,0);// mode 0正常,1对于IRDA
设置字16(UART_IIR_FCR_REG,1);//启用fifo
setBits16(UART_IER_DLH_REG,ERBFI_DLH0,0);// ier访问,禁用可用数据的中断

5) In the GPIO_reservations function, add:

RESERVE_GPIO( UART1_TX, GPIO_PORT_0, GPIO_PIN_4, PID_UART1_TX);
RESERVE_GPIO( UART1_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART1_RX);

6) In the set_pad_function add:

gpio_configurepin(gpio_port_0,gpio_pin_4,输出,pid_uart1_tx,false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_UART1_RX, false );

7) Add: #include "app_console.h" in the file where the printf command has to be used

要打印1字节:
char ch = 0xFF;
拱门(&ch);
要打印1字符串:
拱门印刷(“测试”)
arch_printf(" actual_triming_value= %Lx",actual_triming_value);
ARCH_PRINTF(“原因=%lx”,param - >原因);

如何在扩展睡眠模式下创建计时器(SDK 3)

1) A new handler for the KERNEL timer

必须在APP\u api.h文件的enum APP\u MSG中声明超时事件的消息。在这种情况下,我们将使用:APP\u ADV\u BEACON\u INACTIVE\u MODE。

A message handler function for the BLE timer must be added in the app_task_handlers.h file:

2)必须调用先前声明的处理程序名称的app_timer_set。

调用app_timer_set函数来启动app_dialog_beacon_proj.c文件中的计时器:

Note: time out: 30 000 => 5 min: This is the highest timeout the timer can achieve.

在唤醒时如何在唤醒期间使用ke_timer?

ke_timer的想法是使用BLE定时器的使用,并将BLE定时器中断转换为KE_MESSAGE并发送到相应的任务消息队列。
KE_TIMER机制需要主循环计划,主循环计划需要BLE处于活动状态。
In some application design, system will enter permanent sleep to waiting for external wakeup which will power down BLE.
After CPU wakeup, CPU will wakeup BLE through wake_ble_up(). This function will write certain register to issue ble wakeup req.
BLE最终会在几次中断后激活,一旦在此阶段设置BLE计时器,系统将出现异常的BLE计时器行为。
Several customers met ke_timer didn’t work correctly after wake-up from sleep randomly, or some customers claimed its design work well only without enable sleep.
这种现象是一个特定的计时器(10s)在随机时间戳中发生,有时在3s、6s、8s甚至100ms之后,或者不执行。
我们确定Dialog SDK/参考设计有一个规则要遵循,以确保ble\u timer得到正确的编程,并且在唤醒后timer消息处理程序得到正确的执行。

在HID参考中,我们以下描述以确保在IDLE_ST开始后确保BLE定时器运行。
****************************************************************************************
@brief Handler of a dummy TASK_APP msg sent to trigger the adv timer
In case of advertising start from IDLE_ST, a dummy message is sent to the TASK_APP.
当BLE被唤醒时,此消息被放入队列中。当处理程序被调用时,
可以确定BLE正在运行,计时器可能会启动。
*
*
@return ke_msg_consumed.
****************************************************************************************
* /
int app_start_adv_msg_handler(ke_msg_id_t const msgid”

In SDK 3.0.6 , we have the similar wakeup msg,
//Wakeup BLE here

#if(ext_sleep_enabled)
app_set_extended_sleep();
#elif(启用深度睡眠)
app_set_deep_sleep();
#else
app_disable_sleep();
#万一
SetBits32(GP\ U CONTROL\ U REG,BLE\ U WAKEUP\ U REQ,1);
app_ble_ext_wakeup_off(); ke_msg_send_basic(APP_WAKEUP_MSG, TASK_APP, NULL);

ke_timer should start only after APP_WAKEUP_MSG handle get executed.

我们通常会遇到这种情况,因为这种情况很容易发生,低于WakeUp回电的代码将触发此案例:
start_adv_undirected();//邮件句柄将仅在CPU运行到主循环之后执行
app_timer_set(app_hid_adv_timer,task_app,avd_key_press_to);//表示,App_Timer_Set将在任何MSG实际执行的消息之前运行,这实际上将在BLE处于活动状态之前编程BLE定时器。

Workaround

We have done the following extension of the app_setup_timer. It checks if the BLE is active and if not, it will automatically generate the message and setup the timer by itself.
此解决方法还有一个限制,以确保未发送重复的Dummy App_Create_New_Timer。

uint8_t app_check_ble_active(void)
{
return((GetBits16(CLK\u RADIO\u REG,BLE\u ENABLE)==1)&(GetBits32(BLE\u DEEPSLCNTL\u REG,DEEP\u SLEEP\u STAT)==0)&&\
!(rwip_prevent_sleep_get() & RW_WAKE_UP_ONGOING)) ;
}

int app_create_new_timer(ke_msg_id_t const msgid,const struct create_new_timer_struct*参数,
ke_task_id_t const dest_id, ke_task_id_t const src_id)
{
ke_timer_set(param->timer_id, param->task_id, param->delay);
返回(已消耗的消息);
}

/**

****************************************************************************************
*@brief Start a kernel timer
*
* @return void.
****************************************************************************************
* /
void app_timer_set(ke_msg_id_t const timer_id, ke_task_id_t const task_id, uint16_t delay)
{
//延迟不得超过最大允许
if(delay > KE_TIMER_DELAY_MAX)
{
delay = KE_TIMER_DELAY_MAX;
}
// Delay should not be zero
否则if(delay == 0)
{
delay = 1;
}
if(app_check_ble_active()))
ke_timer_set(timer_id,task_id,延迟);
else
{
app_ble_force_wakeup();// ket_up ble发送一条消息,等待在执行之前醒来的ble
struct create_new_timer_struct * req = ke_msg_alloc(app_create_new_timer,task_app,task_app,create_new_timer_struct);
req->delay=delay;
req-> task_id = task_id;
req-> timer_id = timer_id;
KE_MSG_SEND(REQ);
}

RSSI值在连接和广告模式下不一致。 在连接模式下,GAPC\ U CON\ U RSSI\ IND返回的RSSI值是原始RSSI值的一半。
The application must double the param->rssi value before applying the raw RSSI to dBm formula.
如何在连接时进行广告?

为了在连接到中央设备时进行播发,必须执行以下步骤:

1)在void app_connection_func(struct gapc_connection_req_ind const * param)中,您必须执行以下操作:

2) Create a new flag:

3) In the int gapc_disconnect_ind_handler(), you must do:

4)在app_disconnect_func(dest_id,param)中;你必须这样做:

5) 在int gapm\u cmp\u evt\u处理程序中,必须执行以下操作:

为什么在使用app_easy_gap_ divented_advertise_start()API时,我无法使用5.0.3 SDK执行指示通告?

This is a known issue and will be fixed in a new release of the SDK5. The app_easy_gap_directed_ advertise_start() mistakenly invokes the app_easy_gap_undirected_advertise_start_create_msg(); replace this with app_easy_gap_directed_advertise_start_create_msg() and also add the parameters of intv_min and intv_max in the parameters of the message like the following snippet, and then add the your custom direct advertising function.

static struct gapm_start_advertise_cmd * app_easy_gap_dircated_advertise_start_create_msg(void)
{
//为GAP分配消息
if (adv_cmd == NULL)
{
struct gapm_start_advertise_cmd *cmd;
cmd = app_advertise_start_msg_create();
adv_cmd = cmd;
if(user_config)
{
cmd->op.code = user_directed_advertise_conf.advertise_operation;
cmd->op.addr\u src=user\u directed\u advertise\u conf.address\u src;
cmd-> channel_map = user_direded_advertise_conf.channel_map;
cmd-> intv_min = 32;
cmd->intv_max = 32;
ASSERT_WARNING(user_directed_advertise_conf.advertise_operation == GAPM_ADV_DIRECT);
cmd - > info.direct。addr_type = user_directed_advertise_target_address_conf.addr_type;
memcpy(命令->info.direct.addr.addr,
用户\定向\广告\目标\地址\配置地址,BD\地址\长度)
}
else
memcpy((void *)cmd,(void *)和default_dir_adv_cmd,sizeof(default_dir_adv_cmd));
}
return(adv_cmd);
}

void user_advertise(void)
{
app_easy_gap_directed_advertise_start();
}

1458x家族可以支持多个连接吗? 580和583最多可支持6个连接,581最多可同时支持8个连接只要作为中央操作时。作为外围设备运行时,可以支持的最大连接是只有一个.
1458x家族可以支持多个角色吗? The 4.1 Bluetooth spec defines that specific feature as optional. The 58x family cannot support multiple roles (Central and Peripheral at the same time). At the moment what is supported is role switching. In order to achieve this, one has to issue a GAPM_RESET_CMD and set the appropriate role of the 580 when the GAPM_SET_DEV_CONFIG_CMD is issued upon the completion of the GAPM_RESET.
如何更改软件中使用的低功耗时钟?

The user can change the low power clock in software (depending on which oscillator he wants to use) from the CFG_LP_CLK definition and place the corresponding values.

  • lp_clk_xtal32 - 使用外部振荡器
  • LP_CLK_RCX20 - 使用内部振荡器
  • LP_CLK_FROM_OTP - use the oscillator that is defined in the OTP header
How to make my device advertise with ADV_SCAN_IND packets ?

adv_scan_ind PDU用于在不可连接模式下操作时发送扫描响应的外围设备,以便在580上执行此操作,您必须在不可连接模式下设置设备广告,并设置扫描响应数据。使用上述配置,堆栈将使用适当的PDU(ADV_SCAN_IND)。

在连接时,发送通知我可以从中央正确DSIConnect,我可以再次看到设备广告,但是当我超出范围时,设备断开连接它永远不会启动广告。问题是什么? 当您从设备发送通知时,您可以为消息和要发送的数据分配空间。当设备连接并发送数据时,在将数据发送到客户端设备时释放您为消息和数据分配的空间。当正确断开连接时,设备停止发送通知,以便正常运行代码,并触发断开连接处理,以便广告再次启动。在设备击中设备击中断开连接器之前,它继续生成未离开设备的通知,因此它们累积到堆和580复位。一个正确的解决方案是为了确保先前通知在通过使用适当的GATTC请求类型(GattC_Notify或GattC_Indicate)捕获GattC_CMP_EVT之前,先前的通知已成功离开580。
我如何在SDK5上将实现的配置文件添加到我的模板或示例项目?

在SDK中添加配置文件非常简单,因为已经实现了App_.c / .h文件的配置文件(例如,我们将使用电池配置文件的文件作为演示)。

  1. 在sdk_profiles项目目录中添加bass.c和bass_task.c。
  2. Add the corresponding header files via the target options menu in the C/C++ tab.
  3. 在SDK_APP Project文件夹目录中添加app_bass.c和app_bass_task.c。
  4. 在user_profiles_config.h中添加#include bass.h.h。
  5. Add the specific service to your advertising data (optional, just to indicate that you support that particular service).
  6. In the user_modules_config.h file make sure that in the available defines the corresponding EXCLUDE_DLG_profile is set to 0. For example for the battery service the EXCLUDE_DLG_BASS should be set to zero.

Note: In the user_modules_config.h the modules that the user can exclude are not only the profile modules but features of the SDK as well.

以上所有内容都是用户在项目中添加已经实现的概要文件时应该遵循的标准过程。

当应用程序级别没有实现(没有app\u profile和app\u profile\u任务实现)时,如何将配置文件添加到项目中?

并不是所有的配置文件都有应用程序级实现(大多数配置文件都没有app\u profile.c和app\u profile\u task.c对应),因此用户必须实现这一点。这些文件将包括概要文件级实现的所有实现和消息处理。

A short example is given by using the already implemented battery profile.

创建这两个文件的一般规则是app\u bass.c包含所有启动函数(触发操作的void函数),app\u bass\u task.c包含在操作结束时触发的处理函数,应用程序应相应地进行操作。

For example, when the device powers up it will eventually start to create the database for the services that are included, all of the app_profile.c files include app_profile_create_db() function, the battery profile has the app_bass_create_db().

  • 调用app\u bass\u create\u db()函数并发送bass\u create\u db\u REQ消息。
  • 消息由bass_task.c文件中的bass_create_db_req_handler()处理。
  • 一旦创建数据库超过该函数,就会向应用程序级别发送由batt_create_db_cfm_handler()处理的应用程序级别。

This is the philosophy that the profiles follow in order to interact with the application.

  • 应用程序通过发送消息触发所需的操作。
  • 配置文件捕获该消息并执行操作并向应用程序发送确认/指示。
  • The application takes the confirmation/indication message in order to know that the action is completed and acts accordingly.
如何将Suota配置文件添加到我的SDK 5.0.3应用程序?

在项目中添加SUOTA概要文件是一项非常简单的任务,可以按照以下步骤将概要文件集成到项目中。

  • In the sdk_profiles folder, check if the spotar files are included (spotar.c and spotar_task.c). If not included add them by right click and selecting "Add existing files to group".
  • 在SDK_APP文件夹中,检查Spotar应用程序文件是否包含(app_spotar.c和app_spotar_task.c),如果不是,请添加它们以及先前提到的。
  • Add the on_spotar_status_change() function in your project’s main file. (paste the below snippet code or you can find the same snippet in the proximity reported example).

    #if BLE_SPOTA_RECEIVER
    /**
    ****************************************************************************************
    *@brief SPOTAR session start or stop event handler.
    *
    *@param[in] spotar_event SPOTAR_START/SPOTAR_STOP
    *
    * @return void.
    ****************************************************************************************
    * /
    void on_spotar_status_change(const uint8_t spotar_event)
    {
    #如果定义了(\uu DA14583\uuu)&&(!SPOTAR(SPI禁用)
    Int8_t man_dev_id = 0;

    man_dev_id=spi_flash_enable(spi_EN_GPIO_端口,spi_EN_GPIO_PIN);
    if(man_dev_id == spi_flash_auto_detect_not_detected)
    {
    //设备未被识别。使用默认参数。
    //或者,可以在这里断言错误。
    spi_flash_init(spi_flash_default_size,spi_flash_default_page);
    }if( spotar_event == SPOTAR_END )
    {
    // Power down SPI Flash
    spi_flash_power_down();
    }
    #万一
    }#endif//(BLEŠU SPOTAŠU接收器)

  • Add the user_profile_callbacks variable in the user_callback_config.h file (for the SUOTA implementation the below snippet is enough):

    static const struct profile\u callbacks user\u profile\u callbacks={
    #if(ble_spota_receiver)
    .on\u spotar\u status\u change=在\u spotar\u status\u change上,
    #万一
    };

  • SUOTA应用程序需要在广告字符串中查找特定数据,以便在查找到的设备屏幕中显示设备。SUOTA应用程序的UUID是ADV\u UUID\u SPOTAR\u服务定义(0XF5,0xFE)。通过将这些字节放入广告字符串中,android手机能够发现设备。

重要的提示:如果您使用的是BLE示例,请确保在user\u modules\u config.h文件中不排除任何要使用的概要文件。通过将definition EXCLUDE \u DLG \u SPOTAR设置为1,app \u SPOTAR.c和app \u SPOTAR \u task.c将不会用作应用程序级实现。

如何读取并将RSSI值转换为DBM?

有两种读取RSSI值的方法:

1.在作为中央操作时读取广告字符串的值。

当中央接收广告指示时,虽然作为中央和人们想要读取广告串的RSSI,但可以轻松完成。当广告字符串到达​​中央时,应用程序将通过APP_ON_ADV_REPORT_INC回调函数通知到达。该函数的参数是GAPM_ADV_REPORT_IND,其中包括广告消息的RSSI值的其他信息。使用该值并应用以下公式,可以转换为DBM RSSI(DBM)=(0.474 * LRES) - 112.4。

  • 0.474值是DBB / LSB中的RSSI步长。
  • LRES是RXRSSI[7:0]寄存器=param->rssi的十进制值。
  • -112.4 dBm will be the minimum read out value for the RXRSSI[7:0] register while no signal condition.

An implementation of the above calculation can be found in the proximity monitor in windows application at the gapm_adv_report_ind_handler() function.

2.作为外设工作时,在连接时读取RSSI值。

While operating as a central and one wants to get the RSSI value the application has to make a request to the stack in order to get an indication regarding the RSSI value. So the application should send a GAPC_GET_INFO_CMD with a GAPC_GET_CON_RSSI as the operation of the command. After that the stack will respond with a GAPC_CON_RSSI_IND and the application can retrieve the rssi value from there.

有关命令的更多信息,请检查RW-BLE-GAP-IS.PDF

Using the value above one can make the dBm conversion by using the above formula but the value returned from the GAPC_CON_RSSI_IND has to be doubled before making the calculations.

An application of the above calculation can be found in the proximity monitor windows application in the gapc_con_rssi_ind_handler() function.

如何更改播发类型标志?

广告字符串始终以一系列字节序列从指示设备的某些基本功能(例如0x02,0x01,0x06 - 长度,标记标签类型,一般可选模式/ br / EDR)。规范说明如果将这些字节设置为零,则可以省略这些字节。在580的情况下,由于它是BL / EDR不支持的位域,因此不能省略这些字节。此外,这些字节也无法由用户更改,ROM堆栈负责将这些字节放在广告字符串中,如果例如一个人想要使设备有限可发现的,他必须在GAP_LIM_DISCOVERABLE中设置设备的广告模式将照顾其余部分并将适当的标志放在字符串中。