Last Updated on : 2024-11-20 08:51:40download
The functions included in the Port
file are the required interfaces to enable the Tuya Bluetooth SDK to be ported to your chip platform.
Function | TUYA_BLE_PRINTF |
---|---|
Function prototype | void TUYA_BLE_PRINTF(const char *format,…) |
Description | Print strings. |
Parameters | format[in]: the format control. …[in]: variable parameters. |
Return value | None |
Notes | Port this function by defining a macro. For example, #define TUYA_BLE_PRINTF(...) log_d (__VA_ARGS__) . |
Function | TUYA_BLE_HEXDUMP |
---|---|
Function prototype | void TUYA_BLE_HEXDUMP(uint8_t *p_data , uint16_t len) |
Description | Print data in hexadecimal format. |
Parameters | p_data[in]: the pointer to data to be printed. len[in]: the length of data. |
Return value | None |
Notes | Port this function by defining a macro. For example, #define TUYA_BLE_HEXDUMP(...) elog_hexdump("", 8, __VA_ARGS__) . |
Function | tuya_ble_gap_advertising_adv_data_update |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gap_advertising_adv_data_update(uint8_t const * p_ad_data, uint8_t ad_len) |
Description | Update the Bluetooth advertising data. |
Parameters | p_ad_data[in]: the updated advertising data. ad_len[in]: the length of data. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_gap_advertising_scan_rsp_data_update |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gap_advertising_scan_rsp_data_update(uint8_t const *p_sr_data, uint8_t sr_len) |
Description | Update the Bluetooth scan response data. |
Parameters | p_sr_data[in]: the updated scan response data. sr_len[in]: the length of data. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_gap_disconnect |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gap_disconnect(void) |
Description | Disconnect the Bluetooth connection. |
Parameters | None |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_gatt_send_data |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gatt_send_data(const uint8_t *p_data,uint16_t len) |
Description | The GATT server initiates a notify operation to send data to the client. |
Parameters | p_data[in]: the pointer to data to be sent. len[in]: the length of data to be sent, no more than 20 bytes. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes |
|
Function | tuya_ble_device_info_characteristic_value_update |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_device_info_characteristic_value_update(uint8_t const *p_data, uint8_t data_len) |
Description | Update characteristic value (UUID: 00000003-0000-1001-8001-00805F9B07D0) |
Parameters | p_data[in]: the pointer to data to be sent. len[in]: the length of data to be sent, no more than 20 bytes. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes |
|
Function | tuya_ble_timer_create |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_timer_create(void** p_timer_id,uint32_t timeout_value_ms, tuya_ble_timer_mode mode,tuya_ble_timer_handler_t timeout_handler) |
Description | Create a timer. |
Parameters | p_timer_id[out]: the pointer to the created timer. timeout_value_ms[in]: the scheduled time, in milliseconds. mode[in]:
|
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_timer_delete |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_timer_delete(void* timer_id) |
Description | Delete a timer. |
Parameters | timer_id [in]: the timer ID. |
Return value | TUYA_BLE_SUCCESS: succeeded. TUYA_BLE_ERR_INVALID_PARAM: invalid parameter. Other values: failed. |
Function | tuya_ble_timer_start |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_timer_start(void* timer_id) |
Description | Start a timer. |
Parameters | timer_id [in]: the timer ID. |
Return value | TUYA_BLE_SUCCESS: succeeded. TUYA_BLE_ERR_INVALID_PARAM: invalid parameter. Other values: failed. |
Notes | When this function is executed, the timer will restart if it is already started. |
Function | tuya_ble_timer_restart |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_timer_restart(void* timer_id,uint32_t timeout_value_ms) |
Description | Restart a timer with a new schedule time. |
Parameters | timer_id [in]: the timer ID. timeout_value_ms[in]: the scheduled time, in milliseconds. |
Return value | TUYA_BLE_SUCCESS: succeeded. TUYA_BLE_ERR_INVALID_PARAM: invalid parameter. Other values: failed. |
Function | tuya_ble_timer_stop |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_timer_stop(void* timer_id) |
Description | Stop a timer. |
Parameters | timer_id [in]: the timer ID. |
Return value | TUYA_BLE_SUCCESS: succeeded. TUYA_BLE_ERR_INVALID_PARAM: invalid parameter. Other values: failed. |
Function | tuya_ble_device_delay_ms |
---|---|
Function prototype | void tuya_ble_device_delay_ms(uint32_t ms) |
Description | A millisecond delay function. |
Parameters | ms [in]: the delay time in milliseconds. |
Return value | None |
Notes | If the chip runs an operating system, the delay task must be non-blocking. |
Function | tuya_ble_device_delay_us |
---|---|
Function prototype | void tuya_ble_device_delay_us(uint32_t us) |
Description | A microsecond delay function. |
Parameters | us [in]: the delay time in microseconds. |
Return value | None |
Notes | If the chip runs an operating system, the delay task must be non-blocking. |
Function | tuya_ble_device_reset |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_device_reset(void) |
Description | Restart a device. |
Parameters | None |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_gap_addr_get |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gap_addr_get(tuya_ble_gap_addr_t *p_addr); |
Description | Get the MAC address of a device. |
Parameters | p_addr [out]: the pointer to the MAC address. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
typedef enum
{
TUYA_BLE_ADDRESS_TYPE_PUBLIC, // public address
TUYA_BLE_ADDRESS_TYPE_RANDOM, // random address
} tuya_ble_addr_type_t;
typedef struct
{
tuya_ble_addr_type_t addr_type;
uint8_t addr[6];
}tuya_ble_gap_addr_t;
Function | tuya_ble_gap_addr_set |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_gap_addr_set(tuya_ble_gap_addr_t *p_addr); |
Description | Update the MAC address of a device. |
Parameters | p_addr [in]: the pointer to the MAC address. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_device_enter_critical |
---|---|
Function prototype | voidtuya_ble_device_enter_critical(void) |
Description | Enter the critical section. |
Parameters | None |
Return value | None |
Notes | Specify the critical section by defining a macro. Take the Nordic platform as an example. |
#define tuya_ble_device_enter_critical() \
{ \
uint8_t __CR_NESTED = 0; \
app_util_critical_region_enter(&__CR_NESTED);\
#define tuya_ble_device_exit_critical() \
app_util_critical_region_exit(__CR_NESTED); \
}
Function | tuya_ble_device_exit_critical |
---|---|
Function prototype | void tuya_ble_device_exit_critical(void) |
Description | Exit the critical section. |
Parameters | None |
Return value | None |
Notes | Specify the critical section by defining a macro. Take the Nordic platform as an example. |
#define tuya_ble_device_enter_critical() \
{ \
uint8_t __CR_NESTED = 0; \
app_util_critical_region_enter(&__CR_NESTED);\
#define tuya_ble_device_exit_critical() \
app_util_critical_region_exit(__CR_NESTED); \
}
Function | tuya_ble_rand_generator |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_rand_generator(uint8_t* p_buf, uint8_t len) |
Description | Generate a random number. |
Parameters | p_buf [out]: the pointer to an array of random numbers. len[in]: the length of the random number. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Function | tuya_ble_rtc_get_timestamp |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_rtc_get_timestamp(uint32_t *timestamp,int32_t *timezone); |
Description | Get Unix timestamp. |
Parameters | timestamp [out]: the timestamp. timezone [out]: the timezone, which is a signed integer, 100 times the value of the actual time zone. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | The time is read from the real-time clock (RTC) of the chip. If your chip is not equipped with an RTC, implementing this function is not necessary. |
Function | tuya_ble_rtc_set_timestamp |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_rtc_set_timestamp(uint32_t timestamp,int32_t timezone) |
Description | Update Unix timestamp. |
Parameters | timestamp [in]: the Unix timestamp. timezone [in]: the time zone, which is a signed integer, 100 times the value of the actual time zone. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | The SDK calls this function to update the time that is read from the RTC of the chip. If your chip is not equipped with an RTC, implementing this function is not necessary. |
Function | tuya_ble_nv_init |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_nv_init(void) |
Description | Initialize the non-volatile (NV) memory. |
Parameters | None |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | This function is used with the NV memory address defined in the Config file. The SDK calls the NV function to store and manage information such as authorization. |
Function | tuya_ble_nv_erase |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_nv_erase(uint32_t addr,uint32_t size) |
Description | Erase the NV memory. |
Parameters | addr[in]: the start address of the NV memory to be erased. size[in]: the size of the memory to be erased, in bytes. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | This function is used with the NV memory address defined in the Config file. The SDK calls the NV function to store and manage information such as authorization. |
Function | tuya_ble_nv_write |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_nv_write(uint32_t addr,const uint8_t * p_data, uint32_t size) |
Description | Write to the NV memory. |
Parameters | addr[in]: points to the start address of the data to be written. p_data[in]: the start address. size[in]: the size of the data to be written, in bytes. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | This function is used with the NV memory address defined in the Config file. The SDK calls the NV function to store and manage information such as authorization. |
Function | tuya_ble_nv_read |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_nv_read(uint32_t addr,uint8_t * p_data, uint32_t size) |
Description | Read data from the NV memory. |
Parameters | addr[in]: the start address of the NV memory to be read. p_data[out]: the address of the data. size[in]: the size of the data to be read, in bytes. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | This function is used with the NV memory address defined in the Config file. The SDK calls the NV function to store and manage information such as authorization. |
Function | tuya_ble_common_uart_init |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_common_uart_init(void) |
Description | Initialize the UART interface. |
Parameters | None |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes |
|
Function | tuya_ble_common_uart_send_data |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_common_uart_send_data(const uint8_t *p_data,uint16_t len) |
Description | The UART interface sends data. |
Parameters | p_data[in]: the pointer to data to be sent. len[in]: the length of data to be sent. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | This UART interface is used for the production test and license authorization. |
Function | tuya_ble_os_task_create |
---|---|
Function prototype | bool tuya_ble_os_task_create(void **pp_handle, const char *p_name, void(*p_routine)(void *),void *p_param, uint16_t stack_size, uint16_t priority) |
Description | Create a task. |
Parameters | pp_handle [out]: used to pass back a handle by which the created task can be referenced. p_name[in]: a descriptive name for the task. p_routine [in]: the pointer to task routine function that must be implemented to never return. p_param[in]: pointer parameter passed to the task routine function. stack_size[in]: the size of the task stack, in bytes. priority[in]: the priority at which the task should run. Higher priority task has higher priority value. |
Return value | True : a task is created and added to the task ready list. False : failed to create a task. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_task_delete |
---|---|
Function prototype | bool tuya_ble_os_task_delete(void *p_handle) |
Description | Remove a task from RTOS’s task management. The task being deleted will be removed from the RUNNING , READY , or WAITING state. |
Parameters | pp_handle [in]: the handle of the task to be deleted. |
Return value | True : a task is deleted successfully.False : failed to delete a task. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_task_suspend |
---|---|
Function prototype | bool tuya_ble_os_task_suspend(void *p_handle) |
Description | Suspend a task. The suspended task will not be scheduled and get any microcontroller processing time. |
Parameters | pp_handle [in]: the handle of the task to be suspended. |
Return value | True : a task is suspended successfully. False : failed to suspend a task. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_task_resume |
---|---|
Function prototype | bool tuya_ble_os_task_resume(void *p_handle) |
Description | Resume a suspended task. |
Parameters | pp_handle [in]: the handle of the task to be resumed. |
Return value | True : a task is resumed successfully. False : failed to resume a task. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_msg_queue_create |
---|---|
Function prototype | bool tuya_ble_os_msg_queue_create(void **pp_handle, uint32_t msg_num, uint32_tmsg_size) |
Description | Create a message queue instance. This allocates the storage required by the new queue and passes back a handle for the queue. |
Parameters | pp_handle [out]: used to pass back a handle by which the message queue can be referenced. msg_num [in]: the maximum number of items that the queue can contain. msg_size [in]: the number of bytes each item in the queue will require. |
Return value | True : a message queue is created successfully. False : failed to create a message queue. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_msg_queue_delete |
---|---|
Function prototype | bool tuya_ble_os_msg_queue_delete(void *p_handle) |
Description | Delete a message queue instance. |
Parameters | pp_handle [in]: the handle of the message queue being deleted. |
Return value | True : a message queue is deleted successfully. False : failed to delete a message queue. |
Notes | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_msg_queue_peek |
---|---|
Function prototype | bool tuya_ble_os_msg_queue_peek(void *p_handle, uint32_t *p_msg_num) |
Description | Peek the number of items sent and resided on the message queue. |
Parameters | pp_handle [in]: the handle of the message queue being peeked. p_msg_num[out]: used to pass back the number of items residing on the message queue. |
Return value | True : peek at a message queue successfully. False : failed to peek at a message queue. |
Things to note | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_msg_queue_send |
---|---|
Function prototype | bool tuya_ble_os_msg_queue_send(void *p_handle, void *p_msg, uint32_t wait_ms) |
Description | Send an item to the back of the specified message queue. |
Parameters | pp_handle [in]: the handle of the message queue on which the item is to be sent. p_msg[in]: the pointer to the item that is to be sent on the queue. wait_ms[in]: the maximum amount of time in milliseconds that the task should block waiting for the item to be sent on the queue.
|
Return value | True : a message item is sent successfully. False : failed to send a message item. |
Things to note | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_os_msg_queue_recv |
---|---|
Function prototype | bool tuya_ble_os_msg_queue_recv(void *p_handle, void *p_msg, uint32_t wait_ms) |
Description | Receive an item from the specified message queue. |
Parameters | pp_handle [in]: the handle of the message queue from which the item is to be received. p_msg[out]: pointer to the buffer into which the received item will be copied. wait_ms[in]: the maximum amount of time in milliseconds that the task should block waiting for the item to be received on the queue.
|
Return value | True : a message item is received successfully. False : failed to receive a message item. |
Things to note | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_event_queue_send_port |
---|---|
Function prototype | bool tuya_ble_event_queue_send_port(tuya_ble_evt_param_t *evt, uint32_t wait_ms) |
Description | If the TUYA_BLE_SELF_BUILT_TASK is not defined, the application needs to provide the task to the SDK for event processing. The SDK uses this port to send events to the provided task. |
Parameters | evt [in]: the message data point to be sent. wait_ms[in]: the maximum amount of time in milliseconds that the task should block waiting for the item to be sent on the queue.
|
Return value | True : a message item is sent successfully. False : failed to send a message item. |
Things to note | If your chip does not run an OS, this function is not necessary. |
Function | tuya_ble_aes128_ecb_encrypt |
---|---|
Function prototype | bool tuya_ble_aes128_ecb_encrypt(uint8_t *key,uint8_t *input,uint16_tinput_len,uint8_t *output) |
Description | Encrypt the plain text and key by using 128 bit AES in electronic codebook (ECB) mode. |
Parameters | key [in]: the key to encrypt the plain text. In_put[in]: specify the plain text to be encrypted. in_put_len[in]: the length of data to be encrypted, which must be a multiple of 16. Out_put[out]: the output buffer for storing encrypted data. |
Return value | True : succeeded. False : failed. |
Function | tuya_ble_aes128_ecb_decrypt |
---|---|
Function prototype | bool tuya_ble_aes128_ecb_decrypt(uint8_t *key,uint8_t *input,uint16_tinput_len,uint8_t *output) |
Description | Decrypt the designated data and key by using 128 bit AES in ECB mode. |
Parameters | key [in]: the key to decrypt data. In_put[in]: the data to be decrypted. in_put_len[in]: the length of data to be decrypted, which must be a multiple of 16. Out_put[out]: the output buffer for storing decrypted data. |
Return value | True : succeeded. False : failed. |
Function | tuya_ble_aes128_cbc_encrypt |
---|---|
Function prototype | bool tuya_ble_aes128_cbc_encrypt(uint8_t *key,uint8_t *iv,uint8_t input,uint16_t input_len,uint8_toutput) |
Description | Encrypt the plain text and key by using 128 bit AES in cipher-block chaining (CBC) mode. |
Parameters | key [in]: the key to encrypt the plain text. iv[in]: the initialization vector (IV). In_put[in]: specify the plain text to be encrypted. in_put_len[in]: the length of data to be encrypted, which must be a multiple of 16. Out_put[out]: the output buffer for storing encrypted data. |
Return value | True : succeeded. False : failed. |
Function | tuya_ble_aes128_cbc_decrypt |
---|---|
Function prototype | bool tuya_ble_aes128_cbc_decrypt(uint8_t*key,uint8_t *iv,uint8_t *input,uint16_t input_len,uint8_t *output) |
Description | Decrypt the designated data and key by using 128 bit AES in CBC mode. |
Parameters | key [in]: the key to decrypt data. Iv[in]: the initialization vector. In_put[in]: the data to be decrypted. in_put_len[in]: the length of data to be decrypted, which must be a multiple of 16. Out_put[out]: the output buffer for storing decrypted data. |
Return value |
Function | tuya_ble_md5_crypt |
---|---|
Function prototype | booltuya_ble_md5_crypt(uint8_t *input,uint16_t input_len,uint8_t *output) |
Description | MD5 checksum. |
Parameters | In_put[in]: specify the plain text to be encrypted. in_put_len[in]: the length of data to be encrypted. Out_put[out]: the output buffer for storing the 16-byte MD5 hash. |
Return value | True : succeeded. False : failed. |
Function | tuya_ble_hmac_sha1_crypt |
---|---|
Function prototype | bool tuya_ble_hmac_sha1_crypt(constuint8_t *key, uint32_t key_len, const uint8_t *input, uint32_t input_len,uint8_t *output) |
Description | Calculate the full generic HMAC on the input buffer with the provided key. |
Parameters | key [in]: HMAC key. key_len[in]: the length of HMAC key, in bytes. In_put[in]: specify the plain text to be encrypted. in_put_len[in]: the length of data to be encrypted. out_put[out]: the output buffer for storing the result. |
Return value | True : succeeded. False : failed. |
Notes | Not in use. |
Function | tuya_ble_hmac_sha256_crypt |
---|---|
Function prototype | bool tuya_ble_hmac_sha256_crypt(const uint8_t *key, uint32_t key_len, const uint8_t *input, uint32_t input_len, uint8_t *output) |
Description | Calculate the full generic HMAC on the input buffer with the provided key. |
Parameters | key [in]: HMAC key. key_len[in]: the length of HMAC key, in bytes. In_put[in]: specify the plain text to be encrypted. in_put_len[in]: the length of data to be encrypted. out_put[out]: the output buffer for storing the result. |
Return value | True : succeeded. False : failed. |
Notes | Not in use. |
Function | tuya_ble_storage_private_data |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_storage_private_data(tuya_ble_private_data_type private_data_type, uint8_t *p_data, uint32_t data_size) |
Description | Store the data of keys, used for the advanced encryption based on the secure cryptoprocessor. |
Parameters | private_data_type[in]: the data type. p_data[in]: the start address of data to be written. data_size[in]: the length of data. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_get_dev_crt_len |
---|---|
Function prototype | uint32_t tuya_ble_get_dev_crt_len(void) |
Description | Get the length of the secure certificate stored in the secure cryptoprocessor. |
Parameters | None |
Return value | Length of the certificate. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_get_dev_crt_der |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_get_dev_crt_der(uint8_t *p_der,uint32_t der_len)) |
Description | Read the data of the device certificate from the secure cryptoprocessor. |
Parameters | p_der[out]: the address of the certificate. der_len[in]: the length of the certificate. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_ecc_keypair_gen_secp256r1 |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_ecc_keypair_gen_secp256r1(uint8_t *public_key,uint8_t *private_key) |
Description | Generate ECDH key pair using secp256r1 curve. |
Parameters | public_key[out]: the generated public key. private_key[out]: the generated private key. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_ecc_shared_secret_compute_secp256r1 |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_ecc_shared_secret_compute_secp256r1(uint8_t *public_key,uint8_t *private_key,uint8_t *secret_key) |
Description | Calculate the shared key. |
Parameters | public_key[in]: public key. private_key[in]: private key. secret_key[out]: shared key. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_ecc_sign_secp256r1 |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_ecc_sign_secp256r1(const uint8_t *p_sk, const uint8_t * p_data, uint32_t data_size,uint8_t *p_sig) |
Description | Calculate the ECDSA signature. |
Parameters | p_sk[in]: sign a private key. p_data[in]: the data to be signed. data_size[in]: the length of data to be signed. p_sig[out]: the signed data. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_ecc_verify_secp256r1 |
---|---|
Function prototype | tuya_ble_status_t tuya_ble_ecc_verify_secp256r1(const uint8_t *p_pk, const uint8_t * p_data, uint32_t data_size,const uint8_t *p_sig) |
Description | Verify the ECDSA signature. |
Parameters | p_pk[in]: verify the signature of a public key. p_data[in]: the data to be verified. data_size[in]: the length of data to be verified. p_sig[in]: the verified data. |
Return value | TUYA_BLE_SUCCESS : succeeded. Other values: failed. |
Notes | If secure cryptoprocessor-based encryption is not adopted, this function is not necessary. |
Function | tuya_ble_port_malloc |
---|---|
Function prototype | void *tuya_ble_port_malloc( uint32_t size ) |
Description | Allocate the memory space. |
Parameters | Size[in]: the size of required memory. |
Return value | The address of the allocated memory. If NULL is returned, memory allocation failed. |
Notes | Implement this function if you port TUYA_BLE_USE_PLATFORM_MEMORY_HEAP==1 . |
Function | tuya_ble_port_free |
---|---|
Function prototype | void tuya_ble_port_free(void *pv ) |
Description | Release the allocated memory space. |
Parameters | pv[in]: the address of the released memory space. |
Return value | None. |
Notes | Implement this function if you port TUYA_BLE_USE_PLATFORM_MEMORY_HEAP==1 . |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback