Merge pull request #13680 from Jason2866/comp_silence

fix compiler warnings
This commit is contained in:
Jason2866 2021-11-15 12:52:32 +01:00 committed by GitHub
commit 67a8380131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 124 additions and 128 deletions

View File

@ -309,7 +309,7 @@ const hap_val_t *hap_char_get_step_val(hap_char_t *hc)
/** /**
* @brief HAP create a characteristics * @brief HAP create a characteristics
*/ */
static hap_char_t *hap_char_create(char *type_uuid, uint32_t permission, hap_char_format_t format, hap_val_t val) static hap_char_t *hap_char_create(const char *type_uuid, uint32_t permission, hap_char_format_t format, hap_val_t val)
{ {
__hap_char_t *new_ch; __hap_char_t *new_ch;
@ -333,42 +333,42 @@ static hap_char_t *hap_char_create(char *type_uuid, uint32_t permission, hap_cha
return (hap_char_t *) new_ch; return (hap_char_t *) new_ch;
} }
hap_char_t *hap_char_bool_create(char *type_uuid, uint16_t perms, bool b) hap_char_t *hap_char_bool_create(const char *type_uuid, uint16_t perms, bool b)
{ {
hap_val_t val = {.b = b}; hap_val_t val = {.b = b};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_BOOL, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_BOOL, val);
} }
hap_char_t *hap_char_uint8_create(char *type_uuid, uint16_t perms, uint8_t u8) hap_char_t *hap_char_uint8_create(const char *type_uuid, uint16_t perms, uint8_t u8)
{ {
hap_val_t val = {.u = u8}; hap_val_t val = {.u = u8};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT8, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT8, val);
} }
hap_char_t *hap_char_uint16_create(char *type_uuid, uint16_t perms, uint16_t u16) hap_char_t *hap_char_uint16_create(const char *type_uuid, uint16_t perms, uint16_t u16)
{ {
hap_val_t val = {.u = u16}; hap_val_t val = {.u = u16};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT16, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT16, val);
} }
hap_char_t *hap_char_uint32_create(char *type_uuid, uint16_t perms, uint32_t u32) hap_char_t *hap_char_uint32_create(const char *type_uuid, uint16_t perms, uint32_t u32)
{ {
hap_val_t val = {.u = u32}; hap_val_t val = {.u = u32};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT32, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT32, val);
} }
hap_char_t *hap_char_uint64_create(char *type_uuid, uint16_t perms, uint64_t u64) hap_char_t *hap_char_uint64_create(const char *type_uuid, uint16_t perms, uint64_t u64)
{ {
hap_val_t val = {.i64 = u64}; hap_val_t val = {.i64 = u64};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT64, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_UINT64, val);
} }
hap_char_t *hap_char_int_create(char *type_uuid, uint16_t perms, int i32) hap_char_t *hap_char_int_create(const char *type_uuid, uint16_t perms, int i32)
{ {
hap_val_t val = {.i = i32}; hap_val_t val = {.i = i32};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_INT, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_INT, val);
} }
hap_char_t *hap_char_float_create(char *type_uuid, uint16_t perms, float f) hap_char_t *hap_char_float_create(const char *type_uuid, uint16_t perms, float f)
{ {
hap_val_t val = {.f = f}; hap_val_t val = {.f = f};
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_FLOAT, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_FLOAT, val);
} }
hap_char_t *hap_char_string_create(char *type_uuid, uint16_t perms, char *s) hap_char_t *hap_char_string_create(const char *type_uuid, uint16_t perms, const char *s)
{ {
hap_val_t val; hap_val_t val;
if (s) if (s)
@ -378,7 +378,7 @@ hap_char_t *hap_char_string_create(char *type_uuid, uint16_t perms, char *s)
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_STRING, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_STRING, val);
} }
hap_char_t *hap_char_data_create(char *type_uuid, uint16_t perms, hap_data_val_t *d) hap_char_t *hap_char_data_create(const char *type_uuid, uint16_t perms, hap_data_val_t *d)
{ {
hap_val_t val = {0}; hap_val_t val = {0};
if (d) { if (d) {
@ -387,7 +387,7 @@ hap_char_t *hap_char_data_create(char *type_uuid, uint16_t perms, hap_data_val_t
return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_DATA, val); return hap_char_create(type_uuid, perms, HAP_CHAR_FORMAT_DATA, val);
} }
hap_char_t *hap_char_tlv8_create(char *type_uuid, uint16_t perms, hap_tlv8_val_t *t) hap_char_t *hap_char_tlv8_create(const char *type_uuid, uint16_t perms, hap_tlv8_val_t *t)
{ {
hap_val_t val = {0}; hap_val_t val = {0};
if (t) { if (t) {

View File

@ -234,7 +234,7 @@ static struct httpd_uri hap_pair_verify = {
.handler = hap_http_pair_verify_handler, .handler = hap_http_pair_verify_handler,
}; };
static int hap_add_char_val_json(hap_char_format_t format, char *key, static int hap_add_char_val_json(hap_char_format_t format, const char *key,
hap_val_t *val, json_gen_str_t *jptr) hap_val_t *val, json_gen_str_t *jptr)
{ {
switch (format) { switch (format) {
@ -970,7 +970,7 @@ static int hap_http_put_characteristics(httpd_req_t *req)
return HAP_SUCCESS; return HAP_SUCCESS;
} }
static bool hap_get_bool_url_param(char *query_str, char *key) static bool hap_get_bool_url_param(const char *query_str, const char *key)
{ {
char val[6]; /* Max string will be "false" */ char val[6]; /* Max string will be "false" */
if (httpd_query_key_value(query_str, key, val, sizeof(val)) == HAP_SUCCESS) { if (httpd_query_key_value(query_str, key, val, sizeof(val)) == HAP_SUCCESS) {

View File

@ -81,7 +81,7 @@ static void hap_nw_configured_sm(hap_internal_event_t event, hap_state_t *state)
static void hap_common_sm(hap_internal_event_t event) static void hap_common_sm(hap_internal_event_t event)
{ {
char *reboot_reason = HAP_REBOOT_REASON_UNKNOWN; const char *reboot_reason = HAP_REBOOT_REASON_UNKNOWN;
switch (event) { switch (event) {
case HAP_INTERNAL_EVENT_RESET_PAIRINGS: case HAP_INTERNAL_EVENT_RESET_PAIRINGS:
ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Resetting all Pairing Information"); ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Resetting all Pairing Information");
@ -149,7 +149,7 @@ static void hap_common_sm(hap_internal_event_t event)
/* Wait for some time after peeforming the operations and then reboot */ /* Wait for some time after peeforming the operations and then reboot */
ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Rebooting..."); ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Rebooting...");
hap_report_event(HAP_EVENT_ACC_REBOOTING, reboot_reason, strlen(reboot_reason) + 1); hap_report_event(HAP_EVENT_ACC_REBOOTING, (void*)reboot_reason, strlen(reboot_reason) + 1);
vTaskDelay(1000 / hap_platform_os_get_msec_per_tick()); vTaskDelay(1000 / hap_platform_os_get_msec_per_tick());
esp_restart(); esp_restart();
} }

View File

@ -110,7 +110,7 @@ hap_char_t *hap_serv_get_char_by_uuid(hap_serv_t *hs, const char *uuid)
/** /**
* @brief get characteristics UUID prefix number * @brief get characteristics UUID prefix number
*/ */
char *hap_serv_get_uuid(hap_serv_t *hs) const char *hap_serv_get_uuid(hap_serv_t *hs)
{ {
return ((__hap_serv_t *)hs)->type_uuid; return ((__hap_serv_t *)hs)->type_uuid;
} }
@ -145,7 +145,7 @@ static int hap_serv_def_bulk_read_cb(hap_read_data_t read_data[], int count,
/** /**
* @brief HAP create a service * @brief HAP create a service
*/ */
hap_serv_t *hap_serv_create(char *type_uuid) hap_serv_t *hap_serv_create(const char *type_uuid)
{ {
ESP_MFI_ASSERT(type_uuid); ESP_MFI_ASSERT(type_uuid);
__hap_serv_t *_hs = hap_platform_memory_calloc(1, sizeof(__hap_serv_t)); __hap_serv_t *_hs = hap_platform_memory_calloc(1, sizeof(__hap_serv_t));
@ -198,7 +198,7 @@ uint32_t hap_serv_get_iid(hap_serv_t *hs)
return tmp->iid; return tmp->iid;
} }
char *hap_serv_get_type_uuid(hap_serv_t *hs) const char *hap_serv_get_type_uuid(hap_serv_t *hs)
{ {
if (!hs) if (!hs)
return 0; return 0;

View File

@ -44,7 +44,7 @@ typedef struct hap_linked_serv hap_linked_serv_t;
* HAP service information * HAP service information
*/ */
typedef struct { typedef struct {
char *type_uuid; /* String that defines the type of the service. */ const char *type_uuid; /* String that defines the type of the service. */
uint32_t iid; /* service instance ID */ uint32_t iid; /* service instance ID */
@ -69,8 +69,8 @@ typedef struct {
bool hap_serv_get_hidden(hap_serv_t *hs); bool hap_serv_get_hidden(hap_serv_t *hs);
bool hap_serv_get_primary(hap_serv_t *hs); bool hap_serv_get_primary(hap_serv_t *hs);
hap_char_t *hap_serv_get_char_by_iid(hap_serv_t *hs, int32_t iid); hap_char_t *hap_serv_get_char_by_iid(hap_serv_t *hs, int32_t iid);
char *hap_serv_get_uuid(hap_serv_t *hs); const char *hap_serv_get_uuid(hap_serv_t *hs);
hap_serv_t *hap_serv_create(char *type_uuid); hap_serv_t *hap_serv_create(const char *type_uuid);
void hap_serv_delete(hap_serv_t *hs); void hap_serv_delete(hap_serv_t *hs);
int hap_serv_add_char(hap_serv_t *hs, hap_char_t *hc); int hap_serv_add_char(hap_serv_t *hs, hap_char_t *hc);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -234,23 +234,23 @@ typedef int (*hap_identify_routine_t) (hap_acc_t *acc);
/** HAP Accessory configuration */ /** HAP Accessory configuration */
typedef struct { typedef struct {
/** Name (Mandatory) */ /** Name (Mandatory) */
char *name; const char *name;
/** Model (Mandatory) */ /** Model (Mandatory) */
char *model; const char *model;
/** Manufacturer (Mandatory) */ /** Manufacturer (Mandatory) */
char *manufacturer; const char *manufacturer;
/** Serial Number (Mandatory) */ /** Serial Number (Mandatory) */
char *serial_num; const char *serial_num;
/** Firmware Revision number in format x[.y[.z]] (Mandatory) */ /** Firmware Revision number in format x[.y[.z]] (Mandatory) */
char *fw_rev; const char *fw_rev;
/** Hardware revision number in format x[.y[.z]] (Optional. Can be NULL )*/ /** Hardware revision number in format x[.y[.z]] (Optional. Can be NULL )*/
char *hw_rev; const char *hw_rev;
/** HAP Protocol version supported by the accessory. Should be set to "1.1" /** HAP Protocol version supported by the accessory. Should be set to "1.1"
* @note The value set here will currently be ignored and assumed to be 1.1 * @note The value set here will currently be ignored and assumed to be 1.1
* as it is the only protocol version currently supported. * as it is the only protocol version currently supported.
* This is valid only for the Primary accessory. * This is valid only for the Primary accessory.
*/ */
char *pv; const char *pv;
/** Category Identifier for the Accessory. This is valid only for the /** Category Identifier for the Accessory. This is valid only for the
* primary accessory * primary accessory
*/ */
@ -640,7 +640,7 @@ hap_serv_t *hap_acc_get_first_serv(hap_acc_t *ha);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_bool_create(char *type_uuid, uint16_t perms, bool val); hap_char_t *hap_char_bool_create(const char *type_uuid, uint16_t perms, bool val);
/** /**
* @brief Create an 8-bit unsigned integer Characteristic Object * @brief Create an 8-bit unsigned integer Characteristic Object
@ -652,7 +652,7 @@ hap_char_t *hap_char_bool_create(char *type_uuid, uint16_t perms, bool val);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_uint8_create(char *type_uuid, uint16_t perms, uint8_t val); hap_char_t *hap_char_uint8_create(const char *type_uuid, uint16_t perms, uint8_t val);
/** /**
* @brief Create a 16-bit unsigned integer Characteristic Object * @brief Create a 16-bit unsigned integer Characteristic Object
@ -664,7 +664,7 @@ hap_char_t *hap_char_uint8_create(char *type_uuid, uint16_t perms, uint8_t val);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_uint16_create(char *type_uuid, uint16_t perms, uint16_t val); hap_char_t *hap_char_uint16_create(const char *type_uuid, uint16_t perms, uint16_t val);
/** /**
* @brief Create a 32-bit unsigned integer Characteristic Object * @brief Create a 32-bit unsigned integer Characteristic Object
@ -676,7 +676,7 @@ hap_char_t *hap_char_uint16_create(char *type_uuid, uint16_t perms, uint16_t val
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_uint32_create(char *type_uuid, uint16_t perms, uint32_t val); hap_char_t *hap_char_uint32_create(const char *type_uuid, uint16_t perms, uint32_t val);
/** /**
* @brief Create a 64-bit unsigned integer Characteristic Object * @brief Create a 64-bit unsigned integer Characteristic Object
@ -688,7 +688,7 @@ hap_char_t *hap_char_uint32_create(char *type_uuid, uint16_t perms, uint32_t val
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_uint64_create(char *type_uuid, uint16_t perms, uint64_t val); hap_char_t *hap_char_uint64_create(const char *type_uuid, uint16_t perms, uint64_t val);
/** /**
* @brief Create a 32-bit signed integer Characteristic Object * @brief Create a 32-bit signed integer Characteristic Object
@ -700,7 +700,7 @@ hap_char_t *hap_char_uint64_create(char *type_uuid, uint16_t perms, uint64_t val
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_int_create(char *type_uuid, uint16_t perms, int val); hap_char_t *hap_char_int_create(const char *type_uuid, uint16_t perms, int val);
/** /**
* @brief Create a Floating point Characteristic Object * @brief Create a Floating point Characteristic Object
@ -712,7 +712,7 @@ hap_char_t *hap_char_int_create(char *type_uuid, uint16_t perms, int val);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_float_create(char *type_uuid, uint16_t perms, float val); hap_char_t *hap_char_float_create(const char *type_uuid, uint16_t perms, float val);
/** /**
* @brief Create a String Characteristic Object * @brief Create a String Characteristic Object
@ -724,7 +724,7 @@ hap_char_t *hap_char_float_create(char *type_uuid, uint16_t perms, float val);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_string_create(char *type_uuid, uint16_t perms, char *val); hap_char_t *hap_char_string_create(const char *type_uuid, uint16_t perms, const char *val);
/** /**
* @brief Create a Data Characteristic Object * @brief Create a Data Characteristic Object
@ -736,7 +736,7 @@ hap_char_t *hap_char_string_create(char *type_uuid, uint16_t perms, char *val);
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_data_create(char *type_uuid, uint16_t perms, hap_data_val_t *val); hap_char_t *hap_char_data_create(const char *type_uuid, uint16_t perms, hap_data_val_t *val);
/** /**
* @brief Create a TLV8 Characteristic Object * @brief Create a TLV8 Characteristic Object
@ -748,7 +748,7 @@ hap_char_t *hap_char_data_create(char *type_uuid, uint16_t perms, hap_data_val_t
* @return Handle for the characteristic object created * @return Handle for the characteristic object created
* @return NULL on error * @return NULL on error
*/ */
hap_char_t *hap_char_tlv8_create(char *type_uuid, uint16_t perms, hap_tlv8_val_t *val); hap_char_t *hap_char_tlv8_create(const char *type_uuid, uint16_t perms, hap_tlv8_val_t *val);
/** /**
* @brief Delete a characteristic object * @brief Delete a characteristic object
@ -765,7 +765,7 @@ void hap_char_delete(hap_char_t *hc);
* @return Handle for the service object created * @return Handle for the service object created
* @return NULL on error * @return NULL on error
*/ */
hap_serv_t *hap_serv_create(char *type_uuid); hap_serv_t *hap_serv_create(const char *type_uuid);
/** /**
* @brief Delete a service object * @brief Delete a service object
@ -884,7 +884,7 @@ uint32_t hap_serv_get_iid(hap_serv_t *hs);
* *
* @return Type UUID for the service * @return Type UUID for the service
*/ */
char *hap_serv_get_type_uuid(hap_serv_t *hs); const char *hap_serv_get_type_uuid(hap_serv_t *hs);
/** /**
* @brief Get parent Service for given Characteristic * @brief Get parent Service for given Characteristic
* *

View File

@ -128,7 +128,7 @@ hap_char_t *hap_char_current_temperature_create(float curr_temp)
} }
/* Char: Firmware Revision */ /* Char: Firmware Revision */
hap_char_t *hap_char_firmware_revision_create(char *fw_rev) hap_char_t *hap_char_firmware_revision_create(const char *fw_rev)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_FIRMWARE_REVISION, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_FIRMWARE_REVISION,
HAP_CHAR_PERM_PR, fw_rev); HAP_CHAR_PERM_PR, fw_rev);
@ -139,7 +139,7 @@ hap_char_t *hap_char_firmware_revision_create(char *fw_rev)
} }
/* Char: Hardware Revision */ /* Char: Hardware Revision */
hap_char_t *hap_char_hardware_revision_create(char *hw_rev) hap_char_t *hap_char_hardware_revision_create(const char *hw_rev)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_HARDWARE_REVISION, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_HARDWARE_REVISION,
HAP_CHAR_PERM_PR, hw_rev); HAP_CHAR_PERM_PR, hw_rev);
@ -218,7 +218,7 @@ hap_char_t *hap_char_lock_target_state_create(uint8_t lock_targ_state)
} }
/* Char: Manufacturer */ /* Char: Manufacturer */
hap_char_t *hap_char_manufacturer_create(char *manufacturer) hap_char_t *hap_char_manufacturer_create(const char *manufacturer)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_MANUFACTURER, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_MANUFACTURER,
HAP_CHAR_PERM_PR, manufacturer); HAP_CHAR_PERM_PR, manufacturer);
@ -229,7 +229,7 @@ hap_char_t *hap_char_manufacturer_create(char *manufacturer)
} }
/* Char: Model */ /* Char: Model */
hap_char_t *hap_char_model_create(char *model) hap_char_t *hap_char_model_create(const char *model)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_MODEL, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_MODEL,
HAP_CHAR_PERM_PR, model); HAP_CHAR_PERM_PR, model);
@ -252,7 +252,7 @@ hap_char_t *hap_char_motion_detected_create(bool motion_detected)
} }
/* Char: Name */ /* Char: Name */
hap_char_t *hap_char_name_create(char *name) hap_char_t *hap_char_name_create(const char *name)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_NAME, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_NAME,
HAP_CHAR_PERM_PR, name); HAP_CHAR_PERM_PR, name);
@ -341,7 +341,7 @@ hap_char_t *hap_char_saturation_create(float saturation)
} }
/* Char: Serial Number */ /* Char: Serial Number */
hap_char_t *hap_char_serial_number_create(char *serial_num) hap_char_t *hap_char_serial_number_create(const char *serial_num)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_SERIAL_NUMBER, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_SERIAL_NUMBER,
HAP_CHAR_PERM_PR, serial_num); HAP_CHAR_PERM_PR, serial_num);
@ -424,7 +424,7 @@ hap_char_t *hap_char_temperature_display_units_create(uint8_t temp_disp_units)
} }
/* Char: Version */ /* Char: Version */
hap_char_t *hap_char_version_create(char *version) hap_char_t *hap_char_version_create(const char *version)
{ {
hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_VERSION, hap_char_t *hc = hap_char_string_create(HAP_CHAR_UUID_VERSION,
HAP_CHAR_PERM_PR, version); HAP_CHAR_PERM_PR, version);

View File

@ -227,7 +227,7 @@ hap_char_t *hap_char_current_temperature_create(float curr_temp);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_firmware_revision_create(char *fw_rev); hap_char_t *hap_char_firmware_revision_create(const char *fw_rev);
/** Create Hardware Revision Characteristic /** Create Hardware Revision Characteristic
* *
@ -239,7 +239,7 @@ hap_char_t *hap_char_firmware_revision_create(char *fw_rev);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_hardware_revision_create(char *hw_rev); hap_char_t *hap_char_hardware_revision_create(const char *hw_rev);
/** Heating Threshold Temperature Characteristic /** Heating Threshold Temperature Characteristic
* *
@ -309,7 +309,7 @@ hap_char_t *hap_char_lock_target_state_create(uint8_t lock_targ_state);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_manufacturer_create(char *manufacturer); hap_char_t *hap_char_manufacturer_create(const char *manufacturer);
/** Create Model Characteristic /** Create Model Characteristic
* *
@ -321,7 +321,7 @@ hap_char_t *hap_char_manufacturer_create(char *manufacturer);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_model_create(char *model); hap_char_t *hap_char_model_create(const char *model);
/** Create Motion Detected Characteristic /** Create Motion Detected Characteristic
* *
@ -345,7 +345,7 @@ hap_char_t *hap_char_motion_detected_create(bool motion_detected);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_name_create(char *name); hap_char_t *hap_char_name_create(const char *name);
/** Create Obstruction Detected Characteristic /** Create Obstruction Detected Characteristic
* *
@ -429,7 +429,7 @@ hap_char_t *hap_char_saturation_create(float saturation);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_serial_number_create(char *serial_num); hap_char_t *hap_char_serial_number_create(const char *serial_num);
/** Create Target Door State Characteristic /** Create Target Door State Characteristic
* *
@ -501,7 +501,7 @@ hap_char_t *hap_char_temperature_display_units_create(uint8_t temp_disp_units);
* @return Pointer to the characteristic object on success * @return Pointer to the characteristic object on success
* @return NULL on failure * @return NULL on failure
*/ */
hap_char_t *hap_char_version_create(char *version); hap_char_t *hap_char_version_create(const char *version);
/** Create Security System Current State Characteristic /** Create Security System Current State Characteristic
* *

View File

@ -82,7 +82,7 @@ esp_err_t hap_platform_httpd_set_sess_ctx(httpd_req_t *req, void *ctx, httpd_fre
return ESP_FAIL; return ESP_FAIL;
} }
static char * hap_platform_httpd_rqtype_to_string(int method) static const char * hap_platform_httpd_rqtype_to_string(int method)
{ {
switch (method) { switch (method) {
case HTTP_GET: case HTTP_GET:

View File

@ -16,7 +16,7 @@
//#define HEX_DBG_ENABLE //#define HEX_DBG_ENABLE
#ifdef HEX_DBG_ENABLE #ifdef HEX_DBG_ENABLE
void hex_dbg_with_name(char *name, unsigned char *buf, int buf_len) void hex_dbg_with_name(const char *name, unsigned char *buf, int buf_len)
{ {
int i; int i;
printf("%s: ", name); printf("%s: ", name);
@ -28,7 +28,7 @@ void hex_dbg_with_name(char *name, unsigned char *buf, int buf_len)
printf("\r\n"); printf("\r\n");
} }
#else #else
void hex_dbg_with_name(char *name, unsigned char *buf, int buf_len) void hex_dbg_with_name(const char *name, unsigned char *buf, int buf_len)
{ {
} }
#endif /* HEX_DBG_ENABLED */ #endif /* HEX_DBG_ENABLED */

View File

@ -13,6 +13,6 @@
// limitations under the License. // limitations under the License.
#ifndef _HEXDUMP_H_ #ifndef _HEXDUMP_H_
#define _HEXDUMP_H_ #define _HEXDUMP_H_
void hex_dbg_with_name(char *name, unsigned char *buf, int buf_len); void hex_dbg_with_name(const char *name, unsigned char *buf, int buf_len);
#endif /* _HEXDUMP_H_ */ #endif /* _HEXDUMP_H_ */

View File

@ -34,13 +34,13 @@ static inline int json_gen_get_empty_len(json_gen_str_t *jstr)
* flushed out will always be equal to the size of the buffer unless * flushed out will always be equal to the size of the buffer unless
* this is the last chunk being flushed out on json_gen_end_str() * this is the last chunk being flushed out on json_gen_end_str()
*/ */
static int json_gen_add_to_str(json_gen_str_t *jstr, char *str) static int json_gen_add_to_str(json_gen_str_t *jstr, const char *str)
{ {
if (!str) { if (!str) {
return 0; return 0;
} }
int len = strlen(str); int len = strlen(str);
char *cur_ptr = str; const char *cur_ptr = str;
while (1) { while (1) {
int len_remaining = json_gen_get_empty_len(jstr); int len_remaining = json_gen_get_empty_len(jstr);
int copy_len = len_remaining > len ? len : len_remaining; int copy_len = len_remaining > len ? len : len_remaining;
@ -91,7 +91,7 @@ static inline void json_gen_handle_comma(json_gen_str_t *jstr)
} }
static int json_gen_handle_name(json_gen_str_t *jstr, char *name) static int json_gen_handle_name(json_gen_str_t *jstr, const char *name)
{ {
json_gen_add_to_str(jstr, "\""); json_gen_add_to_str(jstr, "\"");
json_gen_add_to_str(jstr, name); json_gen_add_to_str(jstr, name);
@ -126,7 +126,7 @@ int json_gen_end_array(json_gen_str_t *jstr)
return json_gen_add_to_str(jstr, "]"); return json_gen_add_to_str(jstr, "]");
} }
int json_gen_push_object(json_gen_str_t *jstr, char *name) int json_gen_push_object(json_gen_str_t *jstr, const char *name)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -140,7 +140,7 @@ int json_gen_pop_object(json_gen_str_t *jstr)
return json_gen_add_to_str(jstr, "}"); return json_gen_add_to_str(jstr, "}");
} }
int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str) int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, char *object_str)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -148,7 +148,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str)
return json_gen_add_to_str(jstr, object_str); return json_gen_add_to_str(jstr, object_str);
} }
int json_gen_push_array(json_gen_str_t *jstr, char *name) int json_gen_push_array(json_gen_str_t *jstr, const char *name)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -161,7 +161,7 @@ int json_gen_pop_array(json_gen_str_t *jstr)
return json_gen_add_to_str(jstr, "]"); return json_gen_add_to_str(jstr, "]");
} }
int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str) int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, char *array_str)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -177,7 +177,7 @@ static int json_gen_set_bool(json_gen_str_t *jstr, bool val)
else else
return json_gen_add_to_str(jstr, "false"); return json_gen_add_to_str(jstr, "false");
} }
int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val) int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -198,7 +198,7 @@ static int json_gen_set_int(json_gen_str_t *jstr, int val)
return json_gen_add_to_str(jstr, str); return json_gen_add_to_str(jstr, str);
} }
int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val) int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -219,7 +219,7 @@ static int json_gen_set_float(json_gen_str_t *jstr, float val)
snprintf(str, MAX_FLOAT_IN_STR, "%.*f", JSON_FLOAT_PRECISION, val); snprintf(str, MAX_FLOAT_IN_STR, "%.*f", JSON_FLOAT_PRECISION, val);
return json_gen_add_to_str(jstr, str); return json_gen_add_to_str(jstr, str);
} }
int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val) int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
@ -231,7 +231,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val)
return json_gen_set_float(jstr, val); return json_gen_set_float(jstr, val);
} }
static int json_gen_set_string(json_gen_str_t *jstr, char *val) static int json_gen_set_string(json_gen_str_t *jstr, const char *val)
{ {
jstr->comma_req = true; jstr->comma_req = true;
json_gen_add_to_str(jstr, "\""); json_gen_add_to_str(jstr, "\"");
@ -239,40 +239,40 @@ static int json_gen_set_string(json_gen_str_t *jstr, char *val)
return json_gen_add_to_str(jstr, "\""); return json_gen_add_to_str(jstr, "\"");
} }
int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val) int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
return json_gen_set_string(jstr, val); return json_gen_set_string(jstr, val);
} }
int json_gen_arr_set_string(json_gen_str_t *jstr, char *val) int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
return json_gen_set_string(jstr, val); return json_gen_set_string(jstr, val);
} }
static int json_gen_set_long_string(json_gen_str_t *jstr, char *val) static int json_gen_set_long_string(json_gen_str_t *jstr, const char *val)
{ {
jstr->comma_req = true; jstr->comma_req = true;
json_gen_add_to_str(jstr, "\""); json_gen_add_to_str(jstr, "\"");
return json_gen_add_to_str(jstr, val); return json_gen_add_to_str(jstr, val);
} }
int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val) int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);
return json_gen_set_long_string(jstr, val); return json_gen_set_long_string(jstr, val);
} }
int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val) int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
return json_gen_set_long_string(jstr, val); return json_gen_set_long_string(jstr, val);
} }
int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val) int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val)
{ {
return json_gen_add_to_str(jstr, val); return json_gen_add_to_str(jstr, val);
} }
@ -286,7 +286,7 @@ static int json_gen_set_null(json_gen_str_t *jstr)
jstr->comma_req = true; jstr->comma_req = true;
return json_gen_add_to_str(jstr, "null"); return json_gen_add_to_str(jstr, "null");
} }
int json_gen_obj_set_null(json_gen_str_t *jstr, char *name) int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name)
{ {
json_gen_handle_comma(jstr); json_gen_handle_comma(jstr);
json_gen_handle_name(jstr, name); json_gen_handle_name(jstr, name);

View File

@ -170,7 +170,7 @@ int json_gen_end_array(json_gen_str_t *jstr);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_push_object(json_gen_str_t *jstr, char *name); int json_gen_push_object(json_gen_str_t *jstr, const char *name);
/** Pop a named JSON object /** Pop a named JSON object
* *
@ -204,7 +204,7 @@ int json_gen_pop_object(json_gen_str_t *jstr);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that. * added after that.
*/ */
int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str); int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, char *object_str);
/** Push a named JSON array /** Push a named JSON array
* *
@ -219,7 +219,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str)
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_push_array(json_gen_str_t *jstr, char *name); int json_gen_push_array(json_gen_str_t *jstr, const char *name);
/** Pop a named JSON array /** Pop a named JSON array
* *
@ -253,7 +253,7 @@ int json_gen_pop_array(json_gen_str_t *jstr);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that. * added after that.
*/ */
int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, char *array_str);
/** Add a boolean element to an object /** Add a boolean element to an object
* *
@ -272,7 +272,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val);
/** Add an integer element to an object /** Add an integer element to an object
* *
@ -291,7 +291,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val);
/** Add a float element to an object /** Add a float element to an object
* *
@ -310,7 +310,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val);
/** Add a string element to an object /** Add a string element to an object
* *
@ -329,7 +329,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val);
/** Add a NULL element to an object /** Add a NULL element to an object
* *
@ -347,7 +347,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_set_null(json_gen_str_t *jstr, char *name); int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name);
/** Add a boolean element to an array /** Add a boolean element to an array
* *
@ -411,7 +411,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_arr_set_string(json_gen_str_t *jstr, char *val); int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val);
/** Add a NULL element to an array /** Add a NULL element to an array
* *
@ -448,7 +448,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val);
/** Start a Long string in an array /** Start a Long string in an array
* *
@ -469,7 +469,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val);
/** Add to a JSON Long string /** Add to a JSON Long string
* *
@ -485,7 +485,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val);
* is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data
* added after that * added after that
*/ */
int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val); int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val);
/** End a JSON Long string /** End a JSON Long string
* *

View File

@ -23,7 +23,7 @@
#include <jsmn/jsmn.h> #include <jsmn/jsmn.h>
#include <json_parser.h> #include <json_parser.h>
static bool token_matches_str(jparse_ctx_t *ctx, json_tok_t *tok, char *str) static bool token_matches_str(jparse_ctx_t *ctx, json_tok_t *tok, const char *str)
{ {
char *js = ctx->js; char *js = ctx->js;
return ((strncmp(js + tok->start, str, strlen(str)) == 0) return ((strncmp(js + tok->start, str, strlen(str)) == 0)
@ -100,7 +100,7 @@ static int json_tok_to_string(jparse_ctx_t *jctx, json_tok_t *tok, char *val, in
return OS_SUCCESS; return OS_SUCCESS;
} }
static json_tok_t *json_obj_search(jparse_ctx_t *jctx, char *key) static json_tok_t *json_obj_search(jparse_ctx_t *jctx, const char *key)
{ {
json_tok_t *tok = jctx->cur; json_tok_t *tok = jctx->cur;
int size = tok->size; int size = tok->size;
@ -118,7 +118,7 @@ static json_tok_t *json_obj_search(jparse_ctx_t *jctx, char *key)
return NULL; return NULL;
} }
static json_tok_t *json_obj_get_val_tok(jparse_ctx_t *jctx, char *name, jsmntype_t type) static json_tok_t *json_obj_get_val_tok(jparse_ctx_t *jctx, const char *name, jsmntype_t type)
{ {
json_tok_t *tok = json_obj_search(jctx, name); json_tok_t *tok = json_obj_search(jctx, name);
if (!tok) if (!tok)
@ -129,7 +129,7 @@ static json_tok_t *json_obj_get_val_tok(jparse_ctx_t *jctx, char *name, jsmntype
return tok; return tok;
} }
int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem) int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY);
if (!tok) if (!tok)
@ -153,7 +153,7 @@ int json_obj_leave_array(jparse_ctx_t *jctx)
return OS_SUCCESS; return OS_SUCCESS;
} }
int json_obj_get_object(jparse_ctx_t *jctx, char *name) int json_obj_get_object(jparse_ctx_t *jctx, const char *name)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT);
if (!tok) if (!tok)
@ -176,7 +176,7 @@ int json_obj_leave_object(jparse_ctx_t *jctx)
return OS_SUCCESS; return OS_SUCCESS;
} }
int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val) int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE);
if (!tok) if (!tok)
@ -184,7 +184,7 @@ int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val)
return json_tok_to_bool(jctx, tok, val); return json_tok_to_bool(jctx, tok, val);
} }
int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val) int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE);
if (!tok) if (!tok)
@ -192,7 +192,7 @@ int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val)
return json_tok_to_int(jctx, tok, val); return json_tok_to_int(jctx, tok, val);
} }
int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val) int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE);
if (!tok) if (!tok)
@ -200,7 +200,7 @@ int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val)
return json_tok_to_int64(jctx, tok, val); return json_tok_to_int64(jctx, tok, val);
} }
int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val) int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_PRIMITIVE);
if (!tok) if (!tok)
@ -208,7 +208,7 @@ int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val)
return json_tok_to_float(jctx, tok, val); return json_tok_to_float(jctx, tok, val);
} }
int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size) int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_STRING); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_STRING);
if (!tok) if (!tok)
@ -216,7 +216,7 @@ int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size)
return json_tok_to_string(jctx, tok, val, size); return json_tok_to_string(jctx, tok, val, size);
} }
int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen) int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_STRING); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_STRING);
if (!tok) if (!tok)
@ -225,7 +225,7 @@ int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen)
return OS_SUCCESS; return OS_SUCCESS;
} }
int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size) int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT);
if (!tok) if (!tok)
@ -233,7 +233,7 @@ int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size)
return json_tok_to_string(jctx, tok, val, size); return json_tok_to_string(jctx, tok, val, size);
} }
int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen) int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_OBJECT);
if (!tok) if (!tok)
@ -241,7 +241,7 @@ int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen)
*strlen = tok->end - tok->start; *strlen = tok->end - tok->start;
return OS_SUCCESS; return OS_SUCCESS;
} }
int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size) int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY);
if (!tok) if (!tok)
@ -249,7 +249,7 @@ int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size)
return json_tok_to_string(jctx, tok, val, size); return json_tok_to_string(jctx, tok, val, size);
} }
int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen) int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen)
{ {
json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY); json_tok_t *tok = json_obj_get_val_tok(jctx, name, JSMN_ARRAY);
if (!tok) if (!tok)

View File

@ -43,20 +43,20 @@ typedef struct {
int json_parse_start(jparse_ctx_t *jctx, char *js, int len); int json_parse_start(jparse_ctx_t *jctx, char *js, int len);
int json_parse_end(jparse_ctx_t *jctx); int json_parse_end(jparse_ctx_t *jctx);
int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem); int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem);
int json_obj_leave_array(jparse_ctx_t *jctx); int json_obj_leave_array(jparse_ctx_t *jctx);
int json_obj_get_object(jparse_ctx_t *jctx, char *name); int json_obj_get_object(jparse_ctx_t *jctx, const char *name);
int json_obj_leave_object(jparse_ctx_t *jctx); int json_obj_leave_object(jparse_ctx_t *jctx);
int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val); int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val);
int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val); int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val);
int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val); int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val);
int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val); int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val);
int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size); int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size);
int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen); int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen);
int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size); int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size);
int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen); int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen);
int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size); int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size);
int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen); int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen);
int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index); int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index);
int json_arr_leave_array(jparse_ctx_t *jctx); int json_arr_leave_array(jparse_ctx_t *jctx);

View File

@ -447,7 +447,7 @@ int mu_srp_get_session_key(mu_srp_handle_t *hd, char *bytes_A, int len_A, char *
return -1; return -1;
} }
int mu_srp_exchange_proofs(mu_srp_handle_t *hd, char *username, char *bytes_user_proof, char *bytes_host_proof) int mu_srp_exchange_proofs(mu_srp_handle_t *hd, const char *username, char *bytes_user_proof, char *bytes_host_proof)
{ {
/* First calculate M */ /* First calculate M */
unsigned char hash_n[SHA512HashSize]; unsigned char hash_n[SHA512HashSize];

