打开跟踪调试模块,错误定位如下:
error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\ble_app.c:1293
我们转到ble_app.c 的1293行看一下:

其实看一下ble_ancs_c_init()的返回值,就知道是在函数内部已经出错了,进入到函数中继续跟踪调试。

ret_code_t ble_ancs_c_init(ble_ancs_c_t * p_ancs, ble_ancs_c_init_t const * p_ancs_init)
{uint32_t err_code;//Verify that the parameters needed for to initialize this instance of ANCS are not NULL.VERIFY_PARAM_NOT_NULL(p_ancs);VERIFY_PARAM_NOT_NULL(p_ancs_init);VERIFY_PARAM_NOT_NULL(p_ancs_init->evt_handler);//Initialize state for the attribute parsing state machine.p_ancs->parse_info.parse_state = COMMAND_ID;p_ancs->parse_info.p_data_dest = NULL;p_ancs->parse_info.current_attr_index   = 0;p_ancs->parse_info.current_app_id_index = 0;p_ancs->evt_handler   = p_ancs_init->evt_handler;p_ancs->error_handler = p_ancs_init->error_handler;p_ancs->conn_handle   = BLE_CONN_HANDLE_INVALID;p_ancs->service.data_source_cccd.uuid.uuid  = BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG;p_ancs->service.notif_source_cccd.uuid.uuid = BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG;// Make sure instance of service is clear. GATT handles inside the service and characteristics are set to @ref BLE_GATT_HANDLE_INVALID.memset(&p_ancs->service, 0, sizeof(ble_ancs_c_service_t));tx_buffer_init();// Assign UUID types.err_code = sd_ble_uuid_vs_add(&ble_ancs_base_uuid128, &p_ancs->service.service.uuid.type);VERIFY_SUCCESS(err_code);err_code = sd_ble_uuid_vs_add(&ble_ancs_cp_base_uuid128, &p_ancs->service.control_point_char.uuid.type);VERIFY_SUCCESS(err_code);err_code = sd_ble_uuid_vs_add(&ble_ancs_ns_base_uuid128, &p_ancs->service.notif_source_char.uuid.type);VERIFY_SUCCESS(err_code);err_code = sd_ble_uuid_vs_add(&ble_ancs_ds_base_uuid128, &p_ancs->service.data_source_char.uuid.type);VERIFY_SUCCESS(err_code);// Assign UUID to the service.p_ancs->service.service.uuid.uuid = ANCS_UUID_SERVICE;p_ancs->service.service.uuid.type = p_ancs->service.service.uuid.type;return ble_db_discovery_evt_register(&p_ancs->service.service.uuid);
}

就是在这个函数中出现错误的,我们看一下nRF52832的错误的类型:

