Infineon Logo AIROC BTSDK v4.4 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wiced_bt_mesh_model_utils.h File Reference

Generic OnOff Model definitions. More...

Macros

#define TRACE_NONE   0
 
#define TRACE_ERROR   1
 
#define TRACE_CRITICAL   1
 
#define TRACE_WARNING   2
 
#define TRACE_INFO   3
 
#define TRACE_DEBUG   4
 
#define MMDL_TRACE0(l, s)
 
#define MMDL_TRACE1(l, s, p1)
 
#define MMDL_TRACE2(l, s, p1, p2)
 
#define MMDL_TRACE3(l, s, p1, p2, p3)
 
#define MMDL_TRACE4(l, s, p1, p2, p3, p4)
 
#define MMDL_TRACEN(l, p, len)
 
#define SETBUF_LE8(val8, buf_ptr, len_var)   buf_ptr[len_var++] = val8 & 0xFF;
 
#define SETBUF_LE16(val16, buf_ptr, len_var)   buf_ptr[len_var++] = (uint16_t)val16 & 0x00FF; buf_ptr[len_var++] = (((uint16_t)val16 & 0xFF00) >> 8);
 
#define SETBUF_LE32(val32, buf_ptr, len_var)   buf_ptr[len_var++] = (uint32_t)val32 & 0x00FF; buf_ptr[len_var++] = (((uint32_t)val32 & 0xFF00) >> 8);buf_ptr[len_var++] = (((uint32_t)val32 & 0xFF0000) >> 16);buf_ptr[len_var++] = (((uint32_t)val32 & 0xFF000000) >> 24);
 
#define SETBUF_LE8_ptr(val8, buf_ptr)   *buf_ptr++ = val8 & 0xFF;
 
#define SETBUF_LE16_ptr(val16, buf_ptr)   *buf_ptr++ = val16 & 0x00FF; *buf_ptr++ = ((val16 & 0xFF00) >> 8);
 
#define SETBUF_LE24_ptr(val24, buf_ptr)   *buf_ptr++ = val24 & 0x00FF; *buf_ptr++ = ((val24 & 0xFF00) >> 8); *buf_ptr++ = ((val24 & 0xFF0000) >> 16);
 
#define SETBUF_LE32_ptr(val32, buf_ptr)   *buf_ptr++ = val32 & 0x00FF; *buf_ptr++ = ((val32 & 0xFF00) >> 8); *buf_ptr++ = ((val32 & 0xFF0000) >> 16); *buf_ptr++ = ((val32 & 0xFF000000) >> 24);
 
#define GETBUF_LE16(buf_ptr, start)   (buf_ptr[start] | (buf_ptr[start+1] << 8))
 
#define GETBUF_LE24(buf_ptr, start)   (buf_ptr[start] | (buf_ptr[start+1] << 8) | (buf_ptr[start+2] << 16))
 
#define GETBUF_LE32(buf_ptr, start)   (buf_ptr[start] | (buf_ptr[start+1] << 8) | (buf_ptr[start+2] << 16) | (buf_ptr[start+3] << 24))
 
#define GENDEFTRANSTIME_STEP_RESOLUTION_MASK   0xC0
 
#define GENDEFTRANSTIME_STEP_RESOLUTION_100MS   0x00
 
#define GENDEFTRANSTIME_STEP_RESOLUTION_1S   0x40
 
#define GENDEFTRANSTIME_STEP_RESOLUTION_10S   0x80
 
#define GENDEFTRANSTIME_STEP_RESOLUTION_10M   0xC0
 
#define GENDEFTRANSTIME_STEPS_MASK   0x3F
 
#define GENDEFTRANSTIME_STEPS_IMMEDIATE   0x00
 
#define GENDEFTRANSTIME_STEPS_MAX   0x3E
 
#define GENDEFTRANSTIME_STEPS_UNKNOWN   0x3F
 
#define GET_OPCODE_LEN(opcode)   (opcode <= 0x7E ? 1 : (opcode >=0x8000 && opcode <= 0xBFFF) ? 2 : (opcode>=0xC00000) ? 3 : 0xFF)
 
#define MESH_UTILS_COLOR_CONTROLLER_HSL   0
 
#define MESH_UTILS_COLOR_CONTROLLER_CTL   1
 
#define MESH_UTILS_COLOR_CONTROLLER_XYL   2
 
#define TIMER_PARAM_TYPE   WICED_TIMER_PARAM_TYPE
 

Typedefs

typedef wiced_bool_t(* wiced_bt_mesh_model_handle_cb_t )(uint8_t element_idx, uint16_t src_id, uint16_t app_key_idx, uint8_t ttl, uint16_t opcode, const uint8_t *params, uint16_t params_len)
 
