# Try to use the same branch name for esp-idf-template that we're
# using on esp-idf. If it doesn't exist then just stick to the default
# branch
- - git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-idf-template default branch..."
+ - git checkout ${CI_COMMIT_REF_NAME} || echo "Using esp-idf-template default branch..."
# Test debug build (default)
- make all V=1
# Now test release build
script:
- git clone $SSC_REPOSITORY
- cd SSC
- - git checkout ${CI_BUILD_REF_NAME} || echo "Using SSC default branch..."
+ - git checkout ${CI_COMMIT_REF_NAME} || echo "Using SSC default branch..."
- ./gen_misc_ng.sh
build_at:
script:
- git clone $GITLAB_SSH_SERVER/application/esp-at.git
- cd esp-at
- - git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-at default branch..."
+ - git checkout ${CI_COMMIT_REF_NAME} || echo "Using esp-at default branch..."
- make defconfig
- make
# mechanism work, but this is the next best thing
- mkdir build_examples
- cd build_examples
- - ${IDF_PATH}/make/build_examples.sh
+ - ${IDF_PATH}/make/build_examples.sh -j5
build_docs:
stage: build
- /^release\/v/
- /^v\d+\.\d+(\.\d+)?($|-)/
variables:
- LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
+ LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test"
REPORT_PATH: "$CI_PROJECT_DIR/CI_Test_Report"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/tools/ModuleDefinition.yml"
script:
# calc log path
- VER_NUM=`git rev-list HEAD | wc -l | awk '{print $1}'`
- - SHA_ID=`echo $CI_BUILD_REF | cut -c 1-7`
+ - SHA_ID=`echo $CI_COMMIT_SHA | cut -c 1-7`
- REVISION="${VER_NUM}_${SHA_ID}"
# replace / to _ in branch name
- - ESCAPED_BRANCH_NAME=`echo $CI_BUILD_REF_NAME | sed 's/\//___/g'`
+ - ESCAPED_BRANCH_NAME=`echo $CI_COMMIT_REF_NAME | sed 's/\//___/g'`
# result path and artifacts path
- RESULT_PATH="$CI_PROJECT_NAME/$ESCAPED_BRANCH_NAME/$REVISION"
- - ARTIFACTS_PATH="$GITLAB_HTTP_SERVER/idf/esp-idf/builds/$CI_BUILD_ID/artifacts/browse/$CI_BUILD_REF"
+ - ARTIFACTS_PATH="$GITLAB_HTTP_SERVER/idf/esp-idf/builds/$CI_JOB_ID/artifacts/browse/$CI_COMMIT_SHA"
# clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script
- git config --global user.name "ci-test-result"
# commit test result
- git add .
- - git commit . -m "update test result for $CI_PROJECT_NAME/$CI_BUILD_REF_NAME/$CI_BUILD_REF, pipeline ID $CI_PIPELINE_ID" || exit 0
+ - git commit . -m "update test result for $CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHA, pipeline ID $CI_PIPELINE_ID" || exit 0
- git push origin master
- test "${TEST_RESULT}" = "Pass" || exit 1
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git remote add github git@github.com:espressif/esp-idf.git
# What the next line of script does: goes through the list of refs for all branches we push to github,
- # generates a snippet of shell which is evaluated. The snippet checks CI_BUILD_REF against the SHA
+ # generates a snippet of shell which is evaluated. The snippet checks CI_COMMIT_SHA against the SHA
# (aka objectname) at tip of each branch, and if any SHAs match then it checks out the local branch
# and then pushes that ref to a corresponding github branch
- #
- # NB: In gitlab 9.x, CI_BUILD_REF was deprecated. New name is CI_COMMIT_REF. If below command suddenly
- # generates bash syntax errors, this is probably why.
- - eval $(git for-each-ref --shell bash --format 'if [ $CI_BUILD_REF == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
+ - eval $(git for-each-ref --shell bash --format 'if [ $CI_COMMIT_SHA == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
deploy_docs:
# must be triggered with CHECK_LINKS=Yes, otherwise exit without test
- test "$CHECK_LINKS" = "Yes" || exit 0
# can only run on master branch (otherwise the commit is not on Github yet)
- - test "${CI_BUILD_REF_NAME}" = "master" || exit 0
+ - test "${CI_COMMIT_REF_NAME}" = "master" || exit 0
- cd docs
- make linkcheck
artifacts:
before_script:
- echo "skip update submodule"
script:
- - git checkout ${CI_BUILD_REF_NAME}
+ - git checkout ${CI_COMMIT_REF_NAME}
# commit start with "WIP: " need to be squashed before merge
- - 'git log --pretty=%s master..${CI_BUILD_REF_NAME} | grep "^WIP: " || exit 0 && exit 1'
+ - 'git log --pretty=%s master..${CI_COMMIT_REF_NAME} | grep "^WIP: " || exit 0 && exit 1'
assign_test:
<<: *build_template
# clone test script to assign tests
- git clone $TEST_SCRIPT_REPOSITORY
- cd auto_test_script
- - git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
+ - git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
# assign unit test cases
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/unit_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/test_bins
# assgin integration test cases
# set git strategy to fetch so we can get esptool without update submodule
GIT_STRATEGY: fetch
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
- LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
+ LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
- CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/integration_test/CIConfigs/$CI_BUILD_NAME.yml"
+ CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/integration_test/CIConfigs/$CI_JOB_NAME.yml"
IDF_PATH: "$CI_PROJECT_DIR"
artifacts:
# clone test bench
- git clone $TEST_SCRIPT_REPOSITORY
- cd auto_test_script
- - git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
+ - git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
# run test
- - python CIRunner.py -l "$LOG_PATH/$CI_BUILD_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE
+ - python CIRunner.py -l "$LOG_PATH/$CI_JOB_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE
# template for unit test jobs
.unit_test_template: &unit_test_template
variables:
GIT_STRATEGY: fetch
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
- LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
+ LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/unit_test"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
- CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/CIConfigs/$CI_BUILD_NAME.yml"
+ CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/CIConfigs/$CI_JOB_NAME.yml"
IDF_PATH: "$CI_PROJECT_DIR"
UT_001_01:
ESP_BT_STATUS_AUTH_FAILURE, /* relate to BT_STATUS_AUTH_FAILURE in bt_def.h */
ESP_BT_STATUS_RMT_DEV_DOWN = 10, /* relate to BT_STATUS_RMT_DEV_DOWN in bt_def.h */
ESP_BT_STATUS_AUTH_REJECTED, /* relate to BT_STATUS_AUTH_REJECTED in bt_def.h */
- ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR,
+ ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR, /* relate to BT_STATUS_INVALID_STATIC_RAND_ADDR in bt_def.h */
} esp_bt_status_t;
* @}
*/
-#define ESP_LE_KEY_NONE 0
-#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */
-#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */
-#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */
-#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/
-#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4)
-#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */
-#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */
-#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */
-typedef uint8_t esp_ble_key_type_t;
-
-#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/
-#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */
-#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */
-#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */
-#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */
-#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */
-#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */
+/* relate to BTM_LE_KEY_xxx in btm_api.h */
+#define ESP_LE_KEY_NONE 0 /* relate to BTM_LE_KEY_NONE in btm_api.h */
+#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */ /* relate to BTM_LE_KEY_PENC in btm_api.h */
+#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */ /* relate to BTM_LE_KEY_PID in btm_api.h */
+#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */ /* relate to BTM_LE_KEY_PCSRK in btm_api.h */
+#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/ /* relate to BTM_LE_KEY_PLK in btm_api.h */
+#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4) /* relate to BTM_LE_KEY_LLK in btm_api.h */
+#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */ /* relate to BTM_LE_KEY_LENC in btm_api.h */
+#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */ /* relate to BTM_LE_KEY_LID in btm_api.h */
+#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */ /* relate to BTM_LE_KEY_LCSRK in btm_api.h */
+typedef uint8_t esp_ble_key_type_t;
+
+/* relate to BTM_LE_AUTH_xxx in btm_api.h */
+#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in btm_api.h */
+#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in btm_api.h */
+#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in btm_api.h */
+#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in btm_api.h */
+#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in btm_api.h */
+#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in btm_api.h */
+#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in btm_api.h */
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
-#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */
-#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */
-#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */
-#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */
-#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */
+/* relate to BTM_IO_CAP_xxx in btm_api.h */
+#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in btm_api.h */
+#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in btm_api.h */
+#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ /* relate to BTM_IO_CAP_IN in btm_api.h */
+#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ /* relate to BTM_IO_CAP_NONE in btm_api.h */
+#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in btm_api.h */
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
/// Scan response data maximum length
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
+/* relate to BTM_BLE_AD_TYPE_xxx in btm_ble_api.h */
/// The type of advertising data(not adv_type)
typedef enum {
- ESP_BLE_AD_TYPE_FLAG = 0x01,
- ESP_BLE_AD_TYPE_16SRV_PART = 0x02,
- ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03,
- ESP_BLE_AD_TYPE_32SRV_PART = 0x04,
- ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05,
- ESP_BLE_AD_TYPE_128SRV_PART = 0x06,
- ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07,
- ESP_BLE_AD_TYPE_NAME_SHORT = 0x08,
- ESP_BLE_AD_TYPE_NAME_CMPL = 0x09,
- ESP_BLE_AD_TYPE_TX_PWR = 0x0A,
- ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D,
- ESP_BLE_AD_TYPE_SM_TK = 0x10,
- ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11,
- ESP_BLE_AD_TYPE_INT_RANGE = 0x12,
- ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14,
- ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15,
- ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16,
- ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17,
- ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18,
- ESP_BLE_AD_TYPE_APPEARANCE = 0x19,
- ESP_BLE_AD_TYPE_ADV_INT = 0x1A,
- ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1B,
- ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x1C,
- ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x1D,
- ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF,
+ ESP_BLE_AD_TYPE_FLAG = 0x01, /* relate to BTM_BLE_AD_TYPE_FLAG in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_16SRV_PART = 0x02, /* relate to BTM_BLE_AD_TYPE_16SRV_PART in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03, /* relate to BTM_BLE_AD_TYPE_16SRV_CMPL in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_32SRV_PART = 0x04, /* relate to BTM_BLE_AD_TYPE_32SRV_PART in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05, /* relate to BTM_BLE_AD_TYPE_32SRV_CMPL in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_128SRV_PART = 0x06, /* relate to BTM_BLE_AD_TYPE_128SRV_PART in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07, /* relate to BTM_BLE_AD_TYPE_128SRV_CMPL in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_NAME_SHORT = 0x08, /* relate to BTM_BLE_AD_TYPE_NAME_SHORT in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_NAME_CMPL = 0x09, /* relate to BTM_BLE_AD_TYPE_NAME_CMPL in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_TX_PWR = 0x0A, /* relate to BTM_BLE_AD_TYPE_TX_PWR in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D, /* relate to BTM_BLE_AD_TYPE_DEV_CLASS in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SM_TK = 0x10, /* relate to BTM_BLE_AD_TYPE_SM_TK in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11, /* relate to BTM_BLE_AD_TYPE_SM_OOB_FLAG in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_INT_RANGE = 0x12, /* relate to BTM_BLE_AD_TYPE_INT_RANGE in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14, /* relate to BTM_BLE_AD_TYPE_SOL_SRV_UUID in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15, /* relate to BTM_BLE_AD_TYPE_128SOL_SRV_UUID in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16, /* relate to BTM_BLE_AD_TYPE_SERVICE_DATA in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17, /* relate to BTM_BLE_AD_TYPE_PUBLIC_TARGET in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18, /* relate to BTM_BLE_AD_TYPE_RANDOM_TARGET in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_APPEARANCE = 0x19, /* relate to BTM_BLE_AD_TYPE_APPEARANCE in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_ADV_INT = 0x1A, /* relate to BTM_BLE_AD_TYPE_ADV_INT in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_LE_DEV_ADDR = 0x1b, /* relate to BTM_BLE_AD_TYPE_LE_DEV_ADDR in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_LE_ROLE = 0x1c, /* relate to BTM_BLE_AD_TYPE_LE_ROLE in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SPAIR_C256 = 0x1d, /* relate to BTM_BLE_AD_TYPE_SPAIR_C256 in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_SPAIR_R256 = 0x1e, /* relate to BTM_BLE_AD_TYPE_SPAIR_R256 in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1f, /* relate to BTM_BLE_AD_TYPE_32SOL_SRV_UUID in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x20, /* relate to BTM_BLE_AD_TYPE_32SERVICE_DATA in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x21, /* relate to BTM_BLE_AD_TYPE_128SERVICE_DATA in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_LE_SECURE_CONFIRM = 0x22, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_LE_SECURE_RANDOM = 0x23, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_RANDOM in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_URI = 0x24, /* relate to BTM_BLE_AD_TYPE_URI in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_INDOOR_POSITION = 0x25, /* relate to BTM_BLE_AD_TYPE_INDOOR_POSITION in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_TRANS_DISC_DATA = 0x26, /* relate to BTM_BLE_AD_TYPE_TRANS_DISC_DATA in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_LE_SUPPORT_FEATURE = 0x27, /* relate to BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE in btm_ble_api.h */
+ ESP_BLE_AD_TYPE_CHAN_MAP_UPDATE = 0x28, /* relate to BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE in btm_ble_api.h */
+ ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF, /* relate to BTM_BLE_AD_MANUFACTURER_SPECIFIC_TYPE in btm_ble_api.h */
} esp_ble_adv_data_type;
/// Advertising mode
} esp_ble_adv_filter_t;
+/* relate to BTA_DM_BLE_SEC_xxx in bta_api.h */
typedef enum {
- ESP_BLE_SEC_NONE,
- ESP_BLE_SEC_ENCRYPT,
- ESP_BLE_SEC_ENCRYPT_NO_MITM,
- ESP_BLE_SEC_ENCRYPT_MITM,
+ ESP_BLE_SEC_NONE = 0, /* relate to BTA_DM_BLE_SEC_NONE in bta_api.h */
+ ESP_BLE_SEC_ENCRYPT, /* relate to BTA_DM_BLE_SEC_ENCRYPT in bta_api.h */
+ ESP_BLE_SEC_ENCRYPT_NO_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_NO_MITM in bta_api.h */
+ ESP_BLE_SEC_ENCRYPT_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_MITM in bta_api.h */
}esp_ble_sec_act_t;
typedef enum {
- ESP_BLE_SM_PASSKEY,
+ ESP_BLE_SM_PASSKEY = 0,
ESP_BLE_SM_AUTHEN_REQ_MODE,
ESP_BLE_SM_IOCAP_MODE,
ESP_BLE_SM_SET_INIT_KEY,
*/
typedef struct
{
- esp_bd_addr_t bd_addr; /*!< BD address peer device. */
+ esp_bd_addr_t bd_addr; /*!< BD address peer device. */
bool key_present; /*!< Valid link key value in key element */
esp_link_key key; /*!< Link key associated with peer device. */
uint8_t key_type; /*!< The type of Link Key */
* @param[out] len : the length of the param value
*
* @return - ESP_OK : success
-* - other : failed
+* - other : failed
*
*/
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
*
* @param[in] bd_addr : the address of the peer device need to encryption
* @param[in] sec_act : This is the security action to indicate
-* what kind of BLE security level is required for
-* the BLE link if the BLE is supported
+* what kind of BLE security level is required for
+* the BLE link if the BLE is supported
*
* @return - ESP_OK : success
* - other : failed
* @}
*/
+/* relate to BTA_GATT_PREP_WRITE_xxx in bta_gatt_api.h */
/// Attribute write data type from the client
typedef enum {
- ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */
- ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */
+ ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta_gatt_api.h */
+ ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta_gatt_api.h */
} esp_gatt_prep_write_type;
+/* relate to BTA_GATT_xxx in bta_gatt_api.h */
/**
* @brief GATT success code and error codes
*/
typedef enum {
- ESP_GATT_OK = 0x0,
- ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
- ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
- ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
- ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
- ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
- ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
- ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
- ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
- ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
- ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
- ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
- ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
- ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
- ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
- ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
- ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
- ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
-
- ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
- ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
- ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
- ESP_GATT_DB_FULL = 0x83, /* 0x83 */
- ESP_GATT_BUSY = 0x84, /* 0x84 */
- ESP_GATT_ERROR = 0x85, /* 0x85 */
- ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
- ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
- ESP_GATT_PENDING = 0x88, /* 0x88 */
- ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
- ESP_GATT_MORE = 0x8a, /* 0x8a */
- ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
- ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
- ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
- ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
- ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
- ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
- ESP_GATT_DUP_REG = 0x90, /* 0x90 */
- ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
- ESP_GATT_CANCEL = 0x92, /* 0x92 */
-
+ ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta_gatt_api.h */
+ ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta_gatt_api.h */
+ ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta_gatt_api.h */
+ ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta_gatt_api.h */
+ ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta_gatt_api.h */
+ ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta_gatt_api.h */
+ ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta_gatt_api.h */
+ ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta_gatt_api.h */
+ ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta_gatt_api.h */
+ ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta_gatt_api.h */
+ ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta_gatt_api.h */
+ ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta_gatt_api.h */
+ ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta_gatt_api.h */
+ ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta_gatt_api.h */
+ ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta_gatt_api.h */
+ ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta_gatt_api.h */
+ ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta_gatt_api.h */
+ ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta_gatt_api.h */
+
+ ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta_gatt_api.h */
+ ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta_gatt_api.h */
+ ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta_gatt_api.h */
+ ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta_gatt_api.h */
+ ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta_gatt_api.h */
+ ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta_gatt_api.h */
+ ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta_gatt_api.h */
+ ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta_gatt_api.h */
+ ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta_gatt_api.h */
+ ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta_gatt_api.h */
+ ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta_gatt_api.h */
+ ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta_gatt_api.h */
+ ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta_gatt_api.h */
+ ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta_gatt_api.h */
+ ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta_gatt_api.h */
+ ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta_gatt_api.h */
+ ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta_gatt_api.h */
+ ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta_gatt_api.h */
+ ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta_gatt_api.h */
+ ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta_gatt_api.h */
/* 0xE0 ~ 0xFC reserved for future use */
- ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
- ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
- ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
+ ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta_gatt_api.h */
+ ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta_gatt_api.h */
+ //Error caused by customer application or stack bug
+ ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta_gatt_api.h */
+ ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta_gatt_api.h */
+ ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta_gatt_api.h */
+ ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta_gatt_api.h */
} esp_gatt_status_t;
+/* relate to BTA_GATT_CONN_xxx in bta_gatt_api.h */
/**
* @brief Gatt Connection reason enum
*/
typedef enum {
- ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */
- ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */
- ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */
- ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */
- ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */
- ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */
- ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */
- ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */
- ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */
+ ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta_gatt_api.h */
+ ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta_gatt_api.h */
+ ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta_gatt_api.h */
+ ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta_gatt_api.h */
+ ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta_gatt_api.h */
+ ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta_gatt_api.h */
+ ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta_gatt_api.h */
+ ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta_gatt_api.h */
+ ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta_gatt_api.h */
} esp_gatt_conn_reason_t;
/**
bool is_primary; /*!< This service is primary or not */
} __attribute__((packed)) esp_gatt_srvc_id_t;
+/* relate to BTA_GATT_AUTH_REQ_xxx in bta_gatt_api.h */
/**
* @brief Gatt authentication request type
*/
typedef enum {
- ESP_GATT_AUTH_REQ_NONE = 0,
- ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */
- ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */
- ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3,
- ESP_GATT_AUTH_REQ_SIGNED_MITM = 4,
+ ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta_gatt_api.h */
+ ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta_gatt_api.h */
+ ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta_gatt_api.h */
+ ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta_gatt_api.h */
+ ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta_gatt_api.h */
} esp_gatt_auth_req_t;
+/* relate to BTA_GATT_PERM_xxx in bta_gatt_api.h */
/**
* @brief Attribute permissions
*/
typedef enum {
- ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
- ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
- ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
- ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
- ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
- ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
- ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
- ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
+ ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta_gatt_api.h */
+ ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta_gatt_api.h */
+ ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta_gatt_api.h */
+ ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta_gatt_api.h */
+ ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta_gatt_api.h */
+ ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta_gatt_api.h */
+ ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta_gatt_api.h */
+ ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta_gatt_api.h */
} esp_gatt_perm_t;
+/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta_gatt_api.h */
/* definition of characteristic properties */
typedef enum {
- ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
- ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
- ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
- ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
- ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
- ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
- ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
- ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
+ ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta_gatt_api.h */
+ ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta_gatt_api.h */
} esp_gatt_char_prop_t;
/// GATT maximum attribute length
/* Encryption callback*/
typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS result);
+/* relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */
#if BLE_INCLUDED == TRUE
#define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
#define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
UINT8 inst_id; /* instance ID */
} __attribute__((packed)) tBTA_GATT_ID;
+/* relate to ESP_GATT_xxx in esp_gatt_def.h */
/* Success code and error codes */
#define BTA_GATT_OK GATT_SUCCESS
#define BTA_GATT_INVALID_HANDLE GATT_INVALID_HANDLE /* 0x0001 */
#define BTA_GATT_NOT_ENCRYPTED GATT_NOT_ENCRYPTED /* 0x8e */
#define BTA_GATT_CONGESTED GATT_CONGESTED /* 0x8f */
-#define BTA_GATT_DUP_REG 0x90 /* 0x90 */
-#define BTA_GATT_ALREADY_OPEN 0x91 /* 0x91 */
-#define BTA_GATT_CANCEL 0x92 /* 0x92 */
+#define BTA_GATT_DUP_REG GATT_DUP_REG /* 0x90 */
+#define BTA_GATT_ALREADY_OPEN GATT_ALREADY_OPEN /* 0x91 */
+#define BTA_GATT_CANCEL GATT_CANCEL /* 0x92 */
/* 0xE0 ~ 0xFC reserved for future use */
-#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
-#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
-#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
+#define BTA_GATT_STACK_RSP GATT_STACK_RSP /* 0xE0 */
+#define BTA_GATT_APP_RSP GATT_APP_RSP /* 0xE1 */
+//Error caused by customer application or stack bug
+#define BTA_GATT_UNKNOWN_ERROR GATT_UNKNOWN_ERROR /* 0XEF */
+
+#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
+#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
+#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
typedef UINT8 tBTA_GATT_STATUS;
#define BTA_GATTC_TYPE_WRITE_NO_RSP GATT_WRITE_NO_RSP
typedef UINT8 tBTA_GATTC_WRITE_TYPE;
+/* relate to ESP_GATT_CONN_xxx in esp_gatt_defs.h */
#define BTA_GATT_CONN_UNKNOWN 0
#define BTA_GATT_CONN_L2C_FAILURE GATT_CONN_L2C_FAILURE /* general l2cap resource failure */
#define BTA_GATT_CONN_TIMEOUT GATT_CONN_TIMEOUT /* 0x08 connection timeout */
} tBTA_GATTC_MULTI;
+/* relate to ESP_GATT_xxx in esp_gatt_def.h */
#define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE
#define BTA_GATT_AUTH_REQ_NO_MITM GATT_AUTH_REQ_NO_MITM /* unauthenticated encryption */
#define BTA_GATT_AUTH_REQ_MITM GATT_AUTH_REQ_MITM /* authenticated encryption */
#define BTA_GATTS_CLOSE_EVT 18
#define BTA_GATTS_LISTEN_EVT 19
#define BTA_GATTS_CONGEST_EVT 20
-#define BTA_GATTS_SET_ATTR_VAL_EVT 21
+#define BTA_GATTS_SET_ATTR_VAL_EVT 23
typedef UINT8 tBTA_GATTS_EVT;
typedef tGATT_IF tBTA_GATTS_IF;
/* attribute response data */
typedef tGATTS_RSP tBTA_GATTS_RSP;
+/* relate to ESP_GATT_PREP_WRITE_xxx in esp_gatt_defs.h */
/* attribute request data from the client */
#define BTA_GATT_PREP_WRITE_CANCEL 0x00
#define BTA_GATT_PREP_WRITE_EXEC 0x01
if (GKI_queue_length(&btc_media_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ) {
APPL_TRACE_WARNING("Pkt dropped\n");
+ return GKI_queue_length(&btc_media_cb.RxSbcQ);
}
APPL_TRACE_DEBUG("btc_media_sink_enque_buf + ");
#include "hash_map.h"
#include "hash_functions.h"
-
+#include "bt_trace.h"
#define APPLY_CONTINUATION_FLAG(handle) (((handle) & 0xCFFF) | 0x1000)
max_packet_size = max_data_size + HCI_ACL_PREAMBLE_SIZE;
remaining_length = packet->len;
-
STREAM_TO_UINT16(continuation_handle, stream);
continuation_handle = APPLY_CONTINUATION_FLAG(continuation_handle);
if (remaining_length > max_packet_size) {
current_fragment_packet = packet;
- UINT16_TO_STREAM(stream, max_packet_size);
+ UINT16_TO_STREAM(stream, max_data_size);
packet->len = max_packet_size;
callbacks->fragmented(packet, false);
packet->offset += max_data_size;
stream = packet->data + packet->offset;
UINT16_TO_STREAM(stream, continuation_handle);
UINT16_TO_STREAM(stream, remaining_length - HCI_ACL_PREAMBLE_SIZE);
-
// Apparently L2CAP can set layer_specific to a max number of segments to transmit
if (packet->layer_specific) {
packet->layer_specific--;
/** Bluetooth Error Status */
/** We need to build on this */
+/* relate to ESP_BT_STATUS_xxx in esp_bt_defs.h */
typedef enum {
- BT_STATUS_SUCCESS,
+ BT_STATUS_SUCCESS = 0,
BT_STATUS_FAIL,
BT_STATUS_NOT_READY,
BT_STATUS_NOMEM,
BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN,
BT_STATUS_AUTH_REJECTED,
+ BT_STATUS_INVALID_STATIC_RAND_ADDR,
} bt_status_t;
#ifndef CPU_LITTLE_ENDIAN
}
#ifdef BTTRC_DUMP_BUFFER
-#define BTTRC_DUMP_BUFFER(_prefix, _data, _len) trc_dump_buffer(_data, _len)
+#define BTTRC_DUMP_BUFFER(_prefix, _data, _len) trc_dump_buffer(_prefix, _data, _len)
#else
#define BTTRC_DUMP_BUFFER(_prefix, _data, _len)
#endif
} else { /* characteristic description or characteristic value */
if (p_attr16->control.auto_rsp == GATT_RSP_BY_STACK) {
if (p_attr16->p_value == NULL || p_attr16->p_value->attr_val.attr_val == NULL) {
- status = GATT_ESP_ERROR;
+ status = GATT_UNKNOWN_ERROR;
}
else if (offset > p_attr16->p_value->attr_val.attr_len){
/*if offset equal to max_len, should respond with zero byte value
} else if ((p_attr->p_value == NULL) || (p_attr->p_value->attr_val.attr_val == NULL)){
GATT_TRACE_ERROR("Error in %s, line=%d, %s should not be NULL here\n", __func__, __LINE__, \
(p_attr->p_value == NULL) ? "p_value" : "attr_val.attr_val");
- return GATT_ESP_ERROR;
+ return GATT_UNKNOWN_ERROR;
}
}
} else if (p_attr->p_value == NULL) {
LOG_ERROR("Error in %s, attribute of handle 0x%x not allocate value buffer\n",
__func__, handle);
- status = GATT_ESP_ERROR;
+ status = GATT_UNKNOWN_ERROR;
} else {
//valid prepare write request, need to send response and queue the data
//status: GATT_SUCCESS
}
}
} else{
- status = GATT_ESP_ERROR;
+ status = GATT_UNKNOWN_ERROR;
GATT_TRACE_ERROR("Error in %s, Line %d: GATT BUSY\n", __func__, __LINE__);
}
}
};
typedef UINT8 tBTM_SP_EVT;
+/* relate to ESP_IO_CAP_xxx in esp_gap_ble_api.h */
#define BTM_IO_CAP_OUT 0 /* DisplayOnly */
#define BTM_IO_CAP_IO 1 /* DisplayYesNo */
#define BTM_IO_CAP_IN 2 /* KeyboardOnly */
/* LE related event and data structure
*/
+/* relate to ESP_LE_KEY_xxx in esp_gap_ble_api.h */
#if (SMP_INCLUDED == TRUE)
#define BTM_LE_IO_REQ_EVT SMP_IO_CAP_REQ_EVT /* received IO_CAPABILITY_REQUEST event */
#define BTM_LE_SEC_REQUEST_EVT SMP_SEC_REQUEST_EVT /* security request event */
#define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 4) /* local CSRK has been deliver to peer */
#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
typedef UINT8 tBTM_LE_KEY_TYPE;
+
+/* relate to ESP_LE_AUTH_xxx in esp_gap_ble_api.h */
#if (SMP_INCLUDED == TRUE)
#define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND /* 0 */
#define BTM_LE_AUTH_REQ_BOND SMP_AUTH_GEN_BOND /* 1 << 0 */
typedef UINT32 tBTM_BLE_AD_MASK;
+/* relate to ESP_BLE_AD_TYPE_xxx in esp_gap_ble_api.h */
#define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */
#define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
#define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
#define GATT_INSUF_RESOURCE 0x11
-#define GATT_ILLEGAL_PARAMETER 0x87
#define GATT_NO_RESOURCES 0x80
#define GATT_INTERNAL_ERROR 0x81
#define GATT_WRONG_STATE 0x82
#define GATT_BUSY 0x84
#define GATT_ERROR 0x85
#define GATT_CMD_STARTED 0x86
+#define GATT_ILLEGAL_PARAMETER 0x87
#define GATT_PENDING 0x88
#define GATT_AUTH_FAIL 0x89
#define GATT_MORE 0x8a
#define GATT_ENCRYPED_NO_MITM 0x8d
#define GATT_NOT_ENCRYPTED 0x8e
#define GATT_CONGESTED 0x8f
-#define GATT_STACK_RSP 0x90
-#define GATT_APP_RSP 0x91
-//Error caused by customer application or stack bug
-#define GATT_ESP_ERROR 0X9f
+
+#define GATT_DUP_REG 0x90
+#define GATT_ALREADY_OPEN 0x91
+#define GATT_CANCEL 0x92
/* 0xE0 ~ 0xFC reserved for future use */
+#define GATT_STACK_RSP 0xE0
+#define GATT_APP_RSP 0xE1
+//Error caused by customer application or stack bug
+#define GATT_UNKNOWN_ERROR 0XEF
+
#define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */
#define GATT_PRC_IN_PROGRESS 0xFE /* Procedure Already in progress */
#define GATT_OUT_OF_RANGE 0xFF /* Attribute value out of range */
+
typedef UINT8 tGATT_STATUS;
static int i2c_slave_read(i2c_port_t i2c_num, uint8_t* data, size_t max_size, portBASE_TYPE ticks_to_wait)\r
{\r
i2c_obj_t* p_i2c = p_i2c_obj[i2c_num];\r
- size_t size;\r
+ size_t size = 0;\r
uint8_t* pdata = (uint8_t*) xRingbufferReceiveUpTo(p_i2c->rx_ring_buf, &size, ticks_to_wait, max_size);\r
if (pdata && size > 0) {\r
memcpy(data, pdata, size);\r
static uint32_t ccount_margin_cnt;
#endif
+#ifndef CONFIG_FREERTOS_UNICORE
+static BaseType_t oldInterruptLevel[2];
+#endif
+
/* stall other cpu that this cpu is pending to access dport register start */
void IRAM_ATTR esp_dport_access_stall_other_cpu_start(void)
{
#ifdef DPORT_ACCESS_BENCHMARK
ccount_start[cpu_id] = XTHAL_GET_CCOUNT();
#endif
-
- portDISABLE_INTERRUPTS();
+ BaseType_t intLvl=portENTER_CRITICAL_NESTED();
+ oldInterruptLevel[cpu_id]=intLvl;
if (dport_access_ref[cpu_id] == 0) {
portENTER_CRITICAL_ISR(&g_dport_mux);
portEXIT_CRITICAL_ISR(&g_dport_mux);
}
- portENABLE_INTERRUPTS();
+ portEXIT_CRITICAL_NESTED(oldInterruptLevel[cpu_id]);
#ifdef DPORT_ACCESS_BENCHMARK
ccount_end[cpu_id] = XTHAL_GET_CCOUNT();
PROVIDE ( ld_acl_tx_packet_type_select = 0x4002fb40 );
PROVIDE ( ld_acl_sched = 0x40033268 );
PROVIDE ( ld_acl_sniff_sched = 0x4003340c );
+PROVIDE ( lm_cmd_cmp_send = 0x40051838 );
PROVIDE ( r_ld_acl_active_hop_types_get = 0x40036e10 );
PROVIDE ( r_ld_acl_afh_confirm = 0x40036d40 );
PROVIDE ( r_ld_acl_afh_prepare = 0x40036c84 );
PROVIDE ( ets_update_cpu_frequency_rom = 0x40008550 ); /* Updates g_ticks_per_us on the current CPU only; not on the other core */
/* Following are static data, but can be used, not generated by script <<<<< btdm data */
+PROVIDE ( hci_tl_env = 0x3ffb8154 );
PROVIDE ( ld_acl_env = 0x3ffb8258 );
PROVIDE ( ld_active_ch_map = 0x3ffb8334 );
PROVIDE ( ld_bcst_acl_env = 0x3ffb8274 );
#if( portUSING_MPU_WRAPPERS == 1 )
struct xMEMORY_REGION;
void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t usStackDepth ) PRIVILEGED_FUNCTION;
+ void vPortReleaseTaskMPUSettings( xMPU_SETTINGS *xMPUSettings );
#endif
/* Multi-core: get current core ID */
#define portASSERT_IF_IN_ISR() vPortAssertIfInISR()
void vPortAssertIfInISR();
+
#define portCRITICAL_NESTING_IN_TCB 1
/*
#define PRIVILEGED_DATA
#endif
+
+void _xt_coproc_release(volatile void * coproc_sa_base);
+
+
// porttrace
#if configUSE_TRACE_FACILITY_2
#include "porttrace.h"
*/
#endif
}
+
+void vPortReleaseTaskMPUSettings( xMPU_SETTINGS *xMPUSettings )
+{
+ /* If task has live floating point registers somewhere, release them */
+ _xt_coproc_release( xMPUSettings->coproc_area );
+}
+
#endif
/*
{
pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
- ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
- --uxCurrentNumberOfTasks;
- --uxTasksDeleted;
+ /* We only want to kill tasks that ran on this core because e.g. _xt_coproc_release needs to
+ be called on the core the process is pinned on, if any */
+ if( pxTCB->xCoreID == tskNO_AFFINITY || pxTCB->xCoreID == xPortGetCoreID()) {
+ ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
+ --uxCurrentNumberOfTasks;
+ --uxTasksDeleted;
+ } else {
+ /* Need to wait until the idle task on the other processor kills that task first. */
+ break;
+ }
}
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
}
#endif /* configUSE_NEWLIB_REENTRANT */
+ #if ( portUSING_MPU_WRAPPERS == 1 )
+ vPortReleaseTaskMPUSettings( &( pxTCB->xMPUSettings) );
+ #endif
+
#if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( portUSING_MPU_WRAPPERS == 0 ) )
{
/* The task can only have been allocated dynamically - free both
the co-proc save area, to avoid the exception handler having to save the
thread's co-proc state before another thread can use it (optimization).
+Needs to be called on the processor the thread was running on. Unpinned threads
+won't have an entry here because they get pinned as soon they use a coprocessor.
+
Entry Conditions:
A2 = Pointer to base of co-processor state save area.
addx4 a0, a5, a0 /* a0 = &_xt_coproc_mask[n] */
l32i a0, a0, 0 /* a0 = (n << 16) | (1 << n) */
- /* TODO: Remove this as soon as coprocessor state moving works across cores - JD */
/* FPU operations are incompatible with non-pinned tasks. If we have a FPU operation
here, to keep the entire thing from crashing, it's better to pin the task to whatever
core we're running on now. */
/* Grab correct xt_coproc_owner_sa for this core */
movi a2, XCHAL_CP_MAX << 2
- mull a2, a2, a3
+ mull a2, a2, a3 /* multiply by current processor id */
movi a3, _xt_coproc_owner_sa /* a3 = base of owner array */
- add a3, a3, a2
+ add a3, a3, a2 /* a3 = owner area needed for this processor */
extui a2, a0, 0, 16 /* coprocessor bitmask portion */
or a4, a4, a2 /* a4 = CPENABLE | (1 << n) */
wsr a4, CPENABLE
+/*
+Keep loading _xt_coproc_owner_sa[n] atomic (=load once, then use that value
+everywhere): _xt_coproc_release assumes it works like this in order not to need
+locking.
+*/
+
+
/* Get old coprocessor owner thread (save area ptr) and assign new one. */
addx4 a3, a5, a3 /* a3 = &_xt_coproc_owner_sa[n] */
l32i a2, a3, 0 /* a2 = old owner's save area */
*/
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
+/**
+ * @brief Log a buffer of hex bytes at Info level
+ *
+ * @param tag description tag
+ *
+ * @param buffer Pointer to the buffer array
+ *
+ * @param buff_len length of buffer
+ *
+ */
+void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len);
+
+/**
+ * @brief Log a buffer of characters at Info level. Buffer should contain only printable characters.
+ *
+ * @param tag description tag
+ *
+ * @param buffer Pointer to the buffer array
+ *
+ * @param buff_len length of buffer
+ *
+ */
+void esp_log_buffer_char(const char *tag, const char *buffer, uint16_t buff_len);
#if CONFIG_LOG_COLORS
#define LOG_COLOR_BLACK "30"
#include <assert.h>
#include "esp_log.h"
+//print number of bytes per line for esp_log_buffer_char and esp_log_buffer_hex
+#define BYTES_PER_LINE 16
#ifndef BOOTLOADER_BUILD
uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp")));
#endif //BOOTLOADER_BUILD
+
+void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len)
+{
+ char temp_buffer[3*BYTES_PER_LINE + 1]= {0};
+ int line_len = 0;
+ for (int i = 0; i < buff_len; i++) {
+ line_len += sprintf(temp_buffer+line_len, "%02x ", buffer[i]);
+ if (((i + 1) % BYTES_PER_LINE == 0) || (i == buff_len - 1)) {
+ ESP_LOGI(tag, "%s", temp_buffer);
+ line_len = 0;
+ temp_buffer[0] = 0;
+ }
+ }
+}
+
+void esp_log_buffer_char(const char *tag, const char *buffer, uint16_t buff_len)
+{
+ char temp_buffer[2*BYTES_PER_LINE + 1] = {0};
+ int line_len = 0;
+ for (int i = 0; i < buff_len; i++) {
+ line_len += sprintf(temp_buffer+line_len, "%c ", buffer[i]);
+ if (((i + 1) % BYTES_PER_LINE == 0) || (i == buff_len - 1)) {
+ ESP_LOGI(tag, "%s", temp_buffer);
+ line_len = 0;
+ temp_buffer[0] = 0;
+ }
+ }
+}
/* If we are closed, we indicate that we no longer wish to use the socket */
if (buf == NULL) {
API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
- /* RX side is closed, so deallocate the recvmbox */
- netconn_close_shutdown(conn, NETCONN_SHUT_RD);
/* Don' store ERR_CLSD as conn->err since we are only half-closed */
return ERR_CLSD;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The configuration system can be used to conditionally compile some files
-depending on the options selected in ``make menuconfig``:
+depending on the options selected in ``make menuconfig``. For this, ESP-IDF
+has the compile_only_if and compile_only_if_not macros:
``Kconfig``::
``component.mk``::
- COMPONENT_OBJS := foo_a.o foo_b.o
+ $(call compile_only_if,$(CONFIG_FOO_ENABLE_BAR),bar.o)
- ifdef CONFIG_FOO_BAR
- COMPONENT_OBJS += foo_bar.o foo_bar_interface.o
- endif
-See the `GNU Make Manual` for conditional syntax that can be used use in makefiles.
+As can be seen in the example, the ``compile_only_if`` macro takes a condition and a
+list of object files as parameters. If the condition is true (in this case: if the
+BAR feature is enabled in menuconfig) the object files (in this case: bar.o) will
+always be compiled. The opposite goes as well: if the condition is not true, bar.o
+will never be compiled. ``compile_only_if_not`` does the opposite: compile if the
+condition is false, not compile if the condition is true.
+This can also be used to select or stub out an implementation, as such:
+
+``Kconfig``::
+
+ config ENABLE_LCD_OUTPUT
+ bool "Enable LCD output."
+ help
+ Select this if your board has a LCD.
+
+ config ENABLE_LCD_CONSOLE
+ bool "Output console text to LCD"
+ depends on ENABLE_LCD_OUTPUT
+ help
+ Select this to output debugging output to the lcd
+
+ config ENABLE_LCD_PLOT
+ bool "Output temperature plots to LCD"
+ depends on ENABLE_LCD_OUTPUT
+ help
+ Select this to output temperature plots
+
+
+``component.mk``::
+
+ # If LCD is enabled, compile interface to it, otherwise compile dummy interface
+ $(call compile_only_if,$(CONFIG_ENABLE_LCD_OUTPUT),lcd-real.o lcd-spi.o)
+ $(call compile_only_if_not,$(CONFIG_ENABLE_LCD_OUTPUT),lcd-dummy.o)
+
+ #We need font if either console or plot is enabled
+ $(call compile_only_if,$(or $(CONFIG_ENABLE_LCD_CONSOLE),$(CONFIG_ENABLE_LCD_PLOT)), font.o)
+
+Note the use of the Make 'or' function to include the font file. Other substitution functions,
+like 'and' and 'if' will also work here. Variables that do not come from menuconfig can also
+be used: ESP-IDF uses the default Make policy of judging a variable which is empty or contains
+only whitespace to be false while a variable with any non-whitespace in it is true.
+
+(Note: Older versions of this document advised conditionally adding object file names to
+``COMPONENT_OBJS``. While this still is possible, this will only work when all object
+files for a component are named explicitely, and will not clean up deselected object files
+in a ``make clean`` pass.)
Source Code Generation
^^^^^^^^^^^^^^^^^^^^^^
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 0x40
+#define PREPARE_BUF_MAX_SIZE 1024
+
uint8_t char1_str[] = {0x11,0x22,0x33};
esp_attr_value_t gatts_demo_char1_val =
{
},
};
+typedef struct {
+ uint8_t *prepare_buf;
+ int prepare_len;
+} prepare_type_env_t;
+
+static prepare_type_env_t a_prepare_write_env;
+static prepare_type_env_t b_prepare_write_env;
+
+void example_write_event_env(esp_gatt_if_t gatts_if, prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param);
+void example_exec_write_event_env(prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param);
+
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
switch (event) {
}
}
+void example_write_event_env(esp_gatt_if_t gatts_if, prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param){
+ esp_gatt_status_t status = ESP_GATT_OK;
+ if (param->write.need_rsp){
+ if (param->write.is_prep){
+ if (prepare_write_env->prepare_buf == NULL) {
+ prepare_write_env->prepare_buf = (uint8_t *)malloc(PREPARE_BUF_MAX_SIZE*sizeof(uint8_t));
+ prepare_write_env->prepare_len = 0;
+ if (prepare_write_env->prepare_buf == NULL) {
+ LOG_ERROR("Gatt_server prep no mem\n");
+ status = ESP_GATT_NO_RESOURCES;
+ }
+ } else {
+ if(param->write.offset > PREPARE_BUF_MAX_SIZE) {
+ status = ESP_GATT_INVALID_OFFSET;
+ } else if ((param->write.offset + param->write.len) > PREPARE_BUF_MAX_SIZE) {
+ status = ESP_GATT_INVALID_ATTR_LEN;
+ }
+ }
+
+ esp_gatt_rsp_t *gatt_rsp = (esp_gatt_rsp_t *)malloc(sizeof(esp_gatt_rsp_t));
+ gatt_rsp->attr_value.len = param->write.len;
+ gatt_rsp->attr_value.handle = param->write.handle;
+ gatt_rsp->attr_value.offset = param->write.offset;
+ gatt_rsp->attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE;
+ memcpy(gatt_rsp->attr_value.value, param->write.value, param->write.len);
+ esp_err_t response_err = esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, status, gatt_rsp);
+ if (response_err != ESP_OK){
+ LOG_ERROR("Send response error\n");
+ }
+ free(gatt_rsp);
+ if (status != ESP_GATT_OK){
+ return;
+ }
+ memcpy(prepare_write_env->prepare_buf + param->write.offset,
+ param->write.value,
+ param->write.len);
+ prepare_write_env->prepare_len += param->write.len;
+
+ }else{
+ esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, status, NULL);
+ }
+ }
+}
+
+void example_exec_write_event_env(prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param){
+ if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC){
+ esp_log_buffer_hex(GATTS_TAG, (char *)prepare_write_env->prepare_buf, prepare_write_env->prepare_len);
+ }else{
+ ESP_LOGI(GATTS_TAG,"ESP_GATT_PREP_WRITE_CANCEL");
+ }
+ if (prepare_write_env->prepare_buf) {
+ free(prepare_write_env->prepare_buf);
+ prepare_write_env->prepare_buf = NULL;
+ }
+ prepare_write_env->prepare_len = 0;
+}
+
static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) {
switch (event) {
case ESP_GATTS_REG_EVT:
case ESP_GATTS_WRITE_EVT: {
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d\n", param->write.conn_id, param->write.trans_id, param->write.handle);
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value %08x\n", param->write.len, *(uint32_t *)param->write.value);
- esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL);
+ example_write_event_env(gatts_if, &a_prepare_write_env, param);
break;
}
case ESP_GATTS_EXEC_WRITE_EVT:
+ ESP_LOGI(GATTS_TAG,"ESP_GATTS_EXEC_WRITE_EVT");
+ esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL);
+ example_exec_write_event_env(&a_prepare_write_env, param);
+ break;
case ESP_GATTS_MTU_EVT:
case ESP_GATTS_CONF_EVT:
case ESP_GATTS_UNREG_EVT:
case ESP_GATTS_WRITE_EVT: {
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d\n", param->write.conn_id, param->write.trans_id, param->write.handle);
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value %08x\n", param->write.len, *(uint32_t *)param->write.value);
- esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL);
+ example_write_event_env(gatts_if, &b_prepare_write_env, param);
break;
}
case ESP_GATTS_EXEC_WRITE_EVT:
+ ESP_LOGI(GATTS_TAG,"ESP_GATTS_EXEC_WRITE_EVT");
+ esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL);
+ example_exec_write_event_env(&b_prepare_write_env, param);
+ break;
case ESP_GATTS_MTU_EVT:
case ESP_GATTS_CONF_EVT:
case ESP_GATTS_UNREG_EVT:
define prereq_if_explicit
$(filter $(1),$(MAKECMDGOALS))
endef
+
+# macro to kill duplicate items in a list without messing up the sort order of the list.
+# Will only keep the unique items; if there are non-unique items in the list, it will remove
+# the later recurring ones so only the first one remains.
+# Copied from http://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting
+define uniq
+$(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
+endef
COMPONENT_ADD_INCLUDEDIRS = include
COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME)
+# Define optional compiling macros
+define compile_exclude
+COMPONENT_OBJEXCLUDE += $(1)
+endef
+
+define compile_include
+COMPONENT_OBJINCLUDE += $(1)
+endef
+
+define compile_only_if
+$(eval $(if $(1), $(call compile_include, $(2)), $(call compile_exclude, $(2))))
+endef
+
+define compile_only_if_not
+$(eval $(if $(1), $(call compile_exclude, $(2)), $(call compile_include, $(2))))
+endef
+
################################################################################
# 2) Include the component.mk for the specific component (COMPONENT_MAKEFILE) to
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.S,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.S)))
# Make relative by removing COMPONENT_PATH from all found object paths
COMPONENT_OBJS := $(patsubst $(COMPONENT_PATH)/%,%,$(COMPONENT_OBJS))
+else
+# Add in components defined by conditional compiling macros
+COMPONENT_OBJS += $(COMPONENT_OBJINCLUDE)
endif
+# Remove items disabled by optional compilation
+COMPONENT_OBJS := $(foreach obj,$(COMPONENT_OBJS),$(if $(filter $(realpath $(obj)),$(realpath $(COMPONENT_OBJEXCLUDE))), ,$(obj)))
+
+# Remove duplicates
+COMPONENT_OBJS := $(call uniq,$(COMPONENT_OBJS))
+
# Object files with embedded binaries to add to the component library
# Correspond to the files named in COMPONENT_EMBED_FILES & COMPONENT_EMBED_TXTFILES
# If COMPONENT_OWNCLEANTARGET is not set, define a phony clean target
ifndef COMPONENT_OWNCLEANTARGET
-CLEAN_FILES = $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EMBED_OBJS) $(COMPONENT_EXTRA_CLEAN) component_project_vars.mk
+CLEAN_FILES := $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_OBJEXCLUDE) $(COMPONENT_OBJEXCLUDE:.o=.d) $(COMPONENT_EMBED_OBJS) $(COMPONENT_EXTRA_CLEAN) component_project_vars.mk
.PHONY: clean
clean:
$(summary) RM $(CLEAN_FILES)
#
# Tweaks .gitmodules file for private builds
-[ -z $CI_BUILD_REF ] && echo "This internal script should only be run by a Gitlab CI runner." && exit 1
+[ -z $CI_COMMIT_REF_NAME ] && echo "This internal script should only be run by a Gitlab CI runner." && exit 1
-REF=$CI_BUILD_REF
+REF=$CI_COMMIT_REF_NAME
# Public branches are:
# release branches - start with release/
function assert_branch_public()
{
(
- CI_BUILD_REF=$1
+ CI_COMMIT_REF_NAME=$1
set -e
source ./configure_ci_environment.sh
[[ $IS_PUBLIC = $2 ]] || exit 1