context.c File Reference
`#include "liblightify-private.h"`
`#include "context.h"`
`#include "log.h"`
`#include "node.h"`
`#include "groups.h"`
`#include "socket.h"`
`#include <errno.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
Include dependency graph for context.c:

Go to the source code of this file.

## Macros

#define | ENODATA EIO

## Enumerations

enum | msg_header { HEADER_LEN_LSB, HEADER_LEN_MSB, HEADER_FLAGS, HEADER_CMD, HEADER_REQ_ID_B0, HEADER_REQ_ID_B1, HEADER_REQ_ID_B2, HEADER_REQ_ID_B3, HEADER_PAYLOAD_START }
enum | msg_0x13_query { QUERY_0x13_REQTYPE = HEADER_PAYLOAD_START, QUERY_0x13_SIZE }
enum | msg_0x13_answer { ANSWER_0x13_UNKNOWN1 = HEADER_PAYLOAD_START, ANSWER_0x13_NODESCNT_LSB, ANSWER_0x13_NODESCNT_MSB, ANSWER_0x13_SIZE }

enum

msg_0x13_answer_node {
ANSWER_0x13_NODE_ADR16_LSB, ANSWER_0x13_NODE_ADR16_MSB, ANSWER_0x13_NODE_ADR64_B0, ANSWER_0x13_NODE_ADR64_B1,
ANSWER_0x13_NODE_ADR64_B2, ANSWER_0x13_NODE_ADR64_B3, ANSWER_0x13_NODE_ADR64_B4, ANSWER_0x13_NODE_ADR64_B5,
ANSWER_0x13_NODE_ADR64_B6, ANSWER_0x13_NODE_ADR64_B7, ANSWER_0x13_NODE_NODETYPE, ANSWER_0x13_UNKNOWN2,
ANSWER_0x13_UNKNOWN3, ANSWER_0x13_UNKNOWN4, ANSWER_0x13_UNKNOWN5, ANSWER_0x13_NODE_ONLINE_STATE,
ANSWER_0x13_NODE_GRP_MEMBER_LSB, ANSWER_0x13_NODE_GRP_MEMBER_MSB, ANSWER_0x13_NODE_ONOFF_STATE, ANSWER_0x13_NODE_DIM_LEVEL,
ANSWER_0x13_NODE_CCT_LSB, ANSWER_0x13_NODE_CCT_MSB, ANSWER_0x13_NODE_R, ANSWER_0x13_NODE_G,
ANSWER_0x13_NODE_B, ANSWER_0x13_NODE_W, ANSWER_0x13_NODE_NAME_START, ANSWER_0x13_UNKNOWN6 = 42,
ANSWER_0x13_UNKNOWN7, ANSWER_0x13_UNKNOWN8, ANSWER_0x13_UNKNOWN9, ANSWER_0x13_UNKNOWN10,
ANSWER_0x13_UNKNOWN11, ANSWER_0x13_UNKNOWN12, ANSWER_0x13_UNKNOWN13, ANSWER_0x13_NODE_LENGTH = 50
}

enum | msg_0x31_query { QUERY_0x31_NODEADR64_B0 = HEADER_PAYLOAD_START, QUERY_0x31_NODEADR64_B1, QUERY_0x31_NODEADR64_B2, QUERY_0x31_NODEADR64_B3, QUERY_0x31_NODEADR64_B4, QUERY_0x31_NODEADR64_B5, QUERY_0x31_NODEADR64_B6, QUERY_0x31_NODEADR64_B7, QUERY_0x31_LEVEL, QUERY_0x31_FADETIME_LSB, QUERY_0x31_FADETIME_MSB, QUERY_0x31_SIZE }
enum | msg_0x31_answer { ANSWER_0x31_STATE = HEADER_PAYLOAD_START, ANSWER_0x31_UNKNOWN1, ANSWER_0x31_UNKNOWN2, ANSWER_0x31_NODEADR64_B0, ANSWER_0x31_NODEADR64_B1, ANSWER_0x31_NODEADR64_B2, ANSWER_0x31_NODEADR64_B3, ANSWER_0x31_NODEADR64_B4, ANSWER_0x31_NODEADR64_B5, ANSWER_0x31_NODEADR64_B6, ANSWER_0x31_NODEADR64_B7, ANSWER_0x31_UNKNOWN3, ANSWER_0x31_SIZE }
enum | msg_0x32_query { QUERY_0x32_NODEADR64_B0 = HEADER_PAYLOAD_START, QUERY_0x32_NODEADR64_B1, QUERY_0x32_NODEADR64_B2, QUERY_0x32_NODEADR64_B3, QUERY_0x32_NODEADR64_B4, QUERY_0x32_NODEADR64_B5, QUERY_0x32_NODEADR64_B6, QUERY_0x32_NODEADR64_B7, QUERY_0x32_ONOFF, QUERY_0x32_SIZE }
enum | msg_0x32_answer { ANSWER_0x32_STATE = HEADER_PAYLOAD_START, ANSWER_0x32_RESERVED_LSB, ANSWER_0x32_RESERVED_MSB, ANSWER_0x32_NODEADR64_B0, ANSWER_0x32_NODEADR64_B1, ANSWER_0x32_NODEADR64_B2, ANSWER_0x32_NODEADR64_B3, ANSWER_0x32_NODEADR64_B4, ANSWER_0x32_NODEADR64_B5, ANSWER_0x32_NODEADR64_B6, ANSWER_0x32_NODEADR64_B7, ANSWER_0x32_UNKNOWN1, ANSWER_0x32_SIZE }
enum | msg_0x33_query { QUERY_0x33_NODEADR64_B0 = HEADER_PAYLOAD_START, QUERY_0x33_NODEADR64_B1, QUERY_0x33_NODEADR64_B2, QUERY_0x33_NODEADR64_B3, QUERY_0x33_NODEADR64_B4, QUERY_0x33_NODEADR64_B5, QUERY_0x33_NODEADR64_B6, QUERY_0x33_NODEADR64_B7, QUERY_0x33_CCT_LSB, QUERY_0x33_CCT_MSB, QUERY_0x33_FADETIME_LSB, QUERY_0x33_FADETIME_MSB, QUERY_0x33_SIZE }
enum | msg_0x33_answer { ANSWER_0x33_STATE = HEADER_PAYLOAD_START, ANSWER_0x33_RESERVED_LSB, ANSWER_0x33_RESERVED_MSB, ANSWER_0x33_NODEADR64_B0, ANSWER_0x33_NODEADR64_B1, ANSWER_0x33_NODEADR64_B2, ANSWER_0x33_NODEADR64_B3, ANSWER_0x33_NODEADR64_B4, ANSWER_0x33_NODEADR64_B5, ANSWER_0x33_NODEADR64_B6, ANSWER_0x33_NODEADR64_B7, ANSWER_0x33_UNKNOWN1, ANSWER_0x33_SIZE }
enum | msg_0x36_query { QUERY_0x36_NODEADR64_B0 = HEADER_PAYLOAD_START, QUERY_0x36_NODEADR64_B1, QUERY_0x36_NODEADR64_B2, QUERY_0x36_NODEADR64_B3, QUERY_0x36_NODEADR64_B4, QUERY_0x36_NODEADR64_B5, QUERY_0x36_NODEADR64_B6, QUERY_0x36_NODEADR64_B7, QUERY_0x36_R, QUERY_0x36_G, QUERY_0x36_B, QUERY_0x36_W, QUERY_0x36_FADETIME_LSB, QUERY_0x36_FADETIME_MSB, QUERY_0x36_SIZE }
enum | msg_0x36_answer { ANSWER_0x36_STATE = HEADER_PAYLOAD_START, ANSWER_0x36_RESERVED_LSB, ANSWER_0x36_RESERVED_MSB, ANSWER_0x36_NODEADR64_B0, ANSWER_0x36_NODEADR64_B1, ANSWER_0x36_NODEADR64_B2, ANSWER_0x36_NODEADR64_B3, ANSWER_0x36_NODEADR64_B4, ANSWER_0x36_NODEADR64_B5, ANSWER_0x36_NODEADR64_B6, ANSWER_0x36_NODEADR64_B7, ANSWER_0x36_UNKNOWN1, ANSWER_0x36_SIZE }
enum | msg_0x68_query { QUERY_0x68_NODEADR64_B0 = HEADER_PAYLOAD_START, QUERY_0x68_NODEADR64_B1, QUERY_0x68_NODEADR64_B2, QUERY_0x68_NODEADR64_B3, QUERY_0x68_NODEADR64_B4, QUERY_0x68_NODEADR64_B5, QUERY_0x68_NODEADR64_B6, QUERY_0x68_NODEADR64_B7, QUERY_0x68_SIZE }

enum

msg_0x68_answer {
ANSWER_0x68_STATE = HEADER_PAYLOAD_START, ANSWER_0x68_NONODES_LSB, ANSWER_0x68_NONODES_MSB, ANSWER_0x68_NODEADR64_B0,
ANSWER_0x68_NODEADR64_B1, ANSWER_0x68_NODEADR64_B2, ANSWER_0x68_NODEADR64_B3, ANSWER_0x68_NODEADR64_B4,
ANSWER_0x68_NODEADR64_B5, ANSWER_0x68_NODEADR64_B6, ANSWER_0x68_NODEADR64_B7, ANSWER_0x68_REQUEST_STATUS,
ANSWER_0x68_ONLINESTATE, ANSWER_0x68_ONOFF, ANSWER_0x68_DIM_LEVEL, ANSWER_0x68_CCT_LSB,
ANSWER_0x68_CCT_MSB, ANSWER_0x68_R, ANSWER_0x68_G, ANSWER_0x68_B,
ANSWER_0x68_W, ANSWER_0x68_UNKNOWN2, ANSWER_0x68_UNKNOWN3, ANSWER_0x68_UNKNOWN4,
ANSWER_0x68_SIZE
}

enum | msg_0x1e_query { QUERY_0x1e = HEADER_PAYLOAD_START, QUERY_0x1e_SIZE }
enum | msg_0x1e_answer { ANSWER_0x1e_STATE = HEADER_PAYLOAD_START, ANSWER_0x1e_NUMGROUPS, ANSWER_0x1e_HDR_UNKNOWN_ZERO, ANSWER_0x1e_SIZE }
enum | msg_0x1e_answerpergroup { ANSWER_0x1e_GRP_ID, ANSWER_0x1e_GRP_UNKNOWN_ZERO, ANSWER_0x1e_GRP_NAME, ANSWER_0x1e_GRP_LENGHT = ANSWER_0x1e_GRP_NAME+16 }

## Functions

LIGHTIFY_EXPORT struct lightify_node * | lightify_node_get_from_mac (struct lightify_ctx *ctx, uint64_t mac)
LIGHTIFY_EXPORT struct lightify_node * | lightify_node_get_next (struct lightify_ctx *ctx, struct lightify_node *node)
LIGHTIFY_EXPORT struct lightify_node * | lightify_node_get_previous (struct lightify_ctx *ctx, struct lightify_node *node)
LIGHTIFY_EXPORT void * | lightify_get_userdata (struct lightify_ctx *ctx)
LIGHTIFY_EXPORT int | lightify_set_userdata (struct lightify_ctx *ctx, void *userdata)
LIGHTIFY_EXPORT int | lightify_set_socket_fn (struct lightify_ctx *ctx, write_to_socket_fn fpw, read_from_socket_fn fpr)
LIGHTIFY_EXPORT int | lightify_new (struct lightify_ctx **ctx, void *reserved)
LIGHTIFY_EXPORT int | lightify_free (struct lightify_ctx *ctx)
LIGHTIFY_EXPORT int | lightify_node_request_scan (struct lightify_ctx *ctx)
LIGHTIFY_EXPORT int | lightify_node_request_onoff (struct lightify_ctx *ctx, struct lightify_node *node, int onoff)
LIGHTIFY_EXPORT int | lightify_node_request_cct (struct lightify_ctx *ctx, struct lightify_node *node, unsigned int cct, unsigned int fadetime)
LIGHTIFY_EXPORT int | lightify_node_request_rgbw (struct lightify_ctx *ctx, struct lightify_node *node, unsigned int r, unsigned int g, unsigned int b, unsigned int w, unsigned int fadetime)
LIGHTIFY_EXPORT int | lightify_node_request_brightness (struct lightify_ctx *ctx, struct lightify_node *node, unsigned int level, unsigned int fadetime)
LIGHTIFY_EXPORT int | lightify_node_request_update (struct lightify_ctx *ctx, struct lightify_node *node)
LIGHTIFY_EXPORT int | lightify_group_request_scan (struct lightify_ctx *ctx)
LIGHTIFY_EXPORT int | lightify_group_request_onoff (struct lightify_ctx *ctx, struct lightify_group *group, int onoff)
LIGHTIFY_EXPORT int | lightify_group_request_cct (struct lightify_ctx *ctx, struct lightify_group *group, unsigned int cct, unsigned int fadetime)
LIGHTIFY_EXPORT int | lightify_group_request_rgbw (struct lightify_ctx *ctx, struct lightify_group *group, unsigned int r, unsigned int g, unsigned int b, unsigned int w, unsigned int fadetime)
LIGHTIFY_EXPORT int | lightify_group_request_brightness (struct lightify_ctx *ctx, struct lightify_group *group, unsigned int level, unsigned int fadetime)

## Macro Definition Documentation

#define ENODATA EIO

Definition at line 44 of file context.c.

## Enumeration Type Documentation

enum msg_0x13_answer

Enumerator
ANSWER_0x13_UNKNOWN1 |
ANSWER_0x13_NODESCNT_LSB |
ANSWER_0x13_NODESCNT_MSB |
ANSWER_0x13_SIZE |

Definition at line 65 of file context.c.

enum msg_0x13_answer_node

Enumerator
ANSWER_0x13_NODE_ADR16_LSB |
ANSWER_0x13_NODE_ADR16_MSB |
ANSWER_0x13_NODE_ADR64_B0 |
ANSWER_0x13_NODE_ADR64_B1 |
ANSWER_0x13_NODE_ADR64_B2 |
ANSWER_0x13_NODE_ADR64_B3 |
ANSWER_0x13_NODE_ADR64_B4 |
ANSWER_0x13_NODE_ADR64_B5 |
ANSWER_0x13_NODE_ADR64_B6 |
ANSWER_0x13_NODE_ADR64_B7 |
ANSWER_0x13_NODE_NODETYPE |
ANSWER_0x13_UNKNOWN2 |
ANSWER_0x13_UNKNOWN3 |
ANSWER_0x13_UNKNOWN4 |
ANSWER_0x13_UNKNOWN5 |
ANSWER_0x13_NODE_ONLINE_STATE |
ANSWER_0x13_NODE_GRP_MEMBER_LSB |
ANSWER_0x13_NODE_GRP_MEMBER_MSB |
ANSWER_0x13_NODE_ONOFF_STATE |
ANSWER_0x13_NODE_DIM_LEVEL |
ANSWER_0x13_NODE_CCT_LSB |
ANSWER_0x13_NODE_CCT_MSB |
ANSWER_0x13_NODE_R |
ANSWER_0x13_NODE_G |
ANSWER_0x13_NODE_B |
ANSWER_0x13_NODE_W |
ANSWER_0x13_NODE_NAME_START |
ANSWER_0x13_UNKNOWN6 |
ANSWER_0x13_UNKNOWN7 |
ANSWER_0x13_UNKNOWN8 |
ANSWER_0x13_UNKNOWN9 |
ANSWER_0x13_UNKNOWN10 |
ANSWER_0x13_UNKNOWN11 |
ANSWER_0x13_UNKNOWN12 |
ANSWER_0x13_UNKNOWN13 |
ANSWER_0x13_NODE_LENGTH |

Definition at line 72 of file context.c.

enum msg_0x13_query

Enumerator
QUERY_0x13_REQTYPE |
QUERY_0x13_SIZE |

Definition at line 60 of file context.c.

enum msg_0x1e_answer

Enumerator
ANSWER_0x1e_STATE |
ANSWER_0x1e_NUMGROUPS |
ANSWER_0x1e_HDR_UNKNOWN_ZERO |
ANSWER_0x1e_SIZE |

Definition at line 283 of file context.c.

enum msg_0x1e_answerpergroup

Enumerator
ANSWER_0x1e_GRP_ID |
ANSWER_0x1e_GRP_UNKNOWN_ZERO |
ANSWER_0x1e_GRP_NAME |
ANSWER_0x1e_GRP_LENGHT |

Definition at line 290 of file context.c.

enum msg_0x1e_query

Enumerator
QUERY_0x1e |
QUERY_0x1e_SIZE |

Definition at line 278 of file context.c.

enum msg_0x31_answer

Enumerator
ANSWER_0x31_STATE |
ANSWER_0x31_UNKNOWN1 |
ANSWER_0x31_UNKNOWN2 |
ANSWER_0x31_NODEADR64_B0 |
ANSWER_0x31_NODEADR64_B1 |
ANSWER_0x31_NODEADR64_B2 |
ANSWER_0x31_NODEADR64_B3 |
ANSWER_0x31_NODEADR64_B4 |
ANSWER_0x31_NODEADR64_B5 |
ANSWER_0x31_NODEADR64_B6 |
ANSWER_0x31_NODEADR64_B7 |
ANSWER_0x31_UNKNOWN3 |
ANSWER_0x31_SIZE |

Definition at line 126 of file context.c.

enum msg_0x31_query

Enumerator
QUERY_0x31_NODEADR64_B0 |
QUERY_0x31_NODEADR64_B1 |
QUERY_0x31_NODEADR64_B2 |
QUERY_0x31_NODEADR64_B3 |
QUERY_0x31_NODEADR64_B4 |
QUERY_0x31_NODEADR64_B5 |
QUERY_0x31_NODEADR64_B6 |
QUERY_0x31_NODEADR64_B7 |
QUERY_0x31_LEVEL |
QUERY_0x31_FADETIME_LSB |
QUERY_0x31_FADETIME_MSB |
QUERY_0x31_SIZE |

Definition at line 111 of file context.c.

enum msg_0x32_answer

Enumerator
ANSWER_0x32_STATE |
ANSWER_0x32_RESERVED_LSB |
ANSWER_0x32_RESERVED_MSB |
ANSWER_0x32_NODEADR64_B0 |
ANSWER_0x32_NODEADR64_B1 |
ANSWER_0x32_NODEADR64_B2 |
ANSWER_0x32_NODEADR64_B3 |
ANSWER_0x32_NODEADR64_B4 |
ANSWER_0x32_NODEADR64_B5 |
ANSWER_0x32_NODEADR64_B6 |
ANSWER_0x32_NODEADR64_B7 |
ANSWER_0x32_UNKNOWN1 |
ANSWER_0x32_SIZE |

Definition at line 155 of file context.c.

enum msg_0x32_query

Enumerator
QUERY_0x32_NODEADR64_B0 |
QUERY_0x32_NODEADR64_B1 |
QUERY_0x32_NODEADR64_B2 |
QUERY_0x32_NODEADR64_B3 |
QUERY_0x32_NODEADR64_B4 |
QUERY_0x32_NODEADR64_B5 |
QUERY_0x32_NODEADR64_B6 |
QUERY_0x32_NODEADR64_B7 |
QUERY_0x32_ONOFF |
QUERY_0x32_SIZE |

Definition at line 142 of file context.c.

enum msg_0x33_answer

Enumerator
ANSWER_0x33_STATE |
ANSWER_0x33_RESERVED_LSB |
ANSWER_0x33_RESERVED_MSB |
ANSWER_0x33_NODEADR64_B0 |
ANSWER_0x33_NODEADR64_B1 |
ANSWER_0x33_NODEADR64_B2 |
ANSWER_0x33_NODEADR64_B3 |
ANSWER_0x33_NODEADR64_B4 |
ANSWER_0x33_NODEADR64_B5 |
ANSWER_0x33_NODEADR64_B6 |
ANSWER_0x33_NODEADR64_B7 |
ANSWER_0x33_UNKNOWN1 |
ANSWER_0x33_SIZE |

Definition at line 187 of file context.c.

enum msg_0x33_query

Enumerator
QUERY_0x33_NODEADR64_B0 |
QUERY_0x33_NODEADR64_B1 |
QUERY_0x33_NODEADR64_B2 |
QUERY_0x33_NODEADR64_B3 |
QUERY_0x33_NODEADR64_B4 |
QUERY_0x33_NODEADR64_B5 |
QUERY_0x33_NODEADR64_B6 |
QUERY_0x33_NODEADR64_B7 |
QUERY_0x33_CCT_LSB |
QUERY_0x33_CCT_MSB |
QUERY_0x33_FADETIME_LSB |
QUERY_0x33_FADETIME_MSB |
QUERY_0x33_SIZE |

Definition at line 171 of file context.c.

enum msg_0x36_answer

Enumerator
ANSWER_0x36_STATE |
ANSWER_0x36_RESERVED_LSB |
ANSWER_0x36_RESERVED_MSB |
ANSWER_0x36_NODEADR64_B0 |
ANSWER_0x36_NODEADR64_B1 |
ANSWER_0x36_NODEADR64_B2 |
ANSWER_0x36_NODEADR64_B3 |
ANSWER_0x36_NODEADR64_B4 |
ANSWER_0x36_NODEADR64_B5 |
ANSWER_0x36_NODEADR64_B6 |
ANSWER_0x36_NODEADR64_B7 |
ANSWER_0x36_UNKNOWN1 |
ANSWER_0x36_SIZE |

Definition at line 222 of file context.c.

enum msg_0x36_query

Enumerator
QUERY_0x36_NODEADR64_B0 |
QUERY_0x36_NODEADR64_B1 |
QUERY_0x36_NODEADR64_B2 |
QUERY_0x36_NODEADR64_B3 |
QUERY_0x36_NODEADR64_B4 |
QUERY_0x36_NODEADR64_B5 |
QUERY_0x36_NODEADR64_B6 |
QUERY_0x36_NODEADR64_B7 |
QUERY_0x36_R |
QUERY_0x36_G |
QUERY_0x36_B |
QUERY_0x36_W |
QUERY_0x36_FADETIME_LSB |
QUERY_0x36_FADETIME_MSB |
QUERY_0x36_SIZE |

Definition at line 204 of file context.c.

enum msg_0x68_answer

Enumerator
ANSWER_0x68_STATE |
ANSWER_0x68_NONODES_LSB |
ANSWER_0x68_NONODES_MSB |
ANSWER_0x68_NODEADR64_B0 |
ANSWER_0x68_NODEADR64_B1 |
ANSWER_0x68_NODEADR64_B2 |
ANSWER_0x68_NODEADR64_B3 |
ANSWER_0x68_NODEADR64_B4 |
ANSWER_0x68_NODEADR64_B5 |
ANSWER_0x68_NODEADR64_B6 |
ANSWER_0x68_NODEADR64_B7 |
ANSWER_0x68_REQUEST_STATUS |
ANSWER_0x68_ONLINESTATE |
ANSWER_0x68_ONOFF |
ANSWER_0x68_DIM_LEVEL |
ANSWER_0x68_CCT_LSB |
ANSWER_0x68_CCT_MSB |
ANSWER_0x68_R |
ANSWER_0x68_G |
ANSWER_0x68_B |
ANSWER_0x68_W |
ANSWER_0x68_UNKNOWN2 |
ANSWER_0x68_UNKNOWN3 |
ANSWER_0x68_UNKNOWN4 |
ANSWER_0x68_SIZE |

Definition at line 250 of file context.c.

enum msg_0x68_query

Enumerator
QUERY_0x68_NODEADR64_B0 |
QUERY_0x68_NODEADR64_B1 |
QUERY_0x68_NODEADR64_B2 |
QUERY_0x68_NODEADR64_B3 |
QUERY_0x68_NODEADR64_B4 |
QUERY_0x68_NODEADR64_B5 |
QUERY_0x68_NODEADR64_B6 |
QUERY_0x68_NODEADR64_B7 |
QUERY_0x68_SIZE |

Definition at line 238 of file context.c.

enum msg_header

Enumerator
HEADER_LEN_LSB |
HEADER_LEN_MSB |
HEADER_FLAGS |
HEADER_CMD |
HEADER_REQ_ID_B0 |
HEADER_REQ_ID_B1 |
HEADER_REQ_ID_B2 |
HEADER_REQ_ID_B3 |
HEADER_PAYLOAD_START |

Definition at line 48 of file context.c.