ble_qiot_config.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
  3. * Licensed under the MIT License (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://opensource.org/licenses/MIT
  6. * Unless required by applicable law or agreed to in writing, software distributed under the License is
  7. * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  8. * either express or implied. See the License for the specific language governing permissions and
  9. * limitations under the License.
  10. *
  11. */
  12. #ifndef QCLOUD_BLE_QIOT_CONFIG_H
  13. #define QCLOUD_BLE_QIOT_CONFIG_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <stdio.h>
  18. #include <stdint.h>
  19. #define BLE_QIOT_SDK_VERSION "1.5.0" // llsync sdk version
  20. #define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch
  21. // the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power.
  22. // if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast
  23. // stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and
  24. // BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped.
  25. // if the device in the bound state, broadcast dose not stop automatically.
  26. #define BLE_QIOT_BUTTON_BROADCAST 1
  27. #if BLE_QIOT_BUTTON_BROADCAST
  28. #define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms
  29. #endif //BLE_QIOT_BUTTON_BROADCAST
  30. // some data like integer need to be transmitted in a certain byte order, defined it according to your device
  31. #define __ORDER_LITTLE_ENDIAN__ 1234
  32. #define __ORDER_BIG_ENDIAN__ 4321
  33. #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
  34. // the following definition will affect the stack that LLSync used,the minimum value tested is
  35. // 2048(BLE_QIOT_EVENT_MAX_SIZE is 128, BLE_QIOT_EVENT_BUF_SIZE is 23 ) the max length that llsync event data, depends
  36. // on the length of user data reported to Tencent Lianlian at a time
  37. #define BLE_QIOT_EVENT_MAX_SIZE (128)
  38. // the minimum between BLE_QIOT_EVENT_MAX_SIZE and mtu
  39. #define BLE_QIOT_EVENT_BUF_SIZE (23)
  40. #ifdef BSP_USING_SOFTDEVICE
  41. #include "nrf_log.h"
  42. #include "nrf_log_ctrl.h"
  43. #include "nrf_log_default_backends.h"
  44. #endif
  45. // in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function
  46. #define BLE_QIOT_USER_DEFINE_HEXDUMP 1
  47. #if BLE_QIOT_USER_DEFINE_HEXDUMP
  48. #define ble_qiot_log_hex(level, hex_name, data, data_len) \
  49. do { \
  50. } while (0)
  51. #endif // BLE_QIOT_USER_DEFINE_HEXDUMP
  52. // Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or
  53. // timestamp
  54. #define BLE_QIOT_LOG_PRINT(...) printf(__VA_ARGS__)
  55. #define BLE_QIOT_LLSYNC_STANDARD 1 // support llsync standard
  56. #if BLE_QIOT_LLSYNC_STANDARD
  57. // nrf52832xxAA Flash size is 512KB, nrf52832xxAB Flash size is 512KB, be carefol of the address!
  58. #define BLE_QIOT_RECORD_FLASH_ADDR 0x7e000 // qiot data storage address
  59. #define BLE_QIOT_RECORD_FLASH_PAGESIZE 4096 // flash page size, see chip datasheet
  60. #define BLE_QIOT_RECORD_FLASH_PAGENUM 2 // how many pages qiot use
  61. #define APP_BLE_OBSERVER_PRIO 3 /**< Application's BLE observer priority. You shouldn't need to modify this value. */
  62. #define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */
  63. #define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */
  64. #define APP_ADV_DURATION \
  65. BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising time-out (in units of seconds). When set to 0, we will \
  66. never time out. */
  67. // define user develop version, pick from "a-zA-Z0-9.-_" and length limits 1~32 bytes.
  68. // must be consistent with the firmware version that user write in the iot-explorer console
  69. // refer https://cloud.tencent.com/document/product/1081/40296
  70. #define BLE_QIOT_USER_DEVELOPER_VERSION "0.0.1"
  71. #endif // BLE_QIOT_LLSYNC_STANDARD
  72. #if (1 == BLE_QIOT_LLSYNC_STANDARD) && (1 == BLE_QIOT_LLSYNC_CONFIG_NETX)
  73. #error "llsync standard and llsync configure network is incompatible"
  74. #endif
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif // QCLOUD_BLE_QIOT_CONFIG_H