/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions* @{ */
#define NRF_ERROR_BASE_NUM      (0x0)       ///< Global error base
#define NRF_ERROR_SDM_BASE_NUM  (0x1000)    ///< SDM error base
#define NRF_ERROR_SOC_BASE_NUM  (0x2000)    ///< SoC error base
#define NRF_ERROR_STK_BASE_NUM  (0x3000)    ///< STK error base
/** @} */#define NRF_SUCCESS                           (NRF_ERROR_BASE_NUM + 0)  ///< Successful command
#define NRF_ERROR_SVC_HANDLER_MISSING         (NRF_ERROR_BASE_NUM + 1)  ///< SVC handler is missing
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED      (NRF_ERROR_BASE_NUM + 2)  ///< SoftDevice has not been enabled
#define NRF_ERROR_INTERNAL                    (NRF_ERROR_BASE_NUM + 3)  ///< Internal Error
#define NRF_ERROR_NO_MEM                      (NRF_ERROR_BASE_NUM + 4)  ///< No Memory for operation
#define NRF_ERROR_NOT_FOUND                   (NRF_ERROR_BASE_NUM + 5)  ///< Not found
#define NRF_ERROR_NOT_SUPPORTED               (NRF_ERROR_BASE_NUM + 6)  ///< Not supported
#define NRF_ERROR_INVALID_PARAM               (NRF_ERROR_BASE_NUM + 7)  ///< Invalid Parameter
#define NRF_ERROR_INVALID_STATE               (NRF_ERROR_BASE_NUM + 8)  ///< Invalid state, operation disallowed in this state
#define NRF_ERROR_INVALID_LENGTH              (NRF_ERROR_BASE_NUM + 9)  ///< Invalid Length
#define NRF_ERROR_INVALID_FLAGS               (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
#define NRF_ERROR_INVALID_DATA                (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
#define NRF_ERROR_DATA_SIZE                   (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size
#define NRF_ERROR_TIMEOUT                     (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
#define NRF_ERROR_NULL                        (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
#define NRF_ERROR_FORBIDDEN                   (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
#define NRF_ERROR_INVALID_ADDR                (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
#define NRF_ERROR_BUSY                        (NRF_ERROR_BASE_NUM + 17) ///< Busy
#define NRF_ERROR_CONN_COUNT                  (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded.
#define NRF_ERROR_RESOURCES                   (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation
#define NRF_ERROR_INVALID_LICENSE_KEY         (NRF_ERROR_BASE_NUM + 64) ///< Bad license key

根据返回的错误码,可以确定内存不足。

可以根据三个方向调试内存:

1.堆栈内存

在startup_config.h中

* Define size of stack. Size must be multiple of 4. */
#define __STARTUP_CONFIG_STACK_SIZE   0x1000/* Define size of heap. Size must be multiple of 4. */
#define __STARTUP_CONFIG_HEAP_SIZE   0x1000

2.Keil中内存设置

3.蓝牙属性列表大小

在sdk_config.h中,根据使用的蓝牙服务,以及服务特征的数量来调整对应的大小,确保蓝牙属性列表不会越界。

// <o> NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4.
#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 2048
#endif
从上面三个方向入手,虽然能解决一些常见的内存不足的错误,但是还是没有搞定NRF_ERROR_NO_MEM这个错误。

最后定位错误出现在sd_ble_uuid_vs_add()这个函数;当时没有什么思路,就等啊等…,第二天看书的时候突然灵光一闪,这里添加的是自定义服务,莫非nRF中的自定义服务需要单独处理一下……顺着这个思路,真的找到了问题的根源。

// <o> NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs.
#ifndef NRF_SDH_BLE_VS_UUID_COUNT
#define NRF_SDH_BLE_VS_UUID_COUNT 1
#endif

我在ble_ancs_c_init()中添加了4个自定义服务,除了苹果的ANCS,还在使用了一个自定义服务,总的用来5个,修改#define NRF_SDH_BLE_VS_UUID_COUNT 5之后完美运行ing

我想统计下想做蓝牙开发的小伙伴多不多。

如果想做蓝牙开发但是目前还没有入门的小伙伴请在下面评论个‘1’;

已经入门的小伙伴评论个‘2’;

大神自己直接评论‘666’吧;

[玩转BLE]nRF52832提示ERROR 4 [NRF_ERROR_NO_MEM]的处理方法相关推荐

  1. 饥荒启动服务器显示error,玩饥荒游戏提示“error during initialization”错误解决方法...

    有关win10系统玩饥荒游戏提示"error during initialization"错误的操作方法想必大家有所耳闻.但是能够对win10系统玩饥荒游戏提示"erro ...

  2. 饥荒启动服务器显示error,Win10电脑运行饥荒游戏提示error during initialization解决方法...

    喜欢单机游戏的小伙伴,应该有听过<饥荒>这款游戏吧,最近有用户在Win10电脑上运行该游戏,却提示了error during initialization,导致无法正常玩该游戏,让用户感到 ...

  3. win10饥荒服务器未响应,win10系统玩饥荒提示error during initialization的解决方案

    win10系统使用久了,好多网友反馈说win10系统玩饥荒提示error during initialization的问题,非常不方便.有什么办法可以永久解决win10系统玩饥荒提示error dur ...

  4. mysql登陆提示ERROR 1045 (28000): Access denied for user

    今天安装zabbix,安装完成之后在最上面提示如下所示 检查日志如下显示 显示连接数据库失败,登录mysql给zabbix授权之后发现zabbix彻底起不来了 数据库也登陆不进去,提示ERROR 10 ...

  5. yum安装软件包提示Error Downloading Packages解决方法

    yum安装软件包提示Error Downloading Packages解决方法 参考文章: (1)yum安装软件包提示Error Downloading Packages解决方法 (2)https: ...

  6. Xamarin.iOS项目提示error MSB3174:”TargetFrameworkVersion”的值无效

    Xamarin.iOS项目提示error MSB3174:"TargetFrameworkVersion"的值无效 错误信息:MSBulid\14.0\bin\Microsoft. ...

  7. error 1309 mysql_MySQ登录提示ERROR 1045 (28000)错误如何解决

    我们在登录mysql的时候,会经常出现错误,本文主要为大家详细介绍了MySQ登录提示ERROR 1045 (28000)错误的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大 ...

  8. c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法

    c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法 时间:2017-05-09 12:32:06阅读:234评论 ...

  9. 试用版office 2010中提示Error opening SocialConnectorRes.dll求解!!

    试用版office 2010中提示Error opening C:\Program Files\Microsoft Office\Office14\2052\SocialConnectorRes.dl ...

最新文章

  1. zend studio 10破解/汉化
  2. python学习笔记系列-方便自我学习
  3. 【Python】快速认识Pandas的10大索引
  4. 安卓学习 之 多媒体技术(八)
  5. linux下udp多线程编程
  6. Atlassian 域名被曝一次点击账户接管漏洞 可导致供应链攻击
  7. Webrct之demo运行
  8. Kubernetes 小白学习笔记(29)--kubernetes云原生应用开发-基于Elasticsearch技术栈搭建Kubernetes的集群Logging设施
  9. 数商云:B2C商城网站建设功能框架大解析
  10. B站韩顺平版Linux学习笔记(很全啊!)
  11. 车辆路径问题之jsprit(一):认识jsprit
  12. STM32压力传感器信号采集-24位AD HX720 HX711 原理介绍
  13. 【neusoft】 Linux 的学习与使用
  14. Leecode 55跳跃游戏
  15. NVD软件漏洞数据处理及分类方法总结
  16. 为什么印度人可以“称霸”硅谷?
  17. android仿酷狗界面,Android仿酷狗动感歌词(支持翻译和音译歌词)显示效果
  18. zeppelin 下载和安装
  19. 什么是谐波?谐波的危害
  20. Lua获取本地IP地址

热门文章

  1. 你不知道的Redis:RedisCluster与JedisCluster
  2. App开发中如何实现灰度发布?
  3. 一种前端灰度发布方案
  4. 【Python】实训8:企业所得税回归模型(Pearson相关系数、Lasso、灰色预测模型、SVR)
  5. python清空变量值_Python的变量 - YGH1215的个人空间 - OSCHINA - 中文开源技术交流社区...
  6. android开发 如何自我提升
  7. 《App Store 审核指南》中文版本发布
  8. System_Verilog打印格式
  9. 创建同义词 synonym
  10. 防火墙性能测试实战篇-测试仪