struct {
   uint16_t   model_id
 
   wiced_bt_mesh_model_handle_cb_t   model_handle
 
wiced_mesh_model_callback_list_item_t
 
struct {
   uint8_t   max_handles
 
   uint8_t   registered_handles_cnt
 
   wiced_mesh_model_callback_list_item_t   cb_list [WICED_BT_MESH_MODELS_MAX_UNIQUE_MODELS_ON_NODE]
 
wiced_mesh_model_handler_list_t
 
struct {
   uint8_t   year
 
   uint8_t   month
 
   uint8_t   day
 
   uint8_t   hour
 
   uint8_t   minute
 
   uint8_t   second
 
wiced_bt_mesh_time_t
 
typedef void( wiced_bt_mesh_transition_callback_t )(uint32_t *p_present, void *ref_data, uint32_t remaining_time)
 Callback from the Transition procedure that the values have been updated Parameters: p_present Array of present values. More...
 

Functions

void mesh_dump_hex (uint8_t *p, uint32_t len)
 
uint32_t get_transtime_in_ms (uint8_t trans_time)
 Converts the given encoded transition time value in to the units of SMART_MESH_APP_FINE_TIMEOUT_IN_MS. More...
 
uint64_t get_app_finetimer_ticks (void)
 Returns the number of fine timer ticks from the power-up. More...
 
uint8_t * mesh_opcode_to_stream (uint8_t *p, uint32_t op)
 Converts the given opcode to the corresponding byte stream Note: It does not check the validity of the opcode. More...
 
uint8_t mesh_time_ms_to_transtime (uint32_t time_ms)
 Converts the given transition time in milliseconds to correctly encoded value as per the mesh spec Parameters: time_ms : Transition time in milliseconds. More...
 
void mesh_model_transition_server_init (uint8_t element_idx, wiced_bool_t is_provisioned)
 Initialize mesh transition server Parameters: element_idx Index of the element of the device p_ref_data Reference data to be returned in the callback.
 
void mesh_server_transition_start (uint8_t element_idx, uint32_t transition_time, uint32_t delay, uint32_t *target, uint32_t *present, uint32_t num_values, wiced_bt_mesh_transition_callback_t *p_callback, void *p_ref_data)
 Start the Transition procedure Parameters: element_idx Index of the element of the device transition_time Transition time in milliseconds delay Delay before starting the transition target Array of the target values to transition to present Array of the present values to transition from num_values Number of elements in the Target and Present arrays p_callback Callback to be executed on the transition process and when transition is completed p_ref_data Reference data to be returned in the callback.
 
void mesh_server_transition_stop (uint8_t element_idx)
 Stop the Transition procedure. More...
 
void mesh_server_transition_abort (uint8_t element_idx)
 Start the Transition procedure Parameters: element_idx Index of the element of the device.
 
uint32_t mesh_default_transition_time_get (uint8_t element_idx)
 Return the value of the default transition time set for the element in milliseconds. More...
 
wiced_bool_t mesh_sig_model_handle_register (wiced_bt_mesh_model_handle_cb_t model_handle, uint16_t model_id)
 Registers the given SIG model handler into the list of handlers to be called during opcode processing.
 
void wiced_bt_mesh_models_utils_ack_received (wiced_bt_mesh_event_t **p_out_event_queue, uint16_t dst)
 This function can be called to cancel sending of the current message. More...
 
wiced_bool_t wiced_bt_mesh_models_utils_opcode_queued (wiced_bt_mesh_event_t **p_out_event_queue, uint16_t dst, uint16_t *opcode_list, int num_opcodes)
 This function can be called to check if message with one of the opcodes is in the queue for transmission.
 
void wiced_bt_mesh_models_utils_cancel_send (wiced_bt_mesh_event_t **p_out_event_queue, uint16_t dst)
 This request can be used to cancel outstanding writes to a specific destination from the specific queue. More...
 
wiced_result_t wiced_bt_mesh_models_utils_send (wiced_bt_mesh_event_t *p_event, wiced_bt_mesh_event_t **p_out_event, wiced_bool_t is_command, uint16_t opcode, uint8_t *p_buffer, uint16_t len, wiced_bt_mesh_core_send_complete_callback_t complete_callback)
 This function can be called send message through the core. More...
 
wiced_bool_t wiced_bt_mesh_models_utils_update_reply_timeout (wiced_bt_mesh_event_t *p_event)
 This function can be called to extend reply timeout, for example, when a friend has replied on behalf of an LPN. More...
 
wiced_bool_t wiced_bt_mesh_models_utils_send_complete (wiced_bt_mesh_event_t **p_out_event_queue, uint16_t dst)
 The access layer has completed sending of the packet. More...
 
void wiced_bt_mesh_models_utils_cancel_all (wiced_bt_mesh_event_t **p_out_event_queue)
 Cancel all send requests.
 
uint32_t utl_sqrt (uint32_t input)
 
uint8_t mesh_power_onoff_server_onpowerup_get (uint8_t element_idx)
 Return the value of the OnPowerUp state. More...
 
uint16_t mesh_light_lightness_actual_get (uint8_t element_idx)
 
void mesh_light_lightness_actual_set (uint8_t element_idx, uint16_t level, uint32_t remaining_time)
 
uint16_t mesh_light_lightness_linear_get (uint8_t element_idx)
 
void mesh_light_lightness_linear_set (uint8_t element_idx, uint16_t value, uint32_t remaining_time)
 
uint16_t mesh_light_lightness_server_last_get (uint8_t element_idx)
 
void mesh_light_lightness_server_last_set (uint8_t element_idx, uint16_t value)
 
uint16_t mesh_light_lightness_server_linear_last_get (uint8_t element_idx)
 
void mesh_light_lightness_server_linear_last_set (uint8_t element_idx, uint16_t value)
 
void mesh_light_lightness_server_lc_transition_start (uint8_t element_idx, uint16_t actual_target, uint16_t linear_target, uint32_t lux_level_current, uint32_t lux_level_target, uint32_t transition_time, uint32_t delay)
 
uint16_t mesh_light_lightness_server_default_get (uint8_t element_idx)
 
uint16_t mesh_light_lightness_actual_last_get (uint8_t element_idx)
 
uint16_t mesh_light_lightness_linear_last_get (uint8_t element_idx)
 
void mesh_light_lightness_server_default_set (uint8_t element_idx, uint16_t default_value)
 
void mesh_light_lightness_set (uint8_t element_idx, wiced_bool_t store, uint16_t linear, uint16_t actual, uint32_t remaining_time)
 
void light_lightness_actual_set (uint8_t element_idx, uint16_t value)
 
void light_lightness_linear_set (uint8_t element_idx, uint16_t value)
 
void mesh_power_onoff_server_target_onoff_set (uint8_t element_idx, uint8_t onoff)
 
uint8_t mesh_power_onoff_server_target_onoff_get (uint8_t element_idx)
 
void mesh_power_onoff_server_present_onoff_set (uint8_t element_idx, uint8_t onoff)
 
uint8_t mesh_power_onoff_server_get_onoff (uint8_t element_idx)
 
void mesh_power_onoff_server_set_onoff (uint8_t element_idx, uint8_t onoff, uint32_t remaining_time)
 
uint8_t mesh_onoff_server_get_onoff (uint8_t element_idx)
 
void mesh_onoff_server_target_onoff_set (uint8_t element_idx, uint8_t onoff)
 
uint8_t mesh_onoff_server_target_onoff_get (uint8_t element_idx)
 
void mesh_onoff_server_present_onoff_set (uint8_t element_idx, uint8_t onoff)
 
void mesh_onoff_server_onoff_set (uint8_t element_idx, uint8_t onoff, uint32_t remaining_time)
 
void mesh_onoff_execute_set_onoff (wiced_bt_mesh_event_t *p_event, wiced_bt_mesh_onoff_set_data_t *p_onoff_set)
 
void mesh_scene_server_execute_recall (wiced_bt_mesh_event_t *p_event, uint16_t scene_number, uint32_t transition_time, uint32_t delay)
 
void mesh_level_server_level_set (uint8_t element_idx, int16_t level, uint32_t remaining_time)
 
int16_t mesh_level_server_level_get (uint8_t element_idx)
 
wiced_bool_t mesh_time_server_get (wiced_bt_mesh_time_t *p_current_time)
 
void mesh_scheduler_on_time_changed (void)
 
uint32_t mesh_read_node_info (int id, uint8_t *data, uint16_t len, wiced_result_t *p_result)
 
uint32_t mesh_write_node_info (int id, const uint8_t *data, uint16_t len, wiced_result_t *p_result)
 
uint8_t uint32_to_log (uint32_t period)
 
uint32_t uint32_from_log (uint8_t log)
 
uint8_t uint32_to_log_heartbeat (uint32_t period)
 
uint32_t uint32_from_log_heartbeat (uint8_t log)
 
void mesh_model_set_color_light_controller (uint8_t element_idx, uint8_t controller)
 

Variables

wiced_bt_mesh_core_config_tmesh_core_config
 

Detailed Description

Generic OnOff Model definitions.

Typedef Documentation

typedef void( wiced_bt_mesh_transition_callback_t)(uint32_t *p_present, void *ref_data, uint32_t remaining_time)

Callback from the Transition procedure that the values have been updated Parameters: p_present Array of present values.

Sizeof the array is the same as when transaction was started ref_data Pinter as passed to the transaction start remaining_time Remaining time in the transition. If 0, the transition is completed and this is the last time the callback is executed.

Function Documentation

uint64_t get_app_finetimer_ticks ( void  )

Returns the number of fine timer ticks from the power-up.

Parameters: <none>

Return : Number of app ine timer ticks

uint32_t get_transtime_in_ms ( uint8_t  trans_time)

Converts the given encoded transition time value in to the units of SMART_MESH_APP_FINE_TIMEOUT_IN_MS.

Parameters: trans_time :Encoded transition time value as defined in model spec Return :value in number of fine timer ticks. Returns zero for invalid value

uint32_t mesh_default_transition_time_get ( uint8_t  element_idx)

Return the value of the default transition time set for the element in milliseconds.

Parameters
element_idxIndex of the element on the device
Returns
default transition time value.
uint8_t* mesh_opcode_to_stream ( uint8_t *  p,
uint32_t  op 
)

Converts the given opcode to the corresponding byte stream Note: It does not check the validity of the opcode.

Parameters: *p: Pointer to the stream buffer op: 1/2/3 byte opcode Return: pointer to the next empty location in the stream buffer after adding opcode bytes

uint8_t mesh_power_onoff_server_onpowerup_get ( uint8_t  element_idx)

Return the value of the OnPowerUp state.

Parameters
element_idxIndex of the element on the device
onpowerupPointer to the variable to be filled with current on power up state.
Returns
WICED_TRUE if success.
void mesh_server_transition_stop ( uint8_t  element_idx)

Stop the Transition procedure.

The transition server will callback to the parent to indicated current state. Parameters: element_idx Index of the element of the device

uint8_t mesh_time_ms_to_transtime ( uint32_t  time_ms)

Converts the given transition time in milliseconds to correctly encoded value as per the mesh spec Parameters: time_ms : Transition time in milliseconds.

Note, final transition time accuracy will depend upon the length of the time.

Return : Encoded transition time

void wiced_bt_mesh_models_utils_ack_received ( wiced_bt_mesh_event_t **  p_out_event_queue,
uint16_t  dst 
)

This function can be called to cancel sending of the current message.

If request is in the queue, the callback is executed.

void wiced_bt_mesh_models_utils_cancel_send ( wiced_bt_mesh_event_t **  p_out_event_queue,
uint16_t  dst 
)

This request can be used to cancel outstanding writes to a specific destination from the specific queue.

No callbacks will be executed.

wiced_result_t wiced_bt_mesh_models_utils_send ( wiced_bt_mesh_event_t p_event,
wiced_bt_mesh_event_t **  p_out_event,
wiced_bool_t  is_command,
uint16_t  opcode,
uint8_t *  p_buffer,
uint16_t  len,
wiced_bt_mesh_core_send_complete_callback_t  complete_callback 
)

This function can be called send message through the core.

The function keeps track of the output event and executes provided callback if message is not canceled.

Parameters
p_eventFully prepared wiced_bt_mesh_event_t structure with information on where and how event should be sent
p_out_eventPointer to the queue of the events sent by the current modules. The pointer shall not be null if there is callback
is_commandIf true the packet a command originated by the current device. Based on this parameter core selects different value for random delay before the packet is scheduled for transmission.
bufferPointer to the data to be sent out.
lenSize of the data to be sent out. The maximum length is about 377 bytes (depends on the size of the opcode).
complete_callbackThe pointer to the callback to be executed when the packet is queued for the transmission. If parameter is null, the core assumes the application releases the ownership of the p_event. If not null, application shall release the p_event, typically in the contents of the callback.
Returns
WICED_TRUE if success.
wiced_bool_t wiced_bt_mesh_models_utils_send_complete ( wiced_bt_mesh_event_t **  p_out_event_queue,
uint16_t  dst 
)

The access layer has completed sending of the packet.

Returns TRUE if event was dequeued. FALSE if timer is still running and another complete will follow when timer expires.

wiced_bool_t wiced_bt_mesh_models_utils_update_reply_timeout ( wiced_bt_mesh_event_t p_event)

This function can be called to extend reply timeout, for example, when a friend has replied on behalf of an LPN.

Parameters
p_eventevent that has been used in initial wiced_bt_mesh_models_utils_send function
Returns
WICED_TRUE if success.