View File

@ -84,7 +84,7 @@ int mu_srp_get_session_key(mu_srp_handle_t *hd, char *bytes_A, int len_A, char *
* bytes_user_proof is parameter in * bytes_user_proof is parameter in
* bytes_host_proof is parameter out (should be SHA512_DIGEST_LENGTH) bytes in size * bytes_host_proof is parameter out (should be SHA512_DIGEST_LENGTH) bytes in size
*/ */
int mu_srp_exchange_proofs(mu_srp_handle_t *hd, char *username, char *bytes_user_proof, char *bytes_host_proof); int mu_srp_exchange_proofs(mu_srp_handle_t *hd, const char *username, char *bytes_user_proof, char *bytes_host_proof);

View File

@ -25,7 +25,7 @@
#if __has_include("esp_idf_version.h") #if __has_include("esp_idf_version.h")
#include "esp_idf_version.h" #include "esp_idf_version.h"
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
#warning("IDF is 4 or later") // #warning("IDF is 4 or later")
#include "soc/hwcrypto_periph.h" #include "soc/hwcrypto_periph.h"
#endif #endif
#endif #endif

View File

@ -79,4 +79,4 @@ void esp_mpi_release_hardware(void);
int esp_mpi_mul_mpi_mod(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M); int esp_mpi_mul_mpi_mod(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M);
//#endif // CONFIG_MBEDTLS_HARDWARE_MPI //#endif // CONFIG_MBEDTLS_HARDWARE_MPI
#endif CONFIG_IDF_TARGET_ESP32 #endif //CONFIG_IDF_TARGET_ESP32

View File

@ -23,7 +23,7 @@
#if __has_include("esp_idf_version.h") #if __has_include("esp_idf_version.h")
#include "esp_idf_version.h" #include "esp_idf_version.h"
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
#warning("IDF is 4 or later") // #warning("IDF is 4 or later")
#include "soc/hwcrypto_periph.h" #include "soc/hwcrypto_periph.h"
#endif #endif
#endif #endif

View File

@ -781,11 +781,11 @@ void printstr(const char *str, int len)
*/ */
void printxstr(const char *str, int len) void printxstr(const char *str, int len)
{ {
char *sep = ""; char sep[2] = {0};
for ( ; len-- > 0; str++) { for ( ; len-- > 0; str++) {
printf("%s%c%c", sep, hexdigits[(*str >> 4) & 0xF], printf("%s%c%c", sep, hexdigits[(*str >> 4) & 0xF],
hexdigits[*str & 0xF]); hexdigits[*str & 0xF]);
sep = " "; sep[0] = ' ';
} }
} }
@ -866,7 +866,7 @@ void printResult(uint8_t *Message_Digest, int hashsize,
putchar('\n'); putchar('\n');
} else if (printResults == PRINTBASE64) { } else if (printResults == PRINTBASE64) {
unsigned char b; unsigned char b;
char *sm = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" const char *sm = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
"0123456789+/"; "0123456789+/";
for (i = 0; i < hashsize; i += 3) { for (i = 0; i < hashsize; i += 3) {
putchar(sm[Message_Digest[i] >> 2]); putchar(sm[Message_Digest[i] >> 2]);

View File

@ -1,4 +0,0 @@
Import("env")
# General options that are passed to the C compiler (C only; not C++).
env.Append(CFLAGS=["-Wno-discarded-qualifiers"])