hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_PendListChangePrio | void | void OS_PendListChangePrio(OS_TCB *p_tcb)
{
OS_PEND_LIST *p_pend_list;
OS_PEND_OBJ *p_obj;
p_obj = p_tcb->PendObjPtr; // Get pointer to pend list
p_pend_list = &p_obj->PendList;
if (p_pend_list->HeadPtr->PendNextPtr != DEF_NULL) { // Only move if multiple entries in the list
OS_PendListRemove(p_tcb); // Remove entry from current position
p_tcb->PendObjPtr = p_obj;
OS_PendListInsertPrio(p_pend_list, // INSERT it back in the list
p_tcb);
}
} | /****************************************************************************************************/
/**
* OS_PendListChangePrio()
*
* @brief This function is called to change the position of a task waiting in a pend list. The
* strategy used is to remove the task from the pend list and add it again using its changed
* priority.
*
* @param p_tcb Pointer to the TCB of the task to move.
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*
* @note (2) It's assumed that the TCB contains the NEW priority in its .Prio field.
*******************************************************************************************************/ | OS_PendListChangePrio()
@brief This function is called to change the position of a task waiting in a pend list. The
strategy used is to remove the task from the pend list and add it again using its changed
priority.
@param p_tcb Pointer to the TCB of the task to move.
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
@note (2) It's assumed that the TCB contains the NEW priority in its .Prio field. | [
"OS_PendListChangePrio",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"change",
"the",
"position",
"of",
"a",
"task",
"waiting",
"in",
"a",
"pend",
"list",
".",
"The",
"strategy",
"used",
"is",
"to",
"remove",
"the",
"task",
"from",
"the",
"pend",
"list",
"and",
"add",
"it",
"again",
"using",
"its",
"changed",
"priority",
".",
"@param",
"p_tcb",
"Pointer",
"to",
"the",
"TCB",
"of",
"the",
"task",
"to",
"move",
".",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
".",
"@note",
"(",
"2",
")",
"It",
"'",
"s",
"assumed",
"that",
"the",
"TCB",
"contains",
"the",
"NEW",
"priority",
"in",
"its",
".",
"Prio",
"field",
"."
] | void OS_PendListChangePrio(OS_TCB *p_tcb)
{
OS_PEND_LIST *p_pend_list;
OS_PEND_OBJ *p_obj;
p_obj = p_tcb->PendObjPtr;
p_pend_list = &p_obj->PendList;
if (p_pend_list->HeadPtr->PendNextPtr != DEF_NULL) {
OS_PendListRemove(p_tcb);
p_tcb->PendObjPtr = p_obj;
OS_PendListInsertPrio(p_pend_list,
p_tcb);
}
} | [
"void",
"OS_PendListChangePrio",
"(",
"OS_TCB",
"*",
"p_tcb",
")",
"{",
"OS_PEND_LIST",
"*",
"p_pend_list",
";",
"OS_PEND_OBJ",
"*",
"p_obj",
";",
"p_obj",
"=",
"p_tcb",
"->",
"PendObjPtr",
";",
"p_pend_list",
"=",
"&",
"p_obj",
"->",
"PendList",
";",
"if",
"(",
"p_pend_list",
"->",
"HeadPtr",
"->",
"PendNextPtr",
"!=",
"DEF_NULL",
")",
"{",
"OS_PendListRemove",
"(",
"p_tcb",
")",
";",
"p_tcb",
"->",
"PendObjPtr",
"=",
"p_obj",
";",
"OS_PendListInsertPrio",
"(",
"p_pend_list",
",",
"p_tcb",
")",
";",
"}",
"}"
] | OS_PendListChangePrio()
@brief This function is called to change the position of a task waiting in a pend list. | [
"OS_PendListChangePrio",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"change",
"the",
"position",
"of",
"a",
"task",
"waiting",
"in",
"a",
"pend",
"list",
"."
] | [
"// Get pointer to pend list",
"// Only move if multiple entries in the list",
"// Remove entry from current position",
"// INSERT it back in the list"
] | [
{
"param": "p_tcb",
"type": "OS_TCB"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_tcb",
"type": "OS_TCB",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_PendListInsertPrio | void | void OS_PendListInsertPrio(OS_PEND_LIST *p_pend_list,
OS_TCB *p_tcb)
{
OS_PRIO prio;
OS_TCB *p_tcb_next;
prio = p_tcb->Prio; // Obtain the priority of the task to insert
if (p_pend_list->HeadPtr == DEF_NULL) { // CASE 0: Insert when there are no entries
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_pend_list->NbrEntries = 1u; // This is the first entry
#endif
p_tcb->PendNextPtr = DEF_NULL; // No other OS_TCBs in the list
p_tcb->PendPrevPtr = DEF_NULL;
p_pend_list->HeadPtr = p_tcb;
p_pend_list->TailPtr = p_tcb;
} else {
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_pend_list->NbrEntries++; // CASE 1: One more OS_TCBs in the list
#endif
p_tcb_next = p_pend_list->HeadPtr;
while (p_tcb_next != DEF_NULL) { // Find the position where to insert
if (prio < p_tcb_next->Prio) {
break; // Found! ... insert BEFORE current
} else {
p_tcb_next = p_tcb_next->PendNextPtr; // Not Found, follow the list
}
}
if (p_tcb_next == DEF_NULL) { // TCB to insert is lowest in priority
p_tcb->PendNextPtr = DEF_NULL; // ... insert at the tail.
p_tcb->PendPrevPtr = p_pend_list->TailPtr;
p_tcb->PendPrevPtr->PendNextPtr = p_tcb;
p_pend_list->TailPtr = p_tcb;
} else {
if (p_tcb_next->PendPrevPtr == DEF_NULL) { // Is new TCB highest priority?
p_tcb->PendNextPtr = p_tcb_next; // Yes, insert as new Head of list
p_tcb->PendPrevPtr = DEF_NULL;
p_tcb_next->PendPrevPtr = p_tcb;
p_pend_list->HeadPtr = p_tcb;
} else { // No, insert in between two entries
p_tcb->PendNextPtr = p_tcb_next;
p_tcb->PendPrevPtr = p_tcb_next->PendPrevPtr;
p_tcb->PendPrevPtr->PendNextPtr = p_tcb;
p_tcb_next->PendPrevPtr = p_tcb;
}
}
}
} | /****************************************************************************************************/
/**
* OS_PendListInsertPrio()
*
* @brief This function is called to place an OS_TCB entry in a linked list based on its priority.
* The highest priority being placed at the head of the list. The TCB is assumed to contain
* the priority of the task in its .Prio field.
* @verbatim
* CASE 0: Insert in an empty list.
*
* OS_PEND_LIST
* +---------------+
* | TailPtr |-> 0
* +---------------+
* | HeadPtr |-> 0
* +---------------+
* | NbrEntries=0 |
* +---------------+
*
* CASE 1: Insert BEFORE or AFTER an OS_TCB
*
* OS_PEND_LIST
* +--------------+ OS_TCB
* | TailPtr |-+--> +--------------+
* +--------------+ | | PendNextPtr |->0
* | HeadPtr |-/ +--------------+
* +--------------+ 0<-| PendPrevPtr |
* | NbrEntries=1 | +--------------+
* +--------------+ | |
* +--------------+
* | |
* +--------------+
*
* OS_PEND_LIST
* +--------------+
* | TailPtr |---------------------------------------------+
* +--------------+ OS_TCB OS_TCB | OS_TCB
* | HeadPtr |----> +--------------+ +--------------+ +-> +--------------+
* +--------------+ | PendNextPtr |<----| PendNextPtr | .... | PendNextPtr |->0
* | NbrEntries=N | +--------------+ +--------------+ +--------------+
* +--------------+ 0<-| PendPrevPtr |<----| PendPrevPtr | .... | PendPrevPtr |
* +--------------+ +--------------+ +--------------+
* | | | | | |
* +--------------+ +--------------+ +--------------+
* | | | | | |
* +--------------+ +--------------+ +--------------+
* @endverbatim
*
* @param p_pend_list Pointer to the OS_PEND_LIST where the OS_TCB entry will be inserted.
*
* @param p_tcb The OS_TCB to insert in the list.
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*******************************************************************************************************/ | OS_PendListInsertPrio()
@brief This function is called to place an OS_TCB entry in a linked list based on its priority.
The highest priority being placed at the head of the list. The TCB is assumed to contain
the priority of the task in its .Prio field.
@verbatim
CASE 0: Insert in an empty list.
CASE 1: Insert BEFORE or AFTER an OS_TCB
@param p_pend_list Pointer to the OS_PEND_LIST where the OS_TCB entry will be inserted.
@param p_tcb The OS_TCB to insert in the list.
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it. | [
"OS_PendListInsertPrio",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"place",
"an",
"OS_TCB",
"entry",
"in",
"a",
"linked",
"list",
"based",
"on",
"its",
"priority",
".",
"The",
"highest",
"priority",
"being",
"placed",
"at",
"the",
"head",
"of",
"the",
"list",
".",
"The",
"TCB",
"is",
"assumed",
"to",
"contain",
"the",
"priority",
"of",
"the",
"task",
"in",
"its",
".",
"Prio",
"field",
".",
"@verbatim",
"CASE",
"0",
":",
"Insert",
"in",
"an",
"empty",
"list",
".",
"CASE",
"1",
":",
"Insert",
"BEFORE",
"or",
"AFTER",
"an",
"OS_TCB",
"@param",
"p_pend_list",
"Pointer",
"to",
"the",
"OS_PEND_LIST",
"where",
"the",
"OS_TCB",
"entry",
"will",
"be",
"inserted",
".",
"@param",
"p_tcb",
"The",
"OS_TCB",
"to",
"insert",
"in",
"the",
"list",
".",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
"."
] | void OS_PendListInsertPrio(OS_PEND_LIST *p_pend_list,
OS_TCB *p_tcb)
{
OS_PRIO prio;
OS_TCB *p_tcb_next;
prio = p_tcb->Prio;
if (p_pend_list->HeadPtr == DEF_NULL) {
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_pend_list->NbrEntries = 1u;
#endif
p_tcb->PendNextPtr = DEF_NULL;
p_tcb->PendPrevPtr = DEF_NULL;
p_pend_list->HeadPtr = p_tcb;
p_pend_list->TailPtr = p_tcb;
} else {
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_pend_list->NbrEntries++;
#endif
p_tcb_next = p_pend_list->HeadPtr;
while (p_tcb_next != DEF_NULL) {
if (prio < p_tcb_next->Prio) {
break;
} else {
p_tcb_next = p_tcb_next->PendNextPtr;
}
}
if (p_tcb_next == DEF_NULL) {
p_tcb->PendNextPtr = DEF_NULL;
p_tcb->PendPrevPtr = p_pend_list->TailPtr;
p_tcb->PendPrevPtr->PendNextPtr = p_tcb;
p_pend_list->TailPtr = p_tcb;
} else {
if (p_tcb_next->PendPrevPtr == DEF_NULL) {
p_tcb->PendNextPtr = p_tcb_next;
p_tcb->PendPrevPtr = DEF_NULL;
p_tcb_next->PendPrevPtr = p_tcb;
p_pend_list->HeadPtr = p_tcb;
} else {
p_tcb->PendNextPtr = p_tcb_next;
p_tcb->PendPrevPtr = p_tcb_next->PendPrevPtr;
p_tcb->PendPrevPtr->PendNextPtr = p_tcb;
p_tcb_next->PendPrevPtr = p_tcb;
}
}
}
} | [
"void",
"OS_PendListInsertPrio",
"(",
"OS_PEND_LIST",
"*",
"p_pend_list",
",",
"OS_TCB",
"*",
"p_tcb",
")",
"{",
"OS_PRIO",
"prio",
";",
"OS_TCB",
"*",
"p_tcb_next",
";",
"prio",
"=",
"p_tcb",
"->",
"Prio",
";",
"if",
"(",
"p_pend_list",
"->",
"HeadPtr",
"==",
"DEF_NULL",
")",
"{",
"#if",
"(",
"OS_CFG_DBG_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_pend_list",
"->",
"NbrEntries",
"=",
"1u",
";",
"#endif",
"p_tcb",
"->",
"PendNextPtr",
"=",
"DEF_NULL",
";",
"p_tcb",
"->",
"PendPrevPtr",
"=",
"DEF_NULL",
";",
"p_pend_list",
"->",
"HeadPtr",
"=",
"p_tcb",
";",
"p_pend_list",
"->",
"TailPtr",
"=",
"p_tcb",
";",
"}",
"else",
"{",
"#if",
"(",
"OS_CFG_DBG_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_pend_list",
"->",
"NbrEntries",
"++",
";",
"#endif",
"p_tcb_next",
"=",
"p_pend_list",
"->",
"HeadPtr",
";",
"while",
"(",
"p_tcb_next",
"!=",
"DEF_NULL",
")",
"{",
"if",
"(",
"prio",
"<",
"p_tcb_next",
"->",
"Prio",
")",
"{",
"break",
";",
"}",
"else",
"{",
"p_tcb_next",
"=",
"p_tcb_next",
"->",
"PendNextPtr",
";",
"}",
"}",
"if",
"(",
"p_tcb_next",
"==",
"DEF_NULL",
")",
"{",
"p_tcb",
"->",
"PendNextPtr",
"=",
"DEF_NULL",
";",
"p_tcb",
"->",
"PendPrevPtr",
"=",
"p_pend_list",
"->",
"TailPtr",
";",
"p_tcb",
"->",
"PendPrevPtr",
"->",
"PendNextPtr",
"=",
"p_tcb",
";",
"p_pend_list",
"->",
"TailPtr",
"=",
"p_tcb",
";",
"}",
"else",
"{",
"if",
"(",
"p_tcb_next",
"->",
"PendPrevPtr",
"==",
"DEF_NULL",
")",
"{",
"p_tcb",
"->",
"PendNextPtr",
"=",
"p_tcb_next",
";",
"p_tcb",
"->",
"PendPrevPtr",
"=",
"DEF_NULL",
";",
"p_tcb_next",
"->",
"PendPrevPtr",
"=",
"p_tcb",
";",
"p_pend_list",
"->",
"HeadPtr",
"=",
"p_tcb",
";",
"}",
"else",
"{",
"p_tcb",
"->",
"PendNextPtr",
"=",
"p_tcb_next",
";",
"p_tcb",
"->",
"PendPrevPtr",
"=",
"p_tcb_next",
"->",
"PendPrevPtr",
";",
"p_tcb",
"->",
"PendPrevPtr",
"->",
"PendNextPtr",
"=",
"p_tcb",
";",
"p_tcb_next",
"->",
"PendPrevPtr",
"=",
"p_tcb",
";",
"}",
"}",
"}",
"}"
] | OS_PendListInsertPrio()
@brief This function is called to place an OS_TCB entry in a linked list based on its priority. | [
"OS_PendListInsertPrio",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"place",
"an",
"OS_TCB",
"entry",
"in",
"a",
"linked",
"list",
"based",
"on",
"its",
"priority",
"."
] | [
"// Obtain the priority of the task to insert",
"// CASE 0: Insert when there are no entries",
"// This is the first entry",
"// No other OS_TCBs in the list",
"// CASE 1: One more OS_TCBs in the list",
"// Find the position where to insert",
"// Found! ... insert BEFORE current",
"// Not Found, follow the list",
"// TCB to insert is lowest in priority",
"// ... insert at the tail.",
"// Is new TCB highest priority?",
"// Yes, insert as new Head of list",
"// No, insert in between two entries"
] | [
{
"param": "p_pend_list",
"type": "OS_PEND_LIST"
},
{
"param": "p_tcb",
"type": "OS_TCB"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_pend_list",
"type": "OS_PEND_LIST",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "p_tcb",
"type": "OS_TCB",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_RdyListInit | void | void OS_RdyListInit(void)
{
CPU_INT32U i;
OS_RDY_LIST *p_rdy_list;
for (i = 0u; i < OS_CFG_PRIO_MAX; i++) { // Initialize the array of OS_RDY_LIST at each priority
p_rdy_list = &OSRdyList[i];
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_rdy_list->NbrEntries = 0u;
#endif
p_rdy_list->HeadPtr = DEF_NULL;
p_rdy_list->TailPtr = DEF_NULL;
}
} | /****************************************************************************************************/
/**
* OS_RdyListInit()
*
* @brief This function is called by OSInit() to initialize the ready list. The ready list contains
* a list of all the tasks that are ready to run. The list is actually an array of OS_RDY_LIST.
* An OS_RDY_LIST contains three fields. The number of OS_TCBs in the list (i.e. .NbrEntries),
* a pointer to the first OS_TCB in the OS_RDY_LIST (i.e. .HeadPtr) and a pointer to the last
* OS_TCB in the OS_RDY_LIST (i.e. .TailPtr).
* @n
* OS_TCBs are doubly linked in the OS_RDY_LIST and each OS_TCB points back to the OS_RDY_LIST
* it belongs to.
* @n
* 'OS_RDY_LIST OSRdyTbl[OS_CFG_PRIO_MAX]' looks like this once initialized:
* @verbatim
* +---------------+--------------+
* | | TailPtr |-----> 0
* [0] | NbrEntries=0 +--------------+
* | | HeadPtr |-----> 0
* +---------------+--------------+
* | | TailPtr |-----> 0
* [1] | NbrEntries=0 +--------------+
* | | HeadPtr |-----> 0
* +---------------+--------------+
* : :
* : :
* : :
* +---------------+--------------+
* | | TailPtr |-----> 0
* [OS_CFG_PRIO_MAX-1] | NbrEntries=0 +--------------+
* | | HeadPtr |-----> 0
* +---------------+--------------+
* @endverbatim
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*******************************************************************************************************/ | OS_RdyListInit()
@brief This function is called by OSInit() to initialize the ready list. The ready list contains
a list of all the tasks that are ready to run. The list is actually an array of OS_RDY_LIST.
An OS_RDY_LIST contains three fields. The number of OS_TCBs in the list ,
a pointer to the first OS_TCB in the OS_RDY_LIST and a pointer to the last
OS_TCB in the OS_RDY_LIST .
@n
OS_TCBs are doubly linked in the OS_RDY_LIST and each OS_TCB points back to the OS_RDY_LIST
it belongs to. | [
"OS_RdyListInit",
"()",
"@brief",
"This",
"function",
"is",
"called",
"by",
"OSInit",
"()",
"to",
"initialize",
"the",
"ready",
"list",
".",
"The",
"ready",
"list",
"contains",
"a",
"list",
"of",
"all",
"the",
"tasks",
"that",
"are",
"ready",
"to",
"run",
".",
"The",
"list",
"is",
"actually",
"an",
"array",
"of",
"OS_RDY_LIST",
".",
"An",
"OS_RDY_LIST",
"contains",
"three",
"fields",
".",
"The",
"number",
"of",
"OS_TCBs",
"in",
"the",
"list",
"a",
"pointer",
"to",
"the",
"first",
"OS_TCB",
"in",
"the",
"OS_RDY_LIST",
"and",
"a",
"pointer",
"to",
"the",
"last",
"OS_TCB",
"in",
"the",
"OS_RDY_LIST",
".",
"@n",
"OS_TCBs",
"are",
"doubly",
"linked",
"in",
"the",
"OS_RDY_LIST",
"and",
"each",
"OS_TCB",
"points",
"back",
"to",
"the",
"OS_RDY_LIST",
"it",
"belongs",
"to",
"."
] | void OS_RdyListInit(void)
{
CPU_INT32U i;
OS_RDY_LIST *p_rdy_list;
for (i = 0u; i < OS_CFG_PRIO_MAX; i++) {
p_rdy_list = &OSRdyList[i];
#if (OS_CFG_DBG_EN == DEF_ENABLED)
p_rdy_list->NbrEntries = 0u;
#endif
p_rdy_list->HeadPtr = DEF_NULL;
p_rdy_list->TailPtr = DEF_NULL;
}
} | [
"void",
"OS_RdyListInit",
"(",
"void",
")",
"{",
"CPU_INT32U",
"i",
";",
"OS_RDY_LIST",
"*",
"p_rdy_list",
";",
"for",
"(",
"i",
"=",
"0u",
";",
"i",
"<",
"OS_CFG_PRIO_MAX",
";",
"i",
"++",
")",
"{",
"p_rdy_list",
"=",
"&",
"OSRdyList",
"[",
"i",
"]",
";",
"#if",
"(",
"OS_CFG_DBG_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_rdy_list",
"->",
"NbrEntries",
"=",
"0u",
";",
"#endif",
"p_rdy_list",
"->",
"HeadPtr",
"=",
"DEF_NULL",
";",
"p_rdy_list",
"->",
"TailPtr",
"=",
"DEF_NULL",
";",
"}",
"}"
] | OS_RdyListInit()
@brief This function is called by OSInit() to initialize the ready list. | [
"OS_RdyListInit",
"()",
"@brief",
"This",
"function",
"is",
"called",
"by",
"OSInit",
"()",
"to",
"initialize",
"the",
"ready",
"list",
"."
] | [
"// Initialize the array of OS_RDY_LIST at each priority"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_RdyListInsert | void | void OS_RdyListInsert(OS_TCB *p_tcb)
{
OS_PrioInsert(p_tcb->Prio);
if (p_tcb->Prio == OSPrioCur) { // Are we readying a task at the same prio?
OS_RdyListInsertTail(p_tcb); // Yes, insert readied task at the end of the list
} else {
OS_RdyListInsertHead(p_tcb); // No, insert readied task at the beginning of the list
}
OS_TRACE_TASK_READY(p_tcb);
} | /****************************************************************************************************/
/**
* OS_RdyListInsert()
*
* @brief This function is called to insert a TCB in the ready list.
*
* The TCB is inserted at the tail of the list if the priority of the TCB is the same as the
* priority of the current task. The TCB is inserted at the head of the list if not.
*
* @param p_tcb Pointer to the TCB to insert into the ready list.
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*******************************************************************************************************/ | OS_RdyListInsert()
@brief This function is called to insert a TCB in the ready list.
The TCB is inserted at the tail of the list if the priority of the TCB is the same as the
priority of the current task. The TCB is inserted at the head of the list if not.
@param p_tcb Pointer to the TCB to insert into the ready list.
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it. | [
"OS_RdyListInsert",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"insert",
"a",
"TCB",
"in",
"the",
"ready",
"list",
".",
"The",
"TCB",
"is",
"inserted",
"at",
"the",
"tail",
"of",
"the",
"list",
"if",
"the",
"priority",
"of",
"the",
"TCB",
"is",
"the",
"same",
"as",
"the",
"priority",
"of",
"the",
"current",
"task",
".",
"The",
"TCB",
"is",
"inserted",
"at",
"the",
"head",
"of",
"the",
"list",
"if",
"not",
".",
"@param",
"p_tcb",
"Pointer",
"to",
"the",
"TCB",
"to",
"insert",
"into",
"the",
"ready",
"list",
".",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
"."
] | void OS_RdyListInsert(OS_TCB *p_tcb)
{
OS_PrioInsert(p_tcb->Prio);
if (p_tcb->Prio == OSPrioCur) {
OS_RdyListInsertTail(p_tcb);
} else {
OS_RdyListInsertHead(p_tcb);
}
OS_TRACE_TASK_READY(p_tcb);
} | [
"void",
"OS_RdyListInsert",
"(",
"OS_TCB",
"*",
"p_tcb",
")",
"{",
"OS_PrioInsert",
"(",
"p_tcb",
"->",
"Prio",
")",
";",
"if",
"(",
"p_tcb",
"->",
"Prio",
"==",
"OSPrioCur",
")",
"{",
"OS_RdyListInsertTail",
"(",
"p_tcb",
")",
";",
"}",
"else",
"{",
"OS_RdyListInsertHead",
"(",
"p_tcb",
")",
";",
"}",
"OS_TRACE_TASK_READY",
"(",
"p_tcb",
")",
";",
"}"
] | OS_RdyListInsert()
@brief This function is called to insert a TCB in the ready list. | [
"OS_RdyListInsert",
"()",
"@brief",
"This",
"function",
"is",
"called",
"to",
"insert",
"a",
"TCB",
"in",
"the",
"ready",
"list",
"."
] | [
"// Are we readying a task at the same prio?",
"// Yes, insert readied task at the end of the list",
"// No, insert readied task at the beginning of the list"
] | [
{
"param": "p_tcb",
"type": "OS_TCB"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_tcb",
"type": "OS_TCB",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_SchedLockTimeMeasStop | void | void OS_SchedLockTimeMeasStop(void)
{
CPU_TS_TMR delta;
if (OSSchedLockNestingCtr == 0u) { // Make sure we fully un-nested scheduler lock
delta = CPU_TS_TmrRd() // Compute the delta time between begin and end
- OSSchedLockTimeBegin;
if (OSSchedLockTimeMax < delta) { // Detect peak value
OSSchedLockTimeMax = delta;
}
if (OSSchedLockTimeMaxCur < delta) { // Detect peak value (for resettable value)
OSSchedLockTimeMaxCur = delta;
}
}
} | /****************************************************************************************************/
/**
* OS_SchedLockTimeMeasStop()
*
* @brief Stop measuring the time the scheduler is locked and update the current and max locked
* times.
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*
* @note (2) It's assumed that this function is called when interrupts are disabled.
*
* @note (3) We are reading the CPU_TS_TmrRd() directly even if this is a 16-bit timer. The reason
* is that we don't expect to have the scheduler locked for 65536 counts even at the rate
* the TS timer is updated. In other words, locking the scheduler for longer than 65536
* counts would not be a good thing for a real-time system.
*******************************************************************************************************/ | OS_SchedLockTimeMeasStop()
@brief Stop measuring the time the scheduler is locked and update the current and max locked
times.
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
@note (2) It's assumed that this function is called when interrupts are disabled.
@note (3) We are reading the CPU_TS_TmrRd() directly even if this is a 16-bit timer. The reason
is that we don't expect to have the scheduler locked for 65536 counts even at the rate
the TS timer is updated. In other words, locking the scheduler for longer than 65536
counts would not be a good thing for a real-time system. | [
"OS_SchedLockTimeMeasStop",
"()",
"@brief",
"Stop",
"measuring",
"the",
"time",
"the",
"scheduler",
"is",
"locked",
"and",
"update",
"the",
"current",
"and",
"max",
"locked",
"times",
".",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
".",
"@note",
"(",
"2",
")",
"It",
"'",
"s",
"assumed",
"that",
"this",
"function",
"is",
"called",
"when",
"interrupts",
"are",
"disabled",
".",
"@note",
"(",
"3",
")",
"We",
"are",
"reading",
"the",
"CPU_TS_TmrRd",
"()",
"directly",
"even",
"if",
"this",
"is",
"a",
"16",
"-",
"bit",
"timer",
".",
"The",
"reason",
"is",
"that",
"we",
"don",
"'",
"t",
"expect",
"to",
"have",
"the",
"scheduler",
"locked",
"for",
"65536",
"counts",
"even",
"at",
"the",
"rate",
"the",
"TS",
"timer",
"is",
"updated",
".",
"In",
"other",
"words",
"locking",
"the",
"scheduler",
"for",
"longer",
"than",
"65536",
"counts",
"would",
"not",
"be",
"a",
"good",
"thing",
"for",
"a",
"real",
"-",
"time",
"system",
"."
] | void OS_SchedLockTimeMeasStop(void)
{
CPU_TS_TMR delta;
if (OSSchedLockNestingCtr == 0u) {
delta = CPU_TS_TmrRd()
- OSSchedLockTimeBegin;
if (OSSchedLockTimeMax < delta) {
OSSchedLockTimeMax = delta;
}
if (OSSchedLockTimeMaxCur < delta) { (for resettable value)
OSSchedLockTimeMaxCur = delta;
}
}
} | [
"void",
"OS_SchedLockTimeMeasStop",
"(",
"void",
")",
"{",
"CPU_TS_TMR",
"delta",
";",
"if",
"(",
"OSSchedLockNestingCtr",
"==",
"0u",
")",
"{",
"delta",
"=",
"CPU_TS_TmrRd",
"(",
")",
"-",
"OSSchedLockTimeBegin",
";",
"if",
"(",
"OSSchedLockTimeMax",
"<",
"delta",
")",
"{",
"OSSchedLockTimeMax",
"=",
"delta",
";",
"}",
"if",
"(",
"OSSchedLockTimeMaxCur",
"<",
"delta",
")",
"{",
"OSSchedLockTimeMaxCur",
"=",
"delta",
";",
"}",
"}",
"}"
] | OS_SchedLockTimeMeasStop()
@brief Stop measuring the time the scheduler is locked and update the current and max locked
times. | [
"OS_SchedLockTimeMeasStop",
"()",
"@brief",
"Stop",
"measuring",
"the",
"time",
"the",
"scheduler",
"is",
"locked",
"and",
"update",
"the",
"current",
"and",
"max",
"locked",
"times",
"."
] | [
"// Make sure we fully un-nested scheduler lock",
"// Compute the delta time between begin and end",
"// Detect peak value",
"// Detect peak value (for resettable value)"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_SchedRoundRobinRestartTimer | void | void OS_SchedRoundRobinRestartTimer(OS_TCB* p_tcb)
{
if (p_tcb == DEF_NULL) {
return;
}
if (OSSchedRoundRobinEn != DEF_TRUE) { // Make sure round-robin has been enabled
return;
}
sl_sleeptimer_start_timer(&OSRoundRobinTimer,
p_tcb->TimeQuantaCtr,
OS_SchedRoundRobin,
(void *)p_tcb,
0u,
0u);
OSRoundRobinCurTCB = p_tcb;
} | /*****************************************************************************************************/
/**
* OS_SchedRoundRobinRestartTimer()
*
* @brief Restart the Round-Robin timer, saving the TimeQuanta remaining if needed.
*
* @param p_tcb pointer to the TCB of the new task to round-robin
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*
* @note (2) Due to the sleeptimer's behavior and it blocking interrupts, we cannot rely on the
* OSTCBCurPtr as being 100% accurate. OSRoundRobinCurTCB is used instead as the current
* Task for the RoundRobin timer.
*******************************************************************************************************/ | OS_SchedRoundRobinRestartTimer()
@brief Restart the Round-Robin timer, saving the TimeQuanta remaining if needed.
@param p_tcb pointer to the TCB of the new task to round-robin
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
@note (2) Due to the sleeptimer's behavior and it blocking interrupts, we cannot rely on the
OSTCBCurPtr as being 100% accurate. OSRoundRobinCurTCB is used instead as the current
Task for the RoundRobin timer. | [
"OS_SchedRoundRobinRestartTimer",
"()",
"@brief",
"Restart",
"the",
"Round",
"-",
"Robin",
"timer",
"saving",
"the",
"TimeQuanta",
"remaining",
"if",
"needed",
".",
"@param",
"p_tcb",
"pointer",
"to",
"the",
"TCB",
"of",
"the",
"new",
"task",
"to",
"round",
"-",
"robin",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
".",
"@note",
"(",
"2",
")",
"Due",
"to",
"the",
"sleeptimer",
"'",
"s",
"behavior",
"and",
"it",
"blocking",
"interrupts",
"we",
"cannot",
"rely",
"on",
"the",
"OSTCBCurPtr",
"as",
"being",
"100%",
"accurate",
".",
"OSRoundRobinCurTCB",
"is",
"used",
"instead",
"as",
"the",
"current",
"Task",
"for",
"the",
"RoundRobin",
"timer",
"."
] | void OS_SchedRoundRobinRestartTimer(OS_TCB* p_tcb)
{
if (p_tcb == DEF_NULL) {
return;
}
if (OSSchedRoundRobinEn != DEF_TRUE) {
return;
}
sl_sleeptimer_start_timer(&OSRoundRobinTimer,
p_tcb->TimeQuantaCtr,
OS_SchedRoundRobin,
(void *)p_tcb,
0u,
0u);
OSRoundRobinCurTCB = p_tcb;
} | [
"void",
"OS_SchedRoundRobinRestartTimer",
"(",
"OS_TCB",
"*",
"p_tcb",
")",
"{",
"if",
"(",
"p_tcb",
"==",
"DEF_NULL",
")",
"{",
"return",
";",
"}",
"if",
"(",
"OSSchedRoundRobinEn",
"!=",
"DEF_TRUE",
")",
"{",
"return",
";",
"}",
"sl_sleeptimer_start_timer",
"(",
"&",
"OSRoundRobinTimer",
",",
"p_tcb",
"->",
"TimeQuantaCtr",
",",
"OS_SchedRoundRobin",
",",
"(",
"void",
"*",
")",
"p_tcb",
",",
"0u",
",",
"0u",
")",
";",
"OSRoundRobinCurTCB",
"=",
"p_tcb",
";",
"}"
] | OS_SchedRoundRobinRestartTimer()
@brief Restart the Round-Robin timer, saving the TimeQuanta remaining if needed. | [
"OS_SchedRoundRobinRestartTimer",
"()",
"@brief",
"Restart",
"the",
"Round",
"-",
"Robin",
"timer",
"saving",
"the",
"TimeQuanta",
"remaining",
"if",
"needed",
"."
] | [
"// Make sure round-robin has been enabled"
] | [
{
"param": "p_tcb",
"type": "OS_TCB"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_tcb",
"type": "OS_TCB",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_SchedRoundRobinResetQuanta | void | void OS_SchedRoundRobinResetQuanta(OS_TCB *p_tcb)
{
if (p_tcb == DEF_NULL) {
return;
}
if (OSSchedRoundRobinEn != DEF_TRUE) { // Make sure round-robin has been enabled
return;
}
if (p_tcb->TimeQuanta == 0u) { // See if we need to use the default time slice
p_tcb->TimeQuantaCtr = (uint64_t)(((uint64_t)OSSchedRoundRobinDfltTimeQuanta * (uint64_t)sl_sleeptimer_get_timer_frequency()) + (OSCfg_TickRate_Hz - 1u)) / OSCfg_TickRate_Hz;
} else {
p_tcb->TimeQuantaCtr = (uint64_t)(((uint64_t)p_tcb->TimeQuanta * (uint64_t)sl_sleeptimer_get_timer_frequency()) + (OSCfg_TickRate_Hz - 1u)) / OSCfg_TickRate_Hz;
}
} | /*****************************************************************************************************/
/**
* OS_SchedRoundRobinResetQuanta()
*
* @brief Resets a task's TimeQuantaCtr
*
* @param p_tcb pointer to the TCB of the task
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*******************************************************************************************************/ |
@param p_tcb pointer to the TCB of the task
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it. | [
"@param",
"p_tcb",
"pointer",
"to",
"the",
"TCB",
"of",
"the",
"task",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
"."
] | void OS_SchedRoundRobinResetQuanta(OS_TCB *p_tcb)
{
if (p_tcb == DEF_NULL) {
return;
}
if (OSSchedRoundRobinEn != DEF_TRUE) {
return;
}
if (p_tcb->TimeQuanta == 0u) {
p_tcb->TimeQuantaCtr = (uint64_t)(((uint64_t)OSSchedRoundRobinDfltTimeQuanta * (uint64_t)sl_sleeptimer_get_timer_frequency()) + (OSCfg_TickRate_Hz - 1u)) / OSCfg_TickRate_Hz;
} else {
p_tcb->TimeQuantaCtr = (uint64_t)(((uint64_t)p_tcb->TimeQuanta * (uint64_t)sl_sleeptimer_get_timer_frequency()) + (OSCfg_TickRate_Hz - 1u)) / OSCfg_TickRate_Hz;
}
} | [
"void",
"OS_SchedRoundRobinResetQuanta",
"(",
"OS_TCB",
"*",
"p_tcb",
")",
"{",
"if",
"(",
"p_tcb",
"==",
"DEF_NULL",
")",
"{",
"return",
";",
"}",
"if",
"(",
"OSSchedRoundRobinEn",
"!=",
"DEF_TRUE",
")",
"{",
"return",
";",
"}",
"if",
"(",
"p_tcb",
"->",
"TimeQuanta",
"==",
"0u",
")",
"{",
"p_tcb",
"->",
"TimeQuantaCtr",
"=",
"(",
"uint64_t",
")",
"(",
"(",
"(",
"uint64_t",
")",
"OSSchedRoundRobinDfltTimeQuanta",
"*",
"(",
"uint64_t",
")",
"sl_sleeptimer_get_timer_frequency",
"(",
")",
")",
"+",
"(",
"OSCfg_TickRate_Hz",
"-",
"1u",
")",
")",
"/",
"OSCfg_TickRate_Hz",
";",
"}",
"else",
"{",
"p_tcb",
"->",
"TimeQuantaCtr",
"=",
"(",
"uint64_t",
")",
"(",
"(",
"(",
"uint64_t",
")",
"p_tcb",
"->",
"TimeQuanta",
"*",
"(",
"uint64_t",
")",
"sl_sleeptimer_get_timer_frequency",
"(",
")",
")",
"+",
"(",
"OSCfg_TickRate_Hz",
"-",
"1u",
")",
")",
"/",
"OSCfg_TickRate_Hz",
";",
"}",
"}"
] | OS_SchedRoundRobinResetQuanta()
@brief Resets a task's TimeQuantaCtr | [
"OS_SchedRoundRobinResetQuanta",
"()",
"@brief",
"Resets",
"a",
"task",
"'",
"s",
"TimeQuantaCtr"
] | [
"// Make sure round-robin has been enabled",
"// See if we need to use the default time slice"
] | [
{
"param": "p_tcb",
"type": "OS_TCB"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p_tcb",
"type": "OS_TCB",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc11f78fb0144150ac0bad3063376f29f320c1b9 | SiliconLabs/Gecko_SDK | platform/micrium_os/kernel/source/os_core.c | [
"Zlib"
] | C | OS_TimerCallback | void | void OS_TimerCallback(sl_sleeptimer_timer_handle_t *handle,
void *data)
{
OS_TCB *p_tcb = (OS_TCB *)data;
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
OS_TCB *p_tcb_owner;
OS_PRIO prio_new;
#endif
PP_UNUSED_PARAM(handle);
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
switch (p_tcb->TaskState) {
case OS_TASK_STATE_PEND_TIMEOUT:
case OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED:
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
p_tcb_owner = DEF_NULL;
if (p_tcb->PendOn == OS_TASK_PEND_ON_MUTEX) {
p_tcb_owner = ((OS_MUTEX *)p_tcb->PendObjPtr)->OwnerTCBPtr;
}
#endif
#if (OS_MSG_EN == DEF_ENABLED)
p_tcb->MsgPtr = DEF_NULL;
p_tcb->MsgSize = 0u;
#endif
#if (OS_CFG_TS_EN == DEF_ENABLED)
p_tcb->TS = OS_TS_GET();
#endif
OS_PendListRemove(p_tcb); /* Remove task from pend list */
if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT) {
OS_RdyListInsert(p_tcb); /* Insert the task in the ready list */
p_tcb->TaskState = OS_TASK_STATE_RDY;
} else if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED) {
p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
}
p_tcb->PendStatus = OS_STATUS_PEND_TIMEOUT; /* Indicate pend timed out */
p_tcb->PendOn = OS_TASK_PEND_ON_NOTHING; /* Indicate no longer pending */
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
if (p_tcb_owner != DEF_NULL) {
if ((p_tcb_owner->Prio != p_tcb_owner->BasePrio)
&& (p_tcb_owner->Prio == p_tcb->Prio)) { /* Has the owner inherited a priority? */
prio_new = OS_MutexGrpPrioFindHighest(p_tcb_owner);
prio_new = prio_new > p_tcb_owner->BasePrio ? p_tcb_owner->BasePrio : prio_new;
if (prio_new != p_tcb_owner->Prio) {
OS_TaskChangePrio(p_tcb_owner, prio_new);
OS_TRACE_MUTEX_TASK_PRIO_DISINHERIT(p_tcb_owner, p_tcb_owner->Prio);
}
}
}
#endif
break;
case OS_TASK_STATE_DLY:
p_tcb->TaskState = OS_TASK_STATE_RDY;
OS_RdyListInsert(p_tcb); /* Insert the task in the ready list */
break;
case OS_TASK_STATE_DLY_SUSPENDED:
p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
break;
default:
break;
}
CORE_EXIT_ATOMIC();
OSSched();
} | /*****************************************************************************************************/
/**
* OS_TimerCallback()
*
* @brief Function called when a timer expires.
*
* @param handle Handle to timer that expired.
*
* @param data Pointer caller specific data.
*
* @note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it.
*******************************************************************************************************/ | OS_TimerCallback()
@brief Function called when a timer expires.
@param handle Handle to timer that expired.
@param data Pointer caller specific data.
@note (1) This function is INTERNAL to the Kernel and your application MUST NOT call it. | [
"OS_TimerCallback",
"()",
"@brief",
"Function",
"called",
"when",
"a",
"timer",
"expires",
".",
"@param",
"handle",
"Handle",
"to",
"timer",
"that",
"expired",
".",
"@param",
"data",
"Pointer",
"caller",
"specific",
"data",
".",
"@note",
"(",
"1",
")",
"This",
"function",
"is",
"INTERNAL",
"to",
"the",
"Kernel",
"and",
"your",
"application",
"MUST",
"NOT",
"call",
"it",
"."
] | void OS_TimerCallback(sl_sleeptimer_timer_handle_t *handle,
void *data)
{
OS_TCB *p_tcb = (OS_TCB *)data;
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
OS_TCB *p_tcb_owner;
OS_PRIO prio_new;
#endif
PP_UNUSED_PARAM(handle);
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
switch (p_tcb->TaskState) {
case OS_TASK_STATE_PEND_TIMEOUT:
case OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED:
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
p_tcb_owner = DEF_NULL;
if (p_tcb->PendOn == OS_TASK_PEND_ON_MUTEX) {
p_tcb_owner = ((OS_MUTEX *)p_tcb->PendObjPtr)->OwnerTCBPtr;
}
#endif
#if (OS_MSG_EN == DEF_ENABLED)
p_tcb->MsgPtr = DEF_NULL;
p_tcb->MsgSize = 0u;
#endif
#if (OS_CFG_TS_EN == DEF_ENABLED)
p_tcb->TS = OS_TS_GET();
#endif
OS_PendListRemove(p_tcb);
if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT) {
OS_RdyListInsert(p_tcb);
p_tcb->TaskState = OS_TASK_STATE_RDY;
} else if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED) {
p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
}
p_tcb->PendStatus = OS_STATUS_PEND_TIMEOUT;
p_tcb->PendOn = OS_TASK_PEND_ON_NOTHING;
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
if (p_tcb_owner != DEF_NULL) {
if ((p_tcb_owner->Prio != p_tcb_owner->BasePrio)
&& (p_tcb_owner->Prio == p_tcb->Prio)) {
prio_new = OS_MutexGrpPrioFindHighest(p_tcb_owner);
prio_new = prio_new > p_tcb_owner->BasePrio ? p_tcb_owner->BasePrio : prio_new;
if (prio_new != p_tcb_owner->Prio) {
OS_TaskChangePrio(p_tcb_owner, prio_new);
OS_TRACE_MUTEX_TASK_PRIO_DISINHERIT(p_tcb_owner, p_tcb_owner->Prio);
}
}
}
#endif
break;
case OS_TASK_STATE_DLY:
p_tcb->TaskState = OS_TASK_STATE_RDY;
OS_RdyListInsert(p_tcb);
break;
case OS_TASK_STATE_DLY_SUSPENDED:
p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
break;
default:
break;
}
CORE_EXIT_ATOMIC();
OSSched();
} | [
"void",
"OS_TimerCallback",
"(",
"sl_sleeptimer_timer_handle_t",
"*",
"handle",
",",
"void",
"*",
"data",
")",
"{",
"OS_TCB",
"*",
"p_tcb",
"=",
"(",
"OS_TCB",
"*",
")",
"data",
";",
"#if",
"(",
"OS_CFG_MUTEX_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"OS_TCB",
"*",
"p_tcb_owner",
";",
"OS_PRIO",
"prio_new",
";",
"#endif",
"PP_UNUSED_PARAM",
"(",
"handle",
")",
";",
"CORE_DECLARE_IRQ_STATE",
";",
"CORE_ENTER_ATOMIC",
"(",
")",
";",
"switch",
"(",
"p_tcb",
"->",
"TaskState",
")",
"{",
"case",
"OS_TASK_STATE_PEND_TIMEOUT",
":",
"case",
"OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED",
":",
"#if",
"(",
"OS_CFG_MUTEX_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_tcb_owner",
"=",
"DEF_NULL",
";",
"if",
"(",
"p_tcb",
"->",
"PendOn",
"==",
"OS_TASK_PEND_ON_MUTEX",
")",
"{",
"p_tcb_owner",
"=",
"(",
"(",
"OS_MUTEX",
"*",
")",
"p_tcb",
"->",
"PendObjPtr",
")",
"->",
"OwnerTCBPtr",
";",
"}",
"#endif",
"#if",
"(",
"OS_MSG_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_tcb",
"->",
"MsgPtr",
"=",
"DEF_NULL",
";",
"p_tcb",
"->",
"MsgSize",
"=",
"0u",
";",
"#endif",
"#if",
"(",
"OS_CFG_TS_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"p_tcb",
"->",
"TS",
"=",
"OS_TS_GET",
"(",
")",
";",
"#endif",
"OS_PendListRemove",
"(",
"p_tcb",
")",
";",
"if",
"(",
"p_tcb",
"->",
"TaskState",
"==",
"OS_TASK_STATE_PEND_TIMEOUT",
")",
"{",
"OS_RdyListInsert",
"(",
"p_tcb",
")",
";",
"p_tcb",
"->",
"TaskState",
"=",
"OS_TASK_STATE_RDY",
";",
"}",
"else",
"if",
"(",
"p_tcb",
"->",
"TaskState",
"==",
"OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED",
")",
"{",
"p_tcb",
"->",
"TaskState",
"=",
"OS_TASK_STATE_SUSPENDED",
";",
"}",
"p_tcb",
"->",
"PendStatus",
"=",
"OS_STATUS_PEND_TIMEOUT",
";",
"p_tcb",
"->",
"PendOn",
"=",
"OS_TASK_PEND_ON_NOTHING",
";",
"#if",
"(",
"OS_CFG_MUTEX_EN",
"==",
"DEF_ENABLED",
")",
"\n",
"if",
"(",
"p_tcb_owner",
"!=",
"DEF_NULL",
")",
"{",
"if",
"(",
"(",
"p_tcb_owner",
"->",
"Prio",
"!=",
"p_tcb_owner",
"->",
"BasePrio",
")",
"&&",
"(",
"p_tcb_owner",
"->",
"Prio",
"==",
"p_tcb",
"->",
"Prio",
")",
")",
"{",
"prio_new",
"=",
"OS_MutexGrpPrioFindHighest",
"(",
"p_tcb_owner",
")",
";",
"prio_new",
"=",
"prio_new",
">",
"p_tcb_owner",
"->",
"BasePrio",
"?",
"p_tcb_owner",
"->",
"BasePrio",
":",
"prio_new",
";",
"if",
"(",
"prio_new",
"!=",
"p_tcb_owner",
"->",
"Prio",
")",
"{",
"OS_TaskChangePrio",
"(",
"p_tcb_owner",
",",
"prio_new",
")",
";",
"OS_TRACE_MUTEX_TASK_PRIO_DISINHERIT",
"(",
"p_tcb_owner",
",",
"p_tcb_owner",
"->",
"Prio",
")",
";",
"}",
"}",
"}",
"#endif",
"break",
";",
"case",
"OS_TASK_STATE_DLY",
":",
"p_tcb",
"->",
"TaskState",
"=",
"OS_TASK_STATE_RDY",
";",
"OS_RdyListInsert",
"(",
"p_tcb",
")",
";",
"break",
";",
"case",
"OS_TASK_STATE_DLY_SUSPENDED",
":",
"p_tcb",
"->",
"TaskState",
"=",
"OS_TASK_STATE_SUSPENDED",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"CORE_EXIT_ATOMIC",
"(",
")",
";",
"OSSched",
"(",
")",
";",
"}"
] | OS_TimerCallback()
@brief Function called when a timer expires. | [
"OS_TimerCallback",
"()",
"@brief",
"Function",
"called",
"when",
"a",
"timer",
"expires",
"."
] | [
"/* Remove task from pend list */",
"/* Insert the task in the ready list */",
"/* Indicate pend timed out */",
"/* Indicate no longer pending */",
"/* Has the owner inherited a priority? */",
"/* Insert the task in the ready list */"
] | [
{
"param": "handle",
"type": "sl_sleeptimer_timer_handle_t"
},
{
"param": "data",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "sl_sleeptimer_timer_handle_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9458039e9642ff0835e767df814a3a9f0bc4c906 | SiliconLabs/Gecko_SDK | app/bluetooth/common_host/aoa_util/aoa_parse.c | [
"Zlib"
] | C | aoa_parse_angle_filtering_weight | sl_status_t | sl_status_t aoa_parse_angle_filtering_weight(float *filtering_weight,
aoa_id_t locator_id)
{
cJSON *param;
cJSON *locator;
sl_status_t sc;
// Check preconditions.
if (NULL == root) {
return SL_STATUS_NOT_INITIALIZED;
}
if (NULL == filtering_weight) {
return SL_STATUS_NULL_POINTER;
}
// Check for locator in positioning config
sc = aoa_parse_find_locator_config(&locator, locator_id);
if (sc != SL_STATUS_OK) {
// Try to parse as single locator config
locator = root;
}
// Try parse locator specific config
param = cJSON_GetObjectItem(locator, "angleFilteringWeight");
if (NULL == param) {
return SL_STATUS_NOT_FOUND;
}
CHECK_TYPE(param, cJSON_Number);
*filtering_weight = param->valuedouble;
return SL_STATUS_OK;
} | /**************************************************************************/
/**
* Parse angle filtering weight configuration.
*****************************************************************************/ | Parse angle filtering weight configuration. | [
"Parse",
"angle",
"filtering",
"weight",
"configuration",
"."
] | sl_status_t aoa_parse_angle_filtering_weight(float *filtering_weight,
aoa_id_t locator_id)
{
cJSON *param;
cJSON *locator;
sl_status_t sc;
if (NULL == root) {
return SL_STATUS_NOT_INITIALIZED;
}
if (NULL == filtering_weight) {
return SL_STATUS_NULL_POINTER;
}
sc = aoa_parse_find_locator_config(&locator, locator_id);
if (sc != SL_STATUS_OK) {
locator = root;
}
param = cJSON_GetObjectItem(locator, "angleFilteringWeight");
if (NULL == param) {
return SL_STATUS_NOT_FOUND;
}
CHECK_TYPE(param, cJSON_Number);
*filtering_weight = param->valuedouble;
return SL_STATUS_OK;
} | [
"sl_status_t",
"aoa_parse_angle_filtering_weight",
"(",
"float",
"*",
"filtering_weight",
",",
"aoa_id_t",
"locator_id",
")",
"{",
"cJSON",
"*",
"param",
";",
"cJSON",
"*",
"locator",
";",
"sl_status_t",
"sc",
";",
"if",
"(",
"NULL",
"==",
"root",
")",
"{",
"return",
"SL_STATUS_NOT_INITIALIZED",
";",
"}",
"if",
"(",
"NULL",
"==",
"filtering_weight",
")",
"{",
"return",
"SL_STATUS_NULL_POINTER",
";",
"}",
"sc",
"=",
"aoa_parse_find_locator_config",
"(",
"&",
"locator",
",",
"locator_id",
")",
";",
"if",
"(",
"sc",
"!=",
"SL_STATUS_OK",
")",
"{",
"locator",
"=",
"root",
";",
"}",
"param",
"=",
"cJSON_GetObjectItem",
"(",
"locator",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"NULL",
"==",
"param",
")",
"{",
"return",
"SL_STATUS_NOT_FOUND",
";",
"}",
"CHECK_TYPE",
"(",
"param",
",",
"cJSON_Number",
")",
";",
"*",
"filtering_weight",
"=",
"param",
"->",
"valuedouble",
";",
"return",
"SL_STATUS_OK",
";",
"}"
] | Parse angle filtering weight configuration. | [
"Parse",
"angle",
"filtering",
"weight",
"configuration",
"."
] | [
"// Check preconditions.",
"// Check for locator in positioning config",
"// Try to parse as single locator config",
"// Try parse locator specific config"
] | [
{
"param": "filtering_weight",
"type": "float"
},
{
"param": "locator_id",
"type": "aoa_id_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filtering_weight",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "locator_id",
"type": "aoa_id_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9458039e9642ff0835e767df814a3a9f0bc4c906 | SiliconLabs/Gecko_SDK | app/bluetooth/common_host/aoa_util/aoa_parse.c | [
"Zlib"
] | C | aoa_parse_simple_config | sl_status_t | sl_status_t aoa_parse_simple_config(uint16_t *config_value,
char *config_name,
aoa_id_t locator_id)
{
cJSON *param;
cJSON *locator;
sl_status_t sc;
// Check preconditions.
if (NULL == root) {
return SL_STATUS_NOT_INITIALIZED;
}
if (NULL == config_value) {
return SL_STATUS_NULL_POINTER;
}
// Check for locator in positioning config
sc = aoa_parse_find_locator_config(&locator, locator_id);
if (sc != SL_STATUS_OK) {
// Try to parse as single locator config
locator = root;
}
// Try parse locator specific config
param = cJSON_GetObjectItem(locator, config_name);
if (NULL == param) {
return SL_STATUS_NOT_FOUND;
}
CHECK_TYPE(param, cJSON_Number);
*config_value = param->valueint;
return SL_STATUS_OK;
} | /**************************************************************************/
/**
* Parse cte sampling interval configuration.
*****************************************************************************/ | Parse cte sampling interval configuration. | [
"Parse",
"cte",
"sampling",
"interval",
"configuration",
"."
] | sl_status_t aoa_parse_simple_config(uint16_t *config_value,
char *config_name,
aoa_id_t locator_id)
{
cJSON *param;
cJSON *locator;
sl_status_t sc;
if (NULL == root) {
return SL_STATUS_NOT_INITIALIZED;
}
if (NULL == config_value) {
return SL_STATUS_NULL_POINTER;
}
sc = aoa_parse_find_locator_config(&locator, locator_id);
if (sc != SL_STATUS_OK) {
locator = root;
}
param = cJSON_GetObjectItem(locator, config_name);
if (NULL == param) {
return SL_STATUS_NOT_FOUND;
}
CHECK_TYPE(param, cJSON_Number);
*config_value = param->valueint;
return SL_STATUS_OK;
} | [
"sl_status_t",
"aoa_parse_simple_config",
"(",
"uint16_t",
"*",
"config_value",
",",
"char",
"*",
"config_name",
",",
"aoa_id_t",
"locator_id",
")",
"{",
"cJSON",
"*",
"param",
";",
"cJSON",
"*",
"locator",
";",
"sl_status_t",
"sc",
";",
"if",
"(",
"NULL",
"==",
"root",
")",
"{",
"return",
"SL_STATUS_NOT_INITIALIZED",
";",
"}",
"if",
"(",
"NULL",
"==",
"config_value",
")",
"{",
"return",
"SL_STATUS_NULL_POINTER",
";",
"}",
"sc",
"=",
"aoa_parse_find_locator_config",
"(",
"&",
"locator",
",",
"locator_id",
")",
";",
"if",
"(",
"sc",
"!=",
"SL_STATUS_OK",
")",
"{",
"locator",
"=",
"root",
";",
"}",
"param",
"=",
"cJSON_GetObjectItem",
"(",
"locator",
",",
"config_name",
")",
";",
"if",
"(",
"NULL",
"==",
"param",
")",
"{",
"return",
"SL_STATUS_NOT_FOUND",
";",
"}",
"CHECK_TYPE",
"(",
"param",
",",
"cJSON_Number",
")",
";",
"*",
"config_value",
"=",
"param",
"->",
"valueint",
";",
"return",
"SL_STATUS_OK",
";",
"}"
] | Parse cte sampling interval configuration. | [
"Parse",
"cte",
"sampling",
"interval",
"configuration",
"."
] | [
"// Check preconditions.",
"// Check for locator in positioning config",
"// Try to parse as single locator config",
"// Try parse locator specific config"
] | [
{
"param": "config_value",
"type": "uint16_t"
},
{
"param": "config_name",
"type": "char"
},
{
"param": "locator_id",
"type": "aoa_id_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "config_value",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "locator_id",
"type": "aoa_id_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9458039e9642ff0835e767df814a3a9f0bc4c906 | SiliconLabs/Gecko_SDK | app/bluetooth/common_host/aoa_util/aoa_parse.c | [
"Zlib"
] | C | aoa_parse_find_locator_config | sl_status_t | static sl_status_t aoa_parse_find_locator_config(cJSON **locator,
aoa_id_t locator_id)
{
aoa_id_t id_json;
cJSON *param;
cJSON *array;
cJSON *item;
uint8_t i = 0;
array = cJSON_GetObjectItem(root, "locators");
CHECK_TYPE(array, cJSON_Array);
//Check if array of locator configs present
if (NULL == array) {
return SL_STATUS_NOT_FOUND;
}
//Check for the locator
while (i <= cJSON_GetArraySize(array)) {
// Get next locator element from the array.
item = cJSON_GetArrayItem(array, i);
CHECK_TYPE(item, cJSON_Object);
// Parse locator ID.
param = cJSON_GetObjectItem(item, "id");
CHECK_TYPE(param, cJSON_String);
aoa_id_copy(id_json, param->valuestring);
if (aoa_id_compare(id_json, locator_id) == 0) {
// Locator found, check for config.
item = cJSON_GetObjectItem(item, "config");
CHECK_TYPE(item, cJSON_Object);
// Check if config for the locator present.
if (NULL == item) {
return SL_STATUS_NOT_FOUND;
}
// Locator config found.
*locator = item;
return SL_STATUS_OK;
}
++i;
}
return SL_STATUS_NOT_FOUND;
} | /**************************************************************************/
/**
* Checking for a locator by id
*****************************************************************************/ | Checking for a locator by id | [
"Checking",
"for",
"a",
"locator",
"by",
"id"
] | static sl_status_t aoa_parse_find_locator_config(cJSON **locator,
aoa_id_t locator_id)
{
aoa_id_t id_json;
cJSON *param;
cJSON *array;
cJSON *item;
uint8_t i = 0;
array = cJSON_GetObjectItem(root, "locators");
CHECK_TYPE(array, cJSON_Array);
if (NULL == array) {
return SL_STATUS_NOT_FOUND;
}
while (i <= cJSON_GetArraySize(array)) {
item = cJSON_GetArrayItem(array, i);
CHECK_TYPE(item, cJSON_Object);
param = cJSON_GetObjectItem(item, "id");
CHECK_TYPE(param, cJSON_String);
aoa_id_copy(id_json, param->valuestring);
if (aoa_id_compare(id_json, locator_id) == 0) {
item = cJSON_GetObjectItem(item, "config");
CHECK_TYPE(item, cJSON_Object);
if (NULL == item) {
return SL_STATUS_NOT_FOUND;
}
*locator = item;
return SL_STATUS_OK;
}
++i;
}
return SL_STATUS_NOT_FOUND;
} | [
"static",
"sl_status_t",
"aoa_parse_find_locator_config",
"(",
"cJSON",
"*",
"*",
"locator",
",",
"aoa_id_t",
"locator_id",
")",
"{",
"aoa_id_t",
"id_json",
";",
"cJSON",
"*",
"param",
";",
"cJSON",
"*",
"array",
";",
"cJSON",
"*",
"item",
";",
"uint8_t",
"i",
"=",
"0",
";",
"array",
"=",
"cJSON_GetObjectItem",
"(",
"root",
",",
"\"",
"\"",
")",
";",
"CHECK_TYPE",
"(",
"array",
",",
"cJSON_Array",
")",
";",
"if",
"(",
"NULL",
"==",
"array",
")",
"{",
"return",
"SL_STATUS_NOT_FOUND",
";",
"}",
"while",
"(",
"i",
"<=",
"cJSON_GetArraySize",
"(",
"array",
")",
")",
"{",
"item",
"=",
"cJSON_GetArrayItem",
"(",
"array",
",",
"i",
")",
";",
"CHECK_TYPE",
"(",
"item",
",",
"cJSON_Object",
")",
";",
"param",
"=",
"cJSON_GetObjectItem",
"(",
"item",
",",
"\"",
"\"",
")",
";",
"CHECK_TYPE",
"(",
"param",
",",
"cJSON_String",
")",
";",
"aoa_id_copy",
"(",
"id_json",
",",
"param",
"->",
"valuestring",
")",
";",
"if",
"(",
"aoa_id_compare",
"(",
"id_json",
",",
"locator_id",
")",
"==",
"0",
")",
"{",
"item",
"=",
"cJSON_GetObjectItem",
"(",
"item",
",",
"\"",
"\"",
")",
";",
"CHECK_TYPE",
"(",
"item",
",",
"cJSON_Object",
")",
";",
"if",
"(",
"NULL",
"==",
"item",
")",
"{",
"return",
"SL_STATUS_NOT_FOUND",
";",
"}",
"*",
"locator",
"=",
"item",
";",
"return",
"SL_STATUS_OK",
";",
"}",
"++",
"i",
";",
"}",
"return",
"SL_STATUS_NOT_FOUND",
";",
"}"
] | Checking for a locator by id | [
"Checking",
"for",
"a",
"locator",
"by",
"id"
] | [
"//Check if array of locator configs present",
"//Check for the locator",
"// Get next locator element from the array.",
"// Parse locator ID.",
"// Locator found, check for config.",
"// Check if config for the locator present.",
"// Locator config found."
] | [
{
"param": "locator",
"type": "cJSON"
},
{
"param": "locator_id",
"type": "aoa_id_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "locator",
"type": "cJSON",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "locator_id",
"type": "aoa_id_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e6528efa0a6a1bd7810836da4b6213b013fbfb64 | SiliconLabs/Gecko_SDK | app/wisun/component/socket/socket.c | [
"Zlib"
] | C | bind | int32_t | int32_t bind(int32_t sockid, const struct sockaddr *addr, socklen_t addrlen)
{
sl_status_t stat = SL_STATUS_FAIL;
const wisun_addr_t *wisun_addr = NULL;
_socket_handler_t *sockhnd = NULL;
// Get socket handler
sockhnd = socket_handler_get(sockid);
if (sockhnd == NULL) { // tried to bind addresss to non existing socket id
_set_errno_ret_error(EINVAL);
}
switch (sockhnd->_domain) {
case AF_WISUN:
if (addr == NULL || addrlen != sizeof(wisun_addr_t)
|| addr->sa_family != AF_WISUN) {
_set_errno_ret_error(EINVAL);
}
// cast address to wisun address
wisun_addr = (const wisun_addr_t *)addr;
stat = sl_wisun_bind_socket((sl_wisun_socket_id_t) sockid, // socket id
&wisun_addr->sin6_addr.s6_addr, // IPv6 address structure pointer
wisun_addr->sin6_port); // port number
if (stat == SL_STATUS_OK) { // if the stack call return OK, add address struct
socket_handler_set_sockaddr(sockhnd, addr, (uint8_t)addrlen);
}
__CHECK_FOR_STATUS(stat);
return _check_status(stat, RETVAL_OK, EINVAL);
// External socket
case AF_INET:
case AF_INET6:
return _external_bind(sockid, addr, addrlen);
default:
_set_errno_ret_error(EINVAL);
}
} | /* Bind a name to a socket */ | Bind a name to a socket | [
"Bind",
"a",
"name",
"to",
"a",
"socket"
] | int32_t bind(int32_t sockid, const struct sockaddr *addr, socklen_t addrlen)
{
sl_status_t stat = SL_STATUS_FAIL;
const wisun_addr_t *wisun_addr = NULL;
_socket_handler_t *sockhnd = NULL;
sockhnd = socket_handler_get(sockid);
if (sockhnd == NULL) {
_set_errno_ret_error(EINVAL);
}
switch (sockhnd->_domain) {
case AF_WISUN:
if (addr == NULL || addrlen != sizeof(wisun_addr_t)
|| addr->sa_family != AF_WISUN) {
_set_errno_ret_error(EINVAL);
}
wisun_addr = (const wisun_addr_t *)addr;
stat = sl_wisun_bind_socket((sl_wisun_socket_id_t) sockid,
&wisun_addr->sin6_addr.s6_addr,
wisun_addr->sin6_port);
if (stat == SL_STATUS_OK) {
socket_handler_set_sockaddr(sockhnd, addr, (uint8_t)addrlen);
}
__CHECK_FOR_STATUS(stat);
return _check_status(stat, RETVAL_OK, EINVAL);
case AF_INET:
case AF_INET6:
return _external_bind(sockid, addr, addrlen);
default:
_set_errno_ret_error(EINVAL);
}
} | [
"int32_t",
"bind",
"(",
"int32_t",
"sockid",
",",
"const",
"struct",
"sockaddr",
"*",
"addr",
",",
"socklen_t",
"addrlen",
")",
"{",
"sl_status_t",
"stat",
"=",
"SL_STATUS_FAIL",
";",
"const",
"wisun_addr_t",
"*",
"wisun_addr",
"=",
"NULL",
";",
"_socket_handler_t",
"*",
"sockhnd",
"=",
"NULL",
";",
"sockhnd",
"=",
"socket_handler_get",
"(",
"sockid",
")",
";",
"if",
"(",
"sockhnd",
"==",
"NULL",
")",
"{",
"_set_errno_ret_error",
"(",
"EINVAL",
")",
";",
"}",
"switch",
"(",
"sockhnd",
"->",
"_domain",
")",
"{",
"case",
"AF_WISUN",
":",
"if",
"(",
"addr",
"==",
"NULL",
"||",
"addrlen",
"!=",
"sizeof",
"(",
"wisun_addr_t",
")",
"||",
"addr",
"->",
"sa_family",
"!=",
"AF_WISUN",
")",
"{",
"_set_errno_ret_error",
"(",
"EINVAL",
")",
";",
"}",
"wisun_addr",
"=",
"(",
"const",
"wisun_addr_t",
"*",
")",
"addr",
";",
"stat",
"=",
"sl_wisun_bind_socket",
"(",
"(",
"sl_wisun_socket_id_t",
")",
"sockid",
",",
"&",
"wisun_addr",
"->",
"sin6_addr",
".",
"s6_addr",
",",
"wisun_addr",
"->",
"sin6_port",
")",
";",
"if",
"(",
"stat",
"==",
"SL_STATUS_OK",
")",
"{",
"socket_handler_set_sockaddr",
"(",
"sockhnd",
",",
"addr",
",",
"(",
"uint8_t",
")",
"addrlen",
")",
";",
"}",
"__CHECK_FOR_STATUS",
"(",
"stat",
")",
";",
"return",
"_check_status",
"(",
"stat",
",",
"RETVAL_OK",
",",
"EINVAL",
")",
";",
"case",
"AF_INET",
":",
"case",
"AF_INET6",
":",
"return",
"_external_bind",
"(",
"sockid",
",",
"addr",
",",
"addrlen",
")",
";",
"default",
":",
"_set_errno_ret_error",
"(",
"EINVAL",
")",
";",
"}",
"}"
] | Bind a name to a socket | [
"Bind",
"a",
"name",
"to",
"a",
"socket"
] | [
"// Get socket handler",
"// tried to bind addresss to non existing socket id",
"// cast address to wisun address",
"// socket id",
"// IPv6 address structure pointer",
"// port number",
"// if the stack call return OK, add address struct",
"// External socket"
] | [
{
"param": "sockid",
"type": "int32_t"
},
{
"param": "addr",
"type": "struct sockaddr"
},
{
"param": "addrlen",
"type": "socklen_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sockid",
"type": "int32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "struct sockaddr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrlen",
"type": "socklen_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e6528efa0a6a1bd7810836da4b6213b013fbfb64 | SiliconLabs/Gecko_SDK | app/wisun/component/socket/socket.c | [
"Zlib"
] | C | inet_pton | int32_t | int32_t inet_pton(sock_domain_t af, const char *src, void *dst)
{
bool ipv6_res = false;
uint8_t len;
const char *p;
switch (af) {
case AF_WISUN:
case AF_INET6:
for (p = src, len = 0; *p; ++p, ++len) {
;
}
ipv6_res = sl_wisun_stoip6(src, len, dst); // convert address text to binary for wisun and ipv6
return ipv6_res ? 1 : -1; // 1: success, -1: error
case AF_INET:
(void) 0;
default:
_set_errno_ret_error(EINVAL);
}
} | /*convert IPv4 and IPv6 addresses from text to binary form*/ | convert IPv4 and IPv6 addresses from text to binary form | [
"convert",
"IPv4",
"and",
"IPv6",
"addresses",
"from",
"text",
"to",
"binary",
"form"
] | int32_t inet_pton(sock_domain_t af, const char *src, void *dst)
{
bool ipv6_res = false;
uint8_t len;
const char *p;
switch (af) {
case AF_WISUN:
case AF_INET6:
for (p = src, len = 0; *p; ++p, ++len) {
;
}
ipv6_res = sl_wisun_stoip6(src, len, dst);
return ipv6_res ? 1 : -1;
case AF_INET:
(void) 0;
default:
_set_errno_ret_error(EINVAL);
}
} | [
"int32_t",
"inet_pton",
"(",
"sock_domain_t",
"af",
",",
"const",
"char",
"*",
"src",
",",
"void",
"*",
"dst",
")",
"{",
"bool",
"ipv6_res",
"=",
"false",
";",
"uint8_t",
"len",
";",
"const",
"char",
"*",
"p",
";",
"switch",
"(",
"af",
")",
"{",
"case",
"AF_WISUN",
":",
"case",
"AF_INET6",
":",
"for",
"(",
"p",
"=",
"src",
",",
"len",
"=",
"0",
";",
"*",
"p",
";",
"++",
"p",
",",
"++",
"len",
")",
"{",
";",
"}",
"ipv6_res",
"=",
"sl_wisun_stoip6",
"(",
"src",
",",
"len",
",",
"dst",
")",
";",
"return",
"ipv6_res",
"?",
"1",
":",
"-1",
";",
"case",
"AF_INET",
":",
"(",
"void",
")",
"0",
";",
"default",
":",
"_set_errno_ret_error",
"(",
"EINVAL",
")",
";",
"}",
"}"
] | convert IPv4 and IPv6 addresses from text to binary form | [
"convert",
"IPv4",
"and",
"IPv6",
"addresses",
"from",
"text",
"to",
"binary",
"form"
] | [
"// convert address text to binary for wisun and ipv6",
"// 1: success, -1: error"
] | [
{
"param": "af",
"type": "sock_domain_t"
},
{
"param": "src",
"type": "char"
},
{
"param": "dst",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "af",
"type": "sock_domain_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dst",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e6528efa0a6a1bd7810836da4b6213b013fbfb64 | SiliconLabs/Gecko_SDK | app/wisun/component/socket/socket.c | [
"Zlib"
] | C | inet_ntop | char | const char *inet_ntop(sock_domain_t af, const void *src, char *dst, socklen_t size)
{
bool ipv6_res = false;
switch (af) {
case AF_WISUN:
case AF_INET6:
(void) size;
ipv6_res = sl_wisun_ip6tos(src, dst); // convert address binary to text for wisun and ipv6
return ipv6_res ? dst : NULL; // dst: success, NULL: error
case AF_INET:
(void) 0;
default:
_set_errno(EINVAL);
return NULL;
}
} | /*convert IPv4 and IPv6 addresses from binary to text form*/ | convert IPv4 and IPv6 addresses from binary to text form | [
"convert",
"IPv4",
"and",
"IPv6",
"addresses",
"from",
"binary",
"to",
"text",
"form"
] | const char *inet_ntop(sock_domain_t af, const void *src, char *dst, socklen_t size)
{
bool ipv6_res = false;
switch (af) {
case AF_WISUN:
case AF_INET6:
(void) size;
ipv6_res = sl_wisun_ip6tos(src, dst);
return ipv6_res ? dst : NULL;
case AF_INET:
(void) 0;
default:
_set_errno(EINVAL);
return NULL;
}
} | [
"const",
"char",
"*",
"inet_ntop",
"(",
"sock_domain_t",
"af",
",",
"const",
"void",
"*",
"src",
",",
"char",
"*",
"dst",
",",
"socklen_t",
"size",
")",
"{",
"bool",
"ipv6_res",
"=",
"false",
";",
"switch",
"(",
"af",
")",
"{",
"case",
"AF_WISUN",
":",
"case",
"AF_INET6",
":",
"(",
"void",
")",
"size",
";",
"ipv6_res",
"=",
"sl_wisun_ip6tos",
"(",
"src",
",",
"dst",
")",
";",
"return",
"ipv6_res",
"?",
"dst",
":",
"NULL",
";",
"case",
"AF_INET",
":",
"(",
"void",
")",
"0",
";",
"default",
":",
"_set_errno",
"(",
"EINVAL",
")",
";",
"return",
"NULL",
";",
"}",
"}"
] | convert IPv4 and IPv6 addresses from binary to text form | [
"convert",
"IPv4",
"and",
"IPv6",
"addresses",
"from",
"binary",
"to",
"text",
"form"
] | [
"// convert address binary to text for wisun and ipv6",
"// dst: success, NULL: error"
] | [
{
"param": "af",
"type": "sock_domain_t"
},
{
"param": "src",
"type": "void"
},
{
"param": "dst",
"type": "char"
},
{
"param": "size",
"type": "socklen_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "af",
"type": "sock_domain_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dst",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "socklen_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | writeInvolveTCBit | void | static void writeInvolveTCBit(void)
{
// Proceed with processing the involveTC
uint8_t gpsSecurityLevelAttribute = 0;
uint8_t type;
EmberAfStatus secLevelStatus = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
sizeof(uint8_t),
&type);
if (secLevelStatus != EMBER_ZCL_STATUS_SUCCESS) {
return; // No security Level attribute ? Don't proceed
}
emberAfGreenPowerClusterPrintln("");
emberAfGreenPowerClusterPrint("GPS in ");
// Find the security state of the node to examine the network security.
EmberCurrentSecurityState securityState;
// Distributed network - return with out any change to InvolveTc bit
if (emberGetCurrentSecurityState(&securityState) == EMBER_SUCCESS
&& (securityState.bitmask & EMBER_DISTRIBUTED_TRUST_CENTER_MODE)) {
emberAfGreenPowerClusterPrint("Distributed Network");
// reset the InvolveTC bit
gpsSecurityLevelAttribute &= ~(GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC);
} else {
// If centralised - checkif default TC link key is used
const EmberKeyData linkKey = { GP_DEFAULT_LINK_KEY };
EmberKeyStruct keyStruct;
EmberStatus keyReadStatus = emberGetKey(EMBER_TRUST_CENTER_LINK_KEY, &keyStruct);
if (keyReadStatus == EMBER_SUCCESS
&& MEMCOMPARE(keyStruct.key.contents, linkKey.contents, EMBER_ENCRYPTION_KEY_SIZE)) {
emberAfGreenPowerClusterPrint("Centralised Network : Non Default TC Key used - Set InvoveTc bit");
// Set the InvolveTC bit
gpsSecurityLevelAttribute |= GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC;
}
}
emberAfGreenPowerClusterPrintln("");
secLevelStatus = emberAfWriteAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
type);
emberAfGreenPowerClusterPrintln("Security Level writen = %d, Status = %d",
gpsSecurityLevelAttribute,
secLevelStatus);
} | // Writes the TCInvolved bit - this should only be called on first joining of the node. | Writes the TCInvolved bit - this should only be called on first joining of the node. | [
"Writes",
"the",
"TCInvolved",
"bit",
"-",
"this",
"should",
"only",
"be",
"called",
"on",
"first",
"joining",
"of",
"the",
"node",
"."
] | static void writeInvolveTCBit(void)
{
uint8_t gpsSecurityLevelAttribute = 0;
uint8_t type;
EmberAfStatus secLevelStatus = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
sizeof(uint8_t),
&type);
if (secLevelStatus != EMBER_ZCL_STATUS_SUCCESS) {
return;
}
emberAfGreenPowerClusterPrintln("");
emberAfGreenPowerClusterPrint("GPS in ");
EmberCurrentSecurityState securityState;
if (emberGetCurrentSecurityState(&securityState) == EMBER_SUCCESS
&& (securityState.bitmask & EMBER_DISTRIBUTED_TRUST_CENTER_MODE)) {
emberAfGreenPowerClusterPrint("Distributed Network");
gpsSecurityLevelAttribute &= ~(GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC);
} else {
const EmberKeyData linkKey = { GP_DEFAULT_LINK_KEY };
EmberKeyStruct keyStruct;
EmberStatus keyReadStatus = emberGetKey(EMBER_TRUST_CENTER_LINK_KEY, &keyStruct);
if (keyReadStatus == EMBER_SUCCESS
&& MEMCOMPARE(keyStruct.key.contents, linkKey.contents, EMBER_ENCRYPTION_KEY_SIZE)) {
emberAfGreenPowerClusterPrint("Centralised Network : Non Default TC Key used - Set InvoveTc bit");
gpsSecurityLevelAttribute |= GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC;
}
}
emberAfGreenPowerClusterPrintln("");
secLevelStatus = emberAfWriteAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
type);
emberAfGreenPowerClusterPrintln("Security Level writen = %d, Status = %d",
gpsSecurityLevelAttribute,
secLevelStatus);
} | [
"static",
"void",
"writeInvolveTCBit",
"(",
"void",
")",
"{",
"uint8_t",
"gpsSecurityLevelAttribute",
"=",
"0",
";",
"uint8_t",
"type",
";",
"EmberAfStatus",
"secLevelStatus",
"=",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID",
",",
"(",
"CLUSTER_MASK_SERVER",
")",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsSecurityLevelAttribute",
",",
"sizeof",
"(",
"uint8_t",
")",
",",
"&",
"type",
")",
";",
"if",
"(",
"secLevelStatus",
"!=",
"EMBER_ZCL_STATUS_SUCCESS",
")",
"{",
"return",
";",
"}",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
")",
";",
"emberAfGreenPowerClusterPrint",
"(",
"\"",
"\"",
")",
";",
"EmberCurrentSecurityState",
"securityState",
";",
"if",
"(",
"emberGetCurrentSecurityState",
"(",
"&",
"securityState",
")",
"==",
"EMBER_SUCCESS",
"&&",
"(",
"securityState",
".",
"bitmask",
"&",
"EMBER_DISTRIBUTED_TRUST_CENTER_MODE",
")",
")",
"{",
"emberAfGreenPowerClusterPrint",
"(",
"\"",
"\"",
")",
";",
"gpsSecurityLevelAttribute",
"&=",
"~",
"(",
"GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC",
")",
";",
"}",
"else",
"{",
"const",
"EmberKeyData",
"linkKey",
"=",
"{",
"GP_DEFAULT_LINK_KEY",
"}",
";",
"EmberKeyStruct",
"keyStruct",
";",
"EmberStatus",
"keyReadStatus",
"=",
"emberGetKey",
"(",
"EMBER_TRUST_CENTER_LINK_KEY",
",",
"&",
"keyStruct",
")",
";",
"if",
"(",
"keyReadStatus",
"==",
"EMBER_SUCCESS",
"&&",
"MEMCOMPARE",
"(",
"keyStruct",
".",
"key",
".",
"contents",
",",
"linkKey",
".",
"contents",
",",
"EMBER_ENCRYPTION_KEY_SIZE",
")",
")",
"{",
"emberAfGreenPowerClusterPrint",
"(",
"\"",
"\"",
")",
";",
"gpsSecurityLevelAttribute",
"|=",
"GREEN_POWER_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_FIELD_INVOLVE_TC",
";",
"}",
"}",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
")",
";",
"secLevelStatus",
"=",
"emberAfWriteAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID",
",",
"(",
"CLUSTER_MASK_SERVER",
")",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsSecurityLevelAttribute",
",",
"type",
")",
";",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
",",
"gpsSecurityLevelAttribute",
",",
"secLevelStatus",
")",
";",
"}"
] | Writes the TCInvolved bit - this should only be called on first joining of the node. | [
"Writes",
"the",
"TCInvolved",
"bit",
"-",
"this",
"should",
"only",
"be",
"called",
"on",
"first",
"joining",
"of",
"the",
"node",
"."
] | [
"// Proceed with processing the involveTC",
"// No security Level attribute ? Don't proceed",
"// Find the security state of the node to examine the network security.",
"// Distributed network - return with out any change to InvolveTc bit",
"// reset the InvolveTC bit",
"// If centralised - checkif default TC link key is used",
"// Set the InvolveTC bit"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | clearGpsStateInToken | void | static void clearGpsStateInToken(void)
{
#if (EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS == 1) && !defined(EZSP_HOST)
GpsNetworkState gpsNodeState = GREEN_POWER_SERVER_GPS_NODE_STATE_NOT_IN_NETWORK;
halCommonSetToken(TOKEN_GPS_NETWORK_STATE, &gpsNodeState);
#endif
} | // Update the GPS Node state in non volatile token | Update the GPS Node state in non volatile token | [
"Update",
"the",
"GPS",
"Node",
"state",
"in",
"non",
"volatile",
"token"
] | static void clearGpsStateInToken(void)
{
#if (EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS == 1) && !defined(EZSP_HOST)
GpsNetworkState gpsNodeState = GREEN_POWER_SERVER_GPS_NODE_STATE_NOT_IN_NETWORK;
halCommonSetToken(TOKEN_GPS_NETWORK_STATE, &gpsNodeState);
#endif
} | [
"static",
"void",
"clearGpsStateInToken",
"(",
"void",
")",
"{",
"#if",
"(",
"EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS",
"==",
"1",
")",
"&&",
"!",
"defined",
"(",
"EZSP_HOST",
")",
"\n",
"GpsNetworkState",
"gpsNodeState",
"=",
"GREEN_POWER_SERVER_GPS_NODE_STATE_NOT_IN_NETWORK",
";",
"halCommonSetToken",
"(",
"TOKEN_GPS_NETWORK_STATE",
",",
"&",
"gpsNodeState",
")",
";",
"#endif",
"}"
] | Update the GPS Node state in non volatile token | [
"Update",
"the",
"GPS",
"Node",
"state",
"in",
"non",
"volatile",
"token"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | updateInvolveTCNeeded | bool | static bool updateInvolveTCNeeded(void)
{
#if (EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS == 1) && !defined(EZSP_HOST)
GpsNetworkState gpsNodeState;
halCommonGetToken(&gpsNodeState, TOKEN_GPS_NETWORK_STATE);
if (gpsNodeState == GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK) {
return false;
} else {
gpsNodeState = GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK;
halCommonSetToken(TOKEN_GPS_NETWORK_STATE, &gpsNodeState);
}
return true;
#else
return false;
#endif
} | // Checks if the node is just joined checking from the tokens | Checks if the node is just joined checking from the tokens | [
"Checks",
"if",
"the",
"node",
"is",
"just",
"joined",
"checking",
"from",
"the",
"tokens"
] | static bool updateInvolveTCNeeded(void)
{
#if (EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS == 1) && !defined(EZSP_HOST)
GpsNetworkState gpsNodeState;
halCommonGetToken(&gpsNodeState, TOKEN_GPS_NETWORK_STATE);
if (gpsNodeState == GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK) {
return false;
} else {
gpsNodeState = GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK;
halCommonSetToken(TOKEN_GPS_NETWORK_STATE, &gpsNodeState);
}
return true;
#else
return false;
#endif
} | [
"static",
"bool",
"updateInvolveTCNeeded",
"(",
"void",
")",
"{",
"#if",
"(",
"EMBER_AF_PLUGIN_GREEN_POWER_SERVER_USE_TOKENS",
"==",
"1",
")",
"&&",
"!",
"defined",
"(",
"EZSP_HOST",
")",
"\n",
"GpsNetworkState",
"gpsNodeState",
";",
"halCommonGetToken",
"(",
"&",
"gpsNodeState",
",",
"TOKEN_GPS_NETWORK_STATE",
")",
";",
"if",
"(",
"gpsNodeState",
"==",
"GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"gpsNodeState",
"=",
"GREEN_POWER_SERVER_GPS_NODE_STATE_IN_NETWORK",
";",
"halCommonSetToken",
"(",
"TOKEN_GPS_NETWORK_STATE",
",",
"&",
"gpsNodeState",
")",
";",
"}",
"return",
"true",
";",
"#else",
"return",
"false",
";",
"#endif",
"}"
] | Checks if the node is just joined checking from the tokens | [
"Checks",
"if",
"the",
"node",
"is",
"just",
"joined",
"checking",
"from",
"the",
"tokens"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | updateInvolveTC | void | static void updateInvolveTC(EmberStatus status)
{
// Pre process network status to decide if a InvolveTC is needed
if (status == EMBER_NETWORK_DOWN
&& emberStackIsPerformingRejoin() == FALSE) {
clearGpsStateInToken();
return;
} else if (status == EMBER_NETWORK_UP) {
if (!updateInvolveTCNeeded()) {
return;
}
writeInvolveTCBit();
}
} | // Process the update based on statck state | Process the update based on statck state | [
"Process",
"the",
"update",
"based",
"on",
"statck",
"state"
] | static void updateInvolveTC(EmberStatus status)
{
if (status == EMBER_NETWORK_DOWN
&& emberStackIsPerformingRejoin() == FALSE) {
clearGpsStateInToken();
return;
} else if (status == EMBER_NETWORK_UP) {
if (!updateInvolveTCNeeded()) {
return;
}
writeInvolveTCBit();
}
} | [
"static",
"void",
"updateInvolveTC",
"(",
"EmberStatus",
"status",
")",
"{",
"if",
"(",
"status",
"==",
"EMBER_NETWORK_DOWN",
"&&",
"emberStackIsPerformingRejoin",
"(",
")",
"==",
"FALSE",
")",
"{",
"clearGpsStateInToken",
"(",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"status",
"==",
"EMBER_NETWORK_UP",
")",
"{",
"if",
"(",
"!",
"updateInvolveTCNeeded",
"(",
")",
")",
"{",
"return",
";",
"}",
"writeInvolveTCBit",
"(",
")",
";",
"}",
"}"
] | Process the update based on statck state | [
"Process",
"the",
"update",
"based",
"on",
"statck",
"state"
] | [
"// Pre process network status to decide if a InvolveTC is needed"
] | [
{
"param": "status",
"type": "EmberStatus"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "status",
"type": "EmberStatus",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | findGroupInBindingTable | uint8_t | static uint8_t findGroupInBindingTable(uint8_t endpoint, uint16_t groupId)
{
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_MULTICAST_BINDING
&& binding.identifier[0] == LOW_BYTE(groupId)
&& binding.identifier[1] == HIGH_BYTE(groupId)
&& binding.local == endpoint) {
return i;
}
}
return 0xFF;
} | // Internal functions used to maintain the group table within the context
// of the binding table.
//
// In the binding:
// The first two bytes of the identifier is set to the groupId
// The local endpoint is set to the endpoint that is mapped to this group | Internal functions used to maintain the group table within the context
of the binding table.
In the binding:
The first two bytes of the identifier is set to the groupId
The local endpoint is set to the endpoint that is mapped to this group | [
"Internal",
"functions",
"used",
"to",
"maintain",
"the",
"group",
"table",
"within",
"the",
"context",
"of",
"the",
"binding",
"table",
".",
"In",
"the",
"binding",
":",
"The",
"first",
"two",
"bytes",
"of",
"the",
"identifier",
"is",
"set",
"to",
"the",
"groupId",
"The",
"local",
"endpoint",
"is",
"set",
"to",
"the",
"endpoint",
"that",
"is",
"mapped",
"to",
"this",
"group"
] | static uint8_t findGroupInBindingTable(uint8_t endpoint, uint16_t groupId)
{
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_MULTICAST_BINDING
&& binding.identifier[0] == LOW_BYTE(groupId)
&& binding.identifier[1] == HIGH_BYTE(groupId)
&& binding.local == endpoint) {
return i;
}
}
return 0xFF;
} | [
"static",
"uint8_t",
"findGroupInBindingTable",
"(",
"uint8_t",
"endpoint",
",",
"uint16_t",
"groupId",
")",
"{",
"for",
"(",
"uint8_t",
"i",
"=",
"0",
";",
"i",
"<",
"EMBER_BINDING_TABLE_SIZE",
";",
"i",
"++",
")",
"{",
"EmberBindingTableEntry",
"binding",
";",
"if",
"(",
"emberGetBinding",
"(",
"i",
",",
"&",
"binding",
")",
"==",
"EMBER_SUCCESS",
"&&",
"binding",
".",
"type",
"==",
"EMBER_MULTICAST_BINDING",
"&&",
"binding",
".",
"identifier",
"[",
"0",
"]",
"==",
"LOW_BYTE",
"(",
"groupId",
")",
"&&",
"binding",
".",
"identifier",
"[",
"1",
"]",
"==",
"HIGH_BYTE",
"(",
"groupId",
")",
"&&",
"binding",
".",
"local",
"==",
"endpoint",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"0xFF",
";",
"}"
] | Internal functions used to maintain the group table within the context
of the binding table. | [
"Internal",
"functions",
"used",
"to",
"maintain",
"the",
"group",
"table",
"within",
"the",
"context",
"of",
"the",
"binding",
"table",
"."
] | [] | [
{
"param": "endpoint",
"type": "uint8_t"
},
{
"param": "groupId",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "endpoint",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "groupId",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | findAppEndpointGroupId | uint16_t | static uint16_t findAppEndpointGroupId(uint8_t endpoint)
{
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_MULTICAST_BINDING
&& binding.local == endpoint) {
uint16_t groupId = (binding.identifier[1] << 8) | binding.identifier[0];
return groupId;
}
}
return 0;
} | // Finds and returns the Gp Controlable application endpoint in the APS group | Finds and returns the Gp Controlable application endpoint in the APS group | [
"Finds",
"and",
"returns",
"the",
"Gp",
"Controlable",
"application",
"endpoint",
"in",
"the",
"APS",
"group"
] | static uint16_t findAppEndpointGroupId(uint8_t endpoint)
{
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_MULTICAST_BINDING
&& binding.local == endpoint) {
uint16_t groupId = (binding.identifier[1] << 8) | binding.identifier[0];
return groupId;
}
}
return 0;
} | [
"static",
"uint16_t",
"findAppEndpointGroupId",
"(",
"uint8_t",
"endpoint",
")",
"{",
"for",
"(",
"uint8_t",
"i",
"=",
"0",
";",
"i",
"<",
"EMBER_BINDING_TABLE_SIZE",
";",
"i",
"++",
")",
"{",
"EmberBindingTableEntry",
"binding",
";",
"if",
"(",
"emberGetBinding",
"(",
"i",
",",
"&",
"binding",
")",
"==",
"EMBER_SUCCESS",
"&&",
"binding",
".",
"type",
"==",
"EMBER_MULTICAST_BINDING",
"&&",
"binding",
".",
"local",
"==",
"endpoint",
")",
"{",
"uint16_t",
"groupId",
"=",
"(",
"binding",
".",
"identifier",
"[",
"1",
"]",
"<<",
"8",
")",
"|",
"binding",
".",
"identifier",
"[",
"0",
"]",
";",
"return",
"groupId",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Finds and returns the Gp Controlable application endpoint in the APS group | [
"Finds",
"and",
"returns",
"the",
"Gp",
"Controlable",
"application",
"endpoint",
"in",
"the",
"APS",
"group"
] | [] | [
{
"param": "endpoint",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "endpoint",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emGpCheckCommunicationModeSupport | bool | static bool emGpCheckCommunicationModeSupport(uint8_t communicationModeToCheck)
{
uint32_t gpsFuntionnalityAttribut = 0;
uint32_t gpsActiveFunctionnalityAttribut = 0;
EmberAfAttributeType type;
emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_FUNCTIONALITY_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsFuntionnalityAttribut,
sizeof(uint32_t),
&type);
emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_ACTIVE_FUNCTIONALITY_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsActiveFunctionnalityAttribut,
sizeof(uint32_t),
&type);
uint32_t currentFunctionnalities = (gpsFuntionnalityAttribut & gpsActiveFunctionnalityAttribut);
if ((communicationModeToCheck == EMBER_GP_SINK_TYPE_FULL_UNICAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_FULL_UNICAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_D_GROUPCAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_DERIVED_GROUPCAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_GROUPCAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_PRE_COMMISSIONED_GROUPCAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_LW_UNICAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_LIGHTWEIGHT_UNICAST_COMMUNICATION))) {
return true;
}
return false;
} | //function return true if the param_in communication mode is supported by the sink | function return true if the param_in communication mode is supported by the sink | [
"function",
"return",
"true",
"if",
"the",
"param_in",
"communication",
"mode",
"is",
"supported",
"by",
"the",
"sink"
] | static bool emGpCheckCommunicationModeSupport(uint8_t communicationModeToCheck)
{
uint32_t gpsFuntionnalityAttribut = 0;
uint32_t gpsActiveFunctionnalityAttribut = 0;
EmberAfAttributeType type;
emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_FUNCTIONALITY_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsFuntionnalityAttribut,
sizeof(uint32_t),
&type);
emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_ACTIVE_FUNCTIONALITY_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsActiveFunctionnalityAttribut,
sizeof(uint32_t),
&type);
uint32_t currentFunctionnalities = (gpsFuntionnalityAttribut & gpsActiveFunctionnalityAttribut);
if ((communicationModeToCheck == EMBER_GP_SINK_TYPE_FULL_UNICAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_FULL_UNICAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_D_GROUPCAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_DERIVED_GROUPCAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_GROUPCAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_PRE_COMMISSIONED_GROUPCAST_COMMUNICATION))
|| (communicationModeToCheck == EMBER_GP_SINK_TYPE_LW_UNICAST
&& (currentFunctionnalities & EMBER_AF_GP_GPS_FUNCTIONALITY_LIGHTWEIGHT_UNICAST_COMMUNICATION))) {
return true;
}
return false;
} | [
"static",
"bool",
"emGpCheckCommunicationModeSupport",
"(",
"uint8_t",
"communicationModeToCheck",
")",
"{",
"uint32_t",
"gpsFuntionnalityAttribut",
"=",
"0",
";",
"uint32_t",
"gpsActiveFunctionnalityAttribut",
"=",
"0",
";",
"EmberAfAttributeType",
"type",
";",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_FUNCTIONALITY_ATTRIBUTE_ID",
",",
"CLUSTER_MASK_SERVER",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsFuntionnalityAttribut",
",",
"sizeof",
"(",
"uint32_t",
")",
",",
"&",
"type",
")",
";",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_ACTIVE_FUNCTIONALITY_ATTRIBUTE_ID",
",",
"(",
"CLUSTER_MASK_SERVER",
")",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsActiveFunctionnalityAttribut",
",",
"sizeof",
"(",
"uint32_t",
")",
",",
"&",
"type",
")",
";",
"uint32_t",
"currentFunctionnalities",
"=",
"(",
"gpsFuntionnalityAttribut",
"&",
"gpsActiveFunctionnalityAttribut",
")",
";",
"if",
"(",
"(",
"communicationModeToCheck",
"==",
"EMBER_GP_SINK_TYPE_FULL_UNICAST",
"&&",
"(",
"currentFunctionnalities",
"&",
"EMBER_AF_GP_GPS_FUNCTIONALITY_FULL_UNICAST_COMMUNICATION",
")",
")",
"||",
"(",
"communicationModeToCheck",
"==",
"EMBER_GP_SINK_TYPE_D_GROUPCAST",
"&&",
"(",
"currentFunctionnalities",
"&",
"EMBER_AF_GP_GPS_FUNCTIONALITY_DERIVED_GROUPCAST_COMMUNICATION",
")",
")",
"||",
"(",
"communicationModeToCheck",
"==",
"EMBER_GP_SINK_TYPE_GROUPCAST",
"&&",
"(",
"currentFunctionnalities",
"&",
"EMBER_AF_GP_GPS_FUNCTIONALITY_PRE_COMMISSIONED_GROUPCAST_COMMUNICATION",
")",
")",
"||",
"(",
"communicationModeToCheck",
"==",
"EMBER_GP_SINK_TYPE_LW_UNICAST",
"&&",
"(",
"currentFunctionnalities",
"&",
"EMBER_AF_GP_GPS_FUNCTIONALITY_LIGHTWEIGHT_UNICAST_COMMUNICATION",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | function return true if the param_in communication mode is supported by the sink | [
"function",
"return",
"true",
"if",
"the",
"param_in",
"communication",
"mode",
"is",
"supported",
"by",
"the",
"sink"
] | [] | [
{
"param": "communicationModeToCheck",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "communicationModeToCheck",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | formGpdCommandListFromIncommingCommReq | uint8_t | static uint8_t formGpdCommandListFromIncommingCommReq(uint8_t gpdDeviceId,
uint8_t *inGpdCommandList,
uint8_t inCommandListLength,
uint8_t *gpdCommandList)
{
uint8_t gpdCommandListLength = 0;
// if there is already a command list present in incoming payload copy that
// Realign A0-A3 as AF if TT compacting is enabled and filter out duplicate AF
bool foundAlready = false;
for (int i = 0; i < inCommandListLength; i++) {
if (inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_ATTRIBUTE_REPORTING
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MULTI_CLUSTER_RPTG
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MFR_SP_ATTR_RPTG
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MFR_SP_MULTI_CLUSTER_RPTG) {
if (!foundAlready) {
foundAlready = true;
gpdCommandList[gpdCommandListLength++] = EMBER_ZCL_GP_GPDF_ANY_GPD_SENSOR_CMD;
}
} else {
gpdCommandList[gpdCommandListLength++] = inGpdCommandList[i];
}
}
//Now extend the command list for the device id, take out the duplicate if any
if (gpdDeviceId != 0xFE) {
// look up the device Id derive the commands if there is no commands supplied
if (gpdCommandListLength == 0) {
gpdCommandListLength += emGetCommandListFromDeviceIdLookup(gpdDeviceId,
gpdCommandList);
}
}
return gpdCommandListLength;
} | // Builds a list of all the gpd commands from incoming commissioning req | Builds a list of all the gpd commands from incoming commissioning req | [
"Builds",
"a",
"list",
"of",
"all",
"the",
"gpd",
"commands",
"from",
"incoming",
"commissioning",
"req"
] | static uint8_t formGpdCommandListFromIncommingCommReq(uint8_t gpdDeviceId,
uint8_t *inGpdCommandList,
uint8_t inCommandListLength,
uint8_t *gpdCommandList)
{
uint8_t gpdCommandListLength = 0;
bool foundAlready = false;
for (int i = 0; i < inCommandListLength; i++) {
if (inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_ATTRIBUTE_REPORTING
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MULTI_CLUSTER_RPTG
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MFR_SP_ATTR_RPTG
|| inGpdCommandList[i] == EMBER_ZCL_GP_GPDF_MFR_SP_MULTI_CLUSTER_RPTG) {
if (!foundAlready) {
foundAlready = true;
gpdCommandList[gpdCommandListLength++] = EMBER_ZCL_GP_GPDF_ANY_GPD_SENSOR_CMD;
}
} else {
gpdCommandList[gpdCommandListLength++] = inGpdCommandList[i];
}
}
if (gpdDeviceId != 0xFE) {
if (gpdCommandListLength == 0) {
gpdCommandListLength += emGetCommandListFromDeviceIdLookup(gpdDeviceId,
gpdCommandList);
}
}
return gpdCommandListLength;
} | [
"static",
"uint8_t",
"formGpdCommandListFromIncommingCommReq",
"(",
"uint8_t",
"gpdDeviceId",
",",
"uint8_t",
"*",
"inGpdCommandList",
",",
"uint8_t",
"inCommandListLength",
",",
"uint8_t",
"*",
"gpdCommandList",
")",
"{",
"uint8_t",
"gpdCommandListLength",
"=",
"0",
";",
"bool",
"foundAlready",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"inCommandListLength",
";",
"i",
"++",
")",
"{",
"if",
"(",
"inGpdCommandList",
"[",
"i",
"]",
"==",
"EMBER_ZCL_GP_GPDF_ATTRIBUTE_REPORTING",
"||",
"inGpdCommandList",
"[",
"i",
"]",
"==",
"EMBER_ZCL_GP_GPDF_MULTI_CLUSTER_RPTG",
"||",
"inGpdCommandList",
"[",
"i",
"]",
"==",
"EMBER_ZCL_GP_GPDF_MFR_SP_ATTR_RPTG",
"||",
"inGpdCommandList",
"[",
"i",
"]",
"==",
"EMBER_ZCL_GP_GPDF_MFR_SP_MULTI_CLUSTER_RPTG",
")",
"{",
"if",
"(",
"!",
"foundAlready",
")",
"{",
"foundAlready",
"=",
"true",
";",
"gpdCommandList",
"[",
"gpdCommandListLength",
"++",
"]",
"=",
"EMBER_ZCL_GP_GPDF_ANY_GPD_SENSOR_CMD",
";",
"}",
"}",
"else",
"{",
"gpdCommandList",
"[",
"gpdCommandListLength",
"++",
"]",
"=",
"inGpdCommandList",
"[",
"i",
"]",
";",
"}",
"}",
"if",
"(",
"gpdDeviceId",
"!=",
"0xFE",
")",
"{",
"if",
"(",
"gpdCommandListLength",
"==",
"0",
")",
"{",
"gpdCommandListLength",
"+=",
"emGetCommandListFromDeviceIdLookup",
"(",
"gpdDeviceId",
",",
"gpdCommandList",
")",
";",
"}",
"}",
"return",
"gpdCommandListLength",
";",
"}"
] | Builds a list of all the gpd commands from incoming commissioning req | [
"Builds",
"a",
"list",
"of",
"all",
"the",
"gpd",
"commands",
"from",
"incoming",
"commissioning",
"req"
] | [
"// if there is already a command list present in incoming payload copy that",
"// Realign A0-A3 as AF if TT compacting is enabled and filter out duplicate AF",
"//Now extend the command list for the device id, take out the duplicate if any",
"// look up the device Id derive the commands if there is no commands supplied"
] | [
{
"param": "gpdDeviceId",
"type": "uint8_t"
},
{
"param": "inGpdCommandList",
"type": "uint8_t"
},
{
"param": "inCommandListLength",
"type": "uint8_t"
},
{
"param": "gpdCommandList",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpdDeviceId",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inGpdCommandList",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inCommandListLength",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandList",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | buildSinkSupportedClusterEndPointListForGpdCommands | uint8_t | static uint8_t buildSinkSupportedClusterEndPointListForGpdCommands(uint8_t numberOfPairedEndpoints,
uint8_t *pairedEndpoints,
uint8_t numberOfClusters,
ZigbeeCluster *clusterList,
SupportedGpdCommandClusterEndpointMap *gpdCommandClusterEpMap)
{
//for (int i = 0; i < numberOfClusters; i++) {
// emberAfGreenPowerClusterPrint("clusterList[%d] = %x ", i, clusterList[i]);
//}
//emberAfGreenPowerClusterPrintln("");
uint8_t tempEndpointsOnSink[MAX_ENDPOINT_COUNT] = { 0 };
uint8_t tempSupportedEndpointCount = 0;
if (numberOfPairedEndpoints == GREEN_POWER_SERVER_NO_PAIRED_ENDPOINTS
|| numberOfPairedEndpoints == GREEN_POWER_SERVER_RESERVED_ENDPOINTS) {
// The target endpoint for validation is the Current commissioning Ep
tempSupportedEndpointCount = getGpCommissioningEndpoint(tempEndpointsOnSink);
} else if (numberOfPairedEndpoints == GREEN_POWER_SERVER_SINK_DERIVES_ENDPOINTS
|| numberOfPairedEndpoints == GREEN_POWER_SERVER_ALL_SINK_ENDPOINTS) {
tempSupportedEndpointCount = getAllSinkEndpoints(tempEndpointsOnSink);
} else {
for (int i = 0; i < MAX_ENDPOINT_COUNT; i++) {
for (int j = 0; j < numberOfPairedEndpoints; j++) {
emberAfGreenPowerClusterPrintln("Checking PairedEp[%d]=%x with SinkEp = %d ",
j, pairedEndpoints[j], emAfEndpoints[i].endpoint);
if (pairedEndpoints[j] == emAfEndpoints[i].endpoint) {
tempEndpointsOnSink[tempSupportedEndpointCount] = emAfEndpoints[i].endpoint;
tempSupportedEndpointCount++;
// Found, so break inner loop
// - this is ensure the temp endpoint list is sorted without duplicate
break;
}
}
}
}
// Here, the endpoints are filtered, those, only are supported out of input paired
// endpoint list - run through all the clusters for each end point to filter
// (endpoint, cluster) pair that is supported.
uint8_t count = 0;
for (int i = 0; i < tempSupportedEndpointCount; i++) {
for (int j = 0; j < numberOfClusters; j++) {
if (0xFFFF != clusterList[j].clusterId) {
if (emGpEndpointAndClusterIdValidation(tempEndpointsOnSink[i],
clusterList[j].serverClient,
clusterList[j].clusterId)) {
gpdCommandClusterEpMap->endpoints[count] = tempEndpointsOnSink[i];
count++;
break;
}
}
}
}
noOfCommissionedEndpoints = 0;
gpdCommandClusterEpMap->numberOfEndpoints = 0;
if (count <= MAX_ENDPOINT_COUNT) {
gpdCommandClusterEpMap->numberOfEndpoints = count;
noOfCommissionedEndpoints = count;
MEMCOPY(commissionedEndPoints, gpdCommandClusterEpMap->endpoints, count);
}
return count;
} | // resolves and relates endpoint - cluster from the given the number of paired endpoints
// cluster list (present in application info and appl description) | resolves and relates endpoint - cluster from the given the number of paired endpoints
cluster list (present in application info and appl description) | [
"resolves",
"and",
"relates",
"endpoint",
"-",
"cluster",
"from",
"the",
"given",
"the",
"number",
"of",
"paired",
"endpoints",
"cluster",
"list",
"(",
"present",
"in",
"application",
"info",
"and",
"appl",
"description",
")"
] | static uint8_t buildSinkSupportedClusterEndPointListForGpdCommands(uint8_t numberOfPairedEndpoints,
uint8_t *pairedEndpoints,
uint8_t numberOfClusters,
ZigbeeCluster *clusterList,
SupportedGpdCommandClusterEndpointMap *gpdCommandClusterEpMap)
{
uint8_t tempEndpointsOnSink[MAX_ENDPOINT_COUNT] = { 0 };
uint8_t tempSupportedEndpointCount = 0;
if (numberOfPairedEndpoints == GREEN_POWER_SERVER_NO_PAIRED_ENDPOINTS
|| numberOfPairedEndpoints == GREEN_POWER_SERVER_RESERVED_ENDPOINTS) {
tempSupportedEndpointCount = getGpCommissioningEndpoint(tempEndpointsOnSink);
} else if (numberOfPairedEndpoints == GREEN_POWER_SERVER_SINK_DERIVES_ENDPOINTS
|| numberOfPairedEndpoints == GREEN_POWER_SERVER_ALL_SINK_ENDPOINTS) {
tempSupportedEndpointCount = getAllSinkEndpoints(tempEndpointsOnSink);
} else {
for (int i = 0; i < MAX_ENDPOINT_COUNT; i++) {
for (int j = 0; j < numberOfPairedEndpoints; j++) {
emberAfGreenPowerClusterPrintln("Checking PairedEp[%d]=%x with SinkEp = %d ",
j, pairedEndpoints[j], emAfEndpoints[i].endpoint);
if (pairedEndpoints[j] == emAfEndpoints[i].endpoint) {
tempEndpointsOnSink[tempSupportedEndpointCount] = emAfEndpoints[i].endpoint;
tempSupportedEndpointCount++;
break;
}
}
}
}
uint8_t count = 0;
for (int i = 0; i < tempSupportedEndpointCount; i++) {
for (int j = 0; j < numberOfClusters; j++) {
if (0xFFFF != clusterList[j].clusterId) {
if (emGpEndpointAndClusterIdValidation(tempEndpointsOnSink[i],
clusterList[j].serverClient,
clusterList[j].clusterId)) {
gpdCommandClusterEpMap->endpoints[count] = tempEndpointsOnSink[i];
count++;
break;
}
}
}
}
noOfCommissionedEndpoints = 0;
gpdCommandClusterEpMap->numberOfEndpoints = 0;
if (count <= MAX_ENDPOINT_COUNT) {
gpdCommandClusterEpMap->numberOfEndpoints = count;
noOfCommissionedEndpoints = count;
MEMCOPY(commissionedEndPoints, gpdCommandClusterEpMap->endpoints, count);
}
return count;
} | [
"static",
"uint8_t",
"buildSinkSupportedClusterEndPointListForGpdCommands",
"(",
"uint8_t",
"numberOfPairedEndpoints",
",",
"uint8_t",
"*",
"pairedEndpoints",
",",
"uint8_t",
"numberOfClusters",
",",
"ZigbeeCluster",
"*",
"clusterList",
",",
"SupportedGpdCommandClusterEndpointMap",
"*",
"gpdCommandClusterEpMap",
")",
"{",
"uint8_t",
"tempEndpointsOnSink",
"[",
"MAX_ENDPOINT_COUNT",
"]",
"=",
"{",
"0",
"}",
";",
"uint8_t",
"tempSupportedEndpointCount",
"=",
"0",
";",
"if",
"(",
"numberOfPairedEndpoints",
"==",
"GREEN_POWER_SERVER_NO_PAIRED_ENDPOINTS",
"||",
"numberOfPairedEndpoints",
"==",
"GREEN_POWER_SERVER_RESERVED_ENDPOINTS",
")",
"{",
"tempSupportedEndpointCount",
"=",
"getGpCommissioningEndpoint",
"(",
"tempEndpointsOnSink",
")",
";",
"}",
"else",
"if",
"(",
"numberOfPairedEndpoints",
"==",
"GREEN_POWER_SERVER_SINK_DERIVES_ENDPOINTS",
"||",
"numberOfPairedEndpoints",
"==",
"GREEN_POWER_SERVER_ALL_SINK_ENDPOINTS",
")",
"{",
"tempSupportedEndpointCount",
"=",
"getAllSinkEndpoints",
"(",
"tempEndpointsOnSink",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_ENDPOINT_COUNT",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numberOfPairedEndpoints",
";",
"j",
"++",
")",
"{",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
",",
"j",
",",
"pairedEndpoints",
"[",
"j",
"]",
",",
"emAfEndpoints",
"[",
"i",
"]",
".",
"endpoint",
")",
";",
"if",
"(",
"pairedEndpoints",
"[",
"j",
"]",
"==",
"emAfEndpoints",
"[",
"i",
"]",
".",
"endpoint",
")",
"{",
"tempEndpointsOnSink",
"[",
"tempSupportedEndpointCount",
"]",
"=",
"emAfEndpoints",
"[",
"i",
"]",
".",
"endpoint",
";",
"tempSupportedEndpointCount",
"++",
";",
"break",
";",
"}",
"}",
"}",
"}",
"uint8_t",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tempSupportedEndpointCount",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numberOfClusters",
";",
"j",
"++",
")",
"{",
"if",
"(",
"0xFFFF",
"!=",
"clusterList",
"[",
"j",
"]",
".",
"clusterId",
")",
"{",
"if",
"(",
"emGpEndpointAndClusterIdValidation",
"(",
"tempEndpointsOnSink",
"[",
"i",
"]",
",",
"clusterList",
"[",
"j",
"]",
".",
"serverClient",
",",
"clusterList",
"[",
"j",
"]",
".",
"clusterId",
")",
")",
"{",
"gpdCommandClusterEpMap",
"->",
"endpoints",
"[",
"count",
"]",
"=",
"tempEndpointsOnSink",
"[",
"i",
"]",
";",
"count",
"++",
";",
"break",
";",
"}",
"}",
"}",
"}",
"noOfCommissionedEndpoints",
"=",
"0",
";",
"gpdCommandClusterEpMap",
"->",
"numberOfEndpoints",
"=",
"0",
";",
"if",
"(",
"count",
"<=",
"MAX_ENDPOINT_COUNT",
")",
"{",
"gpdCommandClusterEpMap",
"->",
"numberOfEndpoints",
"=",
"count",
";",
"noOfCommissionedEndpoints",
"=",
"count",
";",
"MEMCOPY",
"(",
"commissionedEndPoints",
",",
"gpdCommandClusterEpMap",
"->",
"endpoints",
",",
"count",
")",
";",
"}",
"return",
"count",
";",
"}"
] | resolves and relates endpoint - cluster from the given the number of paired endpoints
cluster list (present in application info and appl description) | [
"resolves",
"and",
"relates",
"endpoint",
"-",
"cluster",
"from",
"the",
"given",
"the",
"number",
"of",
"paired",
"endpoints",
"cluster",
"list",
"(",
"present",
"in",
"application",
"info",
"and",
"appl",
"description",
")"
] | [
"//for (int i = 0; i < numberOfClusters; i++) {",
"// emberAfGreenPowerClusterPrint(\"clusterList[%d] = %x \", i, clusterList[i]);",
"//}",
"//emberAfGreenPowerClusterPrintln(\"\");",
"// The target endpoint for validation is the Current commissioning Ep",
"// Found, so break inner loop",
"// - this is ensure the temp endpoint list is sorted without duplicate",
"// Here, the endpoints are filtered, those, only are supported out of input paired",
"// endpoint list - run through all the clusters for each end point to filter",
"// (endpoint, cluster) pair that is supported."
] | [
{
"param": "numberOfPairedEndpoints",
"type": "uint8_t"
},
{
"param": "pairedEndpoints",
"type": "uint8_t"
},
{
"param": "numberOfClusters",
"type": "uint8_t"
},
{
"param": "clusterList",
"type": "ZigbeeCluster"
},
{
"param": "gpdCommandClusterEpMap",
"type": "SupportedGpdCommandClusterEndpointMap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "numberOfPairedEndpoints",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pairedEndpoints",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numberOfClusters",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clusterList",
"type": "ZigbeeCluster",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandClusterEpMap",
"type": "SupportedGpdCommandClusterEndpointMap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | validateGpdCommandSupportOnSink | uint8_t | static uint8_t validateGpdCommandSupportOnSink(uint8_t *gpdCommandList,
uint8_t gpdCommandListLength,
EmberGpApplicationInfo *applicationInfo,
SupportedGpdCommandClusterEndpointMap *gpdCommandClusterEpMap,
GpCommDataSaved *commissioningGpd)
{
uint8_t validatedCommands = 0;
for (int commandIndex = 0; commandIndex < gpdCommandListLength; commandIndex++) {
// First see if it is switch command - validate it else do rest of
// the command validation
if (validateSwitchCommand(&validatedCommands,
commandIndex,
gpdCommandList[commandIndex],
applicationInfo,
gpdCommandClusterEpMap,
commissioningGpd)) {
} else if (validateCARCommand(&validatedCommands,
commandIndex,
gpdCommandList[commandIndex],
applicationInfo,
gpdCommandClusterEpMap,
commissioningGpd)) {
} else {
// default sub translation table has the (gpdCommnd<->ClusterId) mapping,
// use the look up to decide when the mapped clusterId = 0xFFFF, then it
// need to use the cluster list from the incoming message payload.
// pick up clusters to validate against the supplied pair of end points
// and available endpoints in sink;
gpdCommandClusterEpMap[commandIndex].gpdCommand = gpdCommandList[commandIndex];
// Prepare a cluster list that will be input for next level
uint8_t noOfClusters = 0;
ZigbeeCluster cluster[30] = { 0 };
if ((applicationInfo->numberOfGpdClientCluster != 0)
|| (applicationInfo->numberOfGpdServerCluster != 0)) {
// Now a generic cluster - read, write, reporting etc
// many clusters are in for the command
// prepare a list of all the clusters in the incoming message
// pick from appInfo
for (int i = 0; i < applicationInfo->numberOfGpdClientCluster; i++) {
cluster[noOfClusters].clusterId = applicationInfo->clientClusters[i];
cluster[noOfClusters].serverClient = 1; // reverse for the match
noOfClusters++;
}
for (int i = 0; i < applicationInfo->numberOfGpdServerCluster; i++) {
cluster[noOfClusters].clusterId = applicationInfo->serverClusters[i];
cluster[noOfClusters].serverClient = 0; // reverse for the match
noOfClusters++;
}
} else {
ZigbeeCluster gpdCluster;
if (!emGetClusterListFromCmdIdLookup(gpdCommandList[commandIndex],
&gpdCluster)) {
continue;
}
// Apend the cluster found in the TT (default or customised) if available
if (0xFFFF != gpdCluster.clusterId) {
cluster[noOfClusters].clusterId = gpdCluster.clusterId;
cluster[noOfClusters].serverClient = gpdCluster.serverClient;
noOfClusters += 1;
} else {
// Now, get the list of clusters from the device Id if the cluster associated with this
// command in the translation table is reserved.
noOfClusters += emGetClusterListFromDeviceIdLookup(applicationInfo->deviceId,
&cluster[noOfClusters]);
}
}
uint8_t endpointCount = 0;
endpointCount = buildSinkSupportedClusterEndPointListForGpdCommands(applicationInfo->numberOfPairedEndpoints,
applicationInfo->pairedEndpoints,
noOfClusters,
cluster,
&gpdCommandClusterEpMap[commandIndex]);
if (endpointCount) {
validatedCommands += 1;
}
}
}
return validatedCommands;
} | // final list of mapping of gpdCommand-Cluster-EndpointList that is supported | final list of mapping of gpdCommand-Cluster-EndpointList that is supported | [
"final",
"list",
"of",
"mapping",
"of",
"gpdCommand",
"-",
"Cluster",
"-",
"EndpointList",
"that",
"is",
"supported"
] | static uint8_t validateGpdCommandSupportOnSink(uint8_t *gpdCommandList,
uint8_t gpdCommandListLength,
EmberGpApplicationInfo *applicationInfo,
SupportedGpdCommandClusterEndpointMap *gpdCommandClusterEpMap,
GpCommDataSaved *commissioningGpd)
{
uint8_t validatedCommands = 0;
for (int commandIndex = 0; commandIndex < gpdCommandListLength; commandIndex++) {
if (validateSwitchCommand(&validatedCommands,
commandIndex,
gpdCommandList[commandIndex],
applicationInfo,
gpdCommandClusterEpMap,
commissioningGpd)) {
} else if (validateCARCommand(&validatedCommands,
commandIndex,
gpdCommandList[commandIndex],
applicationInfo,
gpdCommandClusterEpMap,
commissioningGpd)) {
} else {
gpdCommandClusterEpMap[commandIndex].gpdCommand = gpdCommandList[commandIndex];
uint8_t noOfClusters = 0;
ZigbeeCluster cluster[30] = { 0 };
if ((applicationInfo->numberOfGpdClientCluster != 0)
|| (applicationInfo->numberOfGpdServerCluster != 0)) {
for (int i = 0; i < applicationInfo->numberOfGpdClientCluster; i++) {
cluster[noOfClusters].clusterId = applicationInfo->clientClusters[i];
cluster[noOfClusters].serverClient = 1;
noOfClusters++;
}
for (int i = 0; i < applicationInfo->numberOfGpdServerCluster; i++) {
cluster[noOfClusters].clusterId = applicationInfo->serverClusters[i];
cluster[noOfClusters].serverClient = 0;
noOfClusters++;
}
} else {
ZigbeeCluster gpdCluster;
if (!emGetClusterListFromCmdIdLookup(gpdCommandList[commandIndex],
&gpdCluster)) {
continue;
}
if (0xFFFF != gpdCluster.clusterId) {
cluster[noOfClusters].clusterId = gpdCluster.clusterId;
cluster[noOfClusters].serverClient = gpdCluster.serverClient;
noOfClusters += 1;
} else {
noOfClusters += emGetClusterListFromDeviceIdLookup(applicationInfo->deviceId,
&cluster[noOfClusters]);
}
}
uint8_t endpointCount = 0;
endpointCount = buildSinkSupportedClusterEndPointListForGpdCommands(applicationInfo->numberOfPairedEndpoints,
applicationInfo->pairedEndpoints,
noOfClusters,
cluster,
&gpdCommandClusterEpMap[commandIndex]);
if (endpointCount) {
validatedCommands += 1;
}
}
}
return validatedCommands;
} | [
"static",
"uint8_t",
"validateGpdCommandSupportOnSink",
"(",
"uint8_t",
"*",
"gpdCommandList",
",",
"uint8_t",
"gpdCommandListLength",
",",
"EmberGpApplicationInfo",
"*",
"applicationInfo",
",",
"SupportedGpdCommandClusterEndpointMap",
"*",
"gpdCommandClusterEpMap",
",",
"GpCommDataSaved",
"*",
"commissioningGpd",
")",
"{",
"uint8_t",
"validatedCommands",
"=",
"0",
";",
"for",
"(",
"int",
"commandIndex",
"=",
"0",
";",
"commandIndex",
"<",
"gpdCommandListLength",
";",
"commandIndex",
"++",
")",
"{",
"if",
"(",
"validateSwitchCommand",
"(",
"&",
"validatedCommands",
",",
"commandIndex",
",",
"gpdCommandList",
"[",
"commandIndex",
"]",
",",
"applicationInfo",
",",
"gpdCommandClusterEpMap",
",",
"commissioningGpd",
")",
")",
"{",
"}",
"else",
"if",
"(",
"validateCARCommand",
"(",
"&",
"validatedCommands",
",",
"commandIndex",
",",
"gpdCommandList",
"[",
"commandIndex",
"]",
",",
"applicationInfo",
",",
"gpdCommandClusterEpMap",
",",
"commissioningGpd",
")",
")",
"{",
"}",
"else",
"{",
"gpdCommandClusterEpMap",
"[",
"commandIndex",
"]",
".",
"gpdCommand",
"=",
"gpdCommandList",
"[",
"commandIndex",
"]",
";",
"uint8_t",
"noOfClusters",
"=",
"0",
";",
"ZigbeeCluster",
"cluster",
"[",
"30",
"]",
"=",
"{",
"0",
"}",
";",
"if",
"(",
"(",
"applicationInfo",
"->",
"numberOfGpdClientCluster",
"!=",
"0",
")",
"||",
"(",
"applicationInfo",
"->",
"numberOfGpdServerCluster",
"!=",
"0",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"applicationInfo",
"->",
"numberOfGpdClientCluster",
";",
"i",
"++",
")",
"{",
"cluster",
"[",
"noOfClusters",
"]",
".",
"clusterId",
"=",
"applicationInfo",
"->",
"clientClusters",
"[",
"i",
"]",
";",
"cluster",
"[",
"noOfClusters",
"]",
".",
"serverClient",
"=",
"1",
";",
"noOfClusters",
"++",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"applicationInfo",
"->",
"numberOfGpdServerCluster",
";",
"i",
"++",
")",
"{",
"cluster",
"[",
"noOfClusters",
"]",
".",
"clusterId",
"=",
"applicationInfo",
"->",
"serverClusters",
"[",
"i",
"]",
";",
"cluster",
"[",
"noOfClusters",
"]",
".",
"serverClient",
"=",
"0",
";",
"noOfClusters",
"++",
";",
"}",
"}",
"else",
"{",
"ZigbeeCluster",
"gpdCluster",
";",
"if",
"(",
"!",
"emGetClusterListFromCmdIdLookup",
"(",
"gpdCommandList",
"[",
"commandIndex",
"]",
",",
"&",
"gpdCluster",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"0xFFFF",
"!=",
"gpdCluster",
".",
"clusterId",
")",
"{",
"cluster",
"[",
"noOfClusters",
"]",
".",
"clusterId",
"=",
"gpdCluster",
".",
"clusterId",
";",
"cluster",
"[",
"noOfClusters",
"]",
".",
"serverClient",
"=",
"gpdCluster",
".",
"serverClient",
";",
"noOfClusters",
"+=",
"1",
";",
"}",
"else",
"{",
"noOfClusters",
"+=",
"emGetClusterListFromDeviceIdLookup",
"(",
"applicationInfo",
"->",
"deviceId",
",",
"&",
"cluster",
"[",
"noOfClusters",
"]",
")",
";",
"}",
"}",
"uint8_t",
"endpointCount",
"=",
"0",
";",
"endpointCount",
"=",
"buildSinkSupportedClusterEndPointListForGpdCommands",
"(",
"applicationInfo",
"->",
"numberOfPairedEndpoints",
",",
"applicationInfo",
"->",
"pairedEndpoints",
",",
"noOfClusters",
",",
"cluster",
",",
"&",
"gpdCommandClusterEpMap",
"[",
"commandIndex",
"]",
")",
";",
"if",
"(",
"endpointCount",
")",
"{",
"validatedCommands",
"+=",
"1",
";",
"}",
"}",
"}",
"return",
"validatedCommands",
";",
"}"
] | final list of mapping of gpdCommand-Cluster-EndpointList that is supported | [
"final",
"list",
"of",
"mapping",
"of",
"gpdCommand",
"-",
"Cluster",
"-",
"EndpointList",
"that",
"is",
"supported"
] | [
"// First see if it is switch command - validate it else do rest of",
"// the command validation",
"// default sub translation table has the (gpdCommnd<->ClusterId) mapping,",
"// use the look up to decide when the mapped clusterId = 0xFFFF, then it",
"// need to use the cluster list from the incoming message payload.",
"// pick up clusters to validate against the supplied pair of end points",
"// and available endpoints in sink;",
"// Prepare a cluster list that will be input for next level",
"// Now a generic cluster - read, write, reporting etc",
"// many clusters are in for the command",
"// prepare a list of all the clusters in the incoming message",
"// pick from appInfo",
"// reverse for the match",
"// reverse for the match",
"// Apend the cluster found in the TT (default or customised) if available",
"// Now, get the list of clusters from the device Id if the cluster associated with this",
"// command in the translation table is reserved."
] | [
{
"param": "gpdCommandList",
"type": "uint8_t"
},
{
"param": "gpdCommandListLength",
"type": "uint8_t"
},
{
"param": "applicationInfo",
"type": "EmberGpApplicationInfo"
},
{
"param": "gpdCommandClusterEpMap",
"type": "SupportedGpdCommandClusterEndpointMap"
},
{
"param": "commissioningGpd",
"type": "GpCommDataSaved"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpdCommandList",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandListLength",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "applicationInfo",
"type": "EmberGpApplicationInfo",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandClusterEpMap",
"type": "SupportedGpdCommandClusterEndpointMap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commissioningGpd",
"type": "GpCommDataSaved",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emGpAddToApsGroup | EmberAfStatus | EmberAfStatus emGpAddToApsGroup(uint8_t endpoint, uint16_t groupId)
{
if (0xFF != findGroupInBindingTable(endpoint, groupId)) {
// search returned an valid index, so duplicate exists
return EMBER_ZCL_STATUS_SUCCESS; // per ZCL8; was DUPLICATE_EXISTS
}
// No duplicate entry, try adding
// Look for an empty binding slot.
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_UNUSED_BINDING) {
binding.type = EMBER_MULTICAST_BINDING;
binding.identifier[0] = LOW_BYTE(groupId);
binding.identifier[1] = HIGH_BYTE(groupId);
binding.local = endpoint;
EmberStatus status = emberSetBinding(i, &binding);
if (status == EMBER_SUCCESS) {
return EMBER_ZCL_STATUS_SUCCESS;
} else {
emberAfCorePrintln("ERR: Failed to create binding (0x%x)", status);
return EMBER_ZCL_STATUS_FAILURE;
}
}
}
emberAfCorePrintln("ERR: Binding table is full");
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
} | // Add the endpoint to APS group with GroupId | Add the endpoint to APS group with GroupId | [
"Add",
"the",
"endpoint",
"to",
"APS",
"group",
"with",
"GroupId"
] | EmberAfStatus emGpAddToApsGroup(uint8_t endpoint, uint16_t groupId)
{
if (0xFF != findGroupInBindingTable(endpoint, groupId)) {
return EMBER_ZCL_STATUS_SUCCESS;
}
for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
EmberBindingTableEntry binding;
if (emberGetBinding(i, &binding) == EMBER_SUCCESS
&& binding.type == EMBER_UNUSED_BINDING) {
binding.type = EMBER_MULTICAST_BINDING;
binding.identifier[0] = LOW_BYTE(groupId);
binding.identifier[1] = HIGH_BYTE(groupId);
binding.local = endpoint;
EmberStatus status = emberSetBinding(i, &binding);
if (status == EMBER_SUCCESS) {
return EMBER_ZCL_STATUS_SUCCESS;
} else {
emberAfCorePrintln("ERR: Failed to create binding (0x%x)", status);
return EMBER_ZCL_STATUS_FAILURE;
}
}
}
emberAfCorePrintln("ERR: Binding table is full");
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
} | [
"EmberAfStatus",
"emGpAddToApsGroup",
"(",
"uint8_t",
"endpoint",
",",
"uint16_t",
"groupId",
")",
"{",
"if",
"(",
"0xFF",
"!=",
"findGroupInBindingTable",
"(",
"endpoint",
",",
"groupId",
")",
")",
"{",
"return",
"EMBER_ZCL_STATUS_SUCCESS",
";",
"}",
"for",
"(",
"uint8_t",
"i",
"=",
"0",
";",
"i",
"<",
"EMBER_BINDING_TABLE_SIZE",
";",
"i",
"++",
")",
"{",
"EmberBindingTableEntry",
"binding",
";",
"if",
"(",
"emberGetBinding",
"(",
"i",
",",
"&",
"binding",
")",
"==",
"EMBER_SUCCESS",
"&&",
"binding",
".",
"type",
"==",
"EMBER_UNUSED_BINDING",
")",
"{",
"binding",
".",
"type",
"=",
"EMBER_MULTICAST_BINDING",
";",
"binding",
".",
"identifier",
"[",
"0",
"]",
"=",
"LOW_BYTE",
"(",
"groupId",
")",
";",
"binding",
".",
"identifier",
"[",
"1",
"]",
"=",
"HIGH_BYTE",
"(",
"groupId",
")",
";",
"binding",
".",
"local",
"=",
"endpoint",
";",
"EmberStatus",
"status",
"=",
"emberSetBinding",
"(",
"i",
",",
"&",
"binding",
")",
";",
"if",
"(",
"status",
"==",
"EMBER_SUCCESS",
")",
"{",
"return",
"EMBER_ZCL_STATUS_SUCCESS",
";",
"}",
"else",
"{",
"emberAfCorePrintln",
"(",
"\"",
"\"",
",",
"status",
")",
";",
"return",
"EMBER_ZCL_STATUS_FAILURE",
";",
"}",
"}",
"}",
"emberAfCorePrintln",
"(",
"\"",
"\"",
")",
";",
"return",
"EMBER_ZCL_STATUS_INSUFFICIENT_SPACE",
";",
"}"
] | Add the endpoint to APS group with GroupId | [
"Add",
"the",
"endpoint",
"to",
"APS",
"group",
"with",
"GroupId"
] | [
"// search returned an valid index, so duplicate exists",
"// per ZCL8; was DUPLICATE_EXISTS",
"// No duplicate entry, try adding",
"// Look for an empty binding slot."
] | [
{
"param": "endpoint",
"type": "uint8_t"
},
{
"param": "groupId",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "endpoint",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "groupId",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emberAfPluginGreenPowerServerGenericSwitchCommissioningTimeoutEventHandler | void | void emberAfPluginGreenPowerServerGenericSwitchCommissioningTimeoutEventHandler(SLXU_UC_EVENT)
{
// stop the delay
slxu_zigbee_event_set_inactive(genericSwitchCommissioningTimeout);
emberAfGreenPowerServerCommissioningTimeoutCallback(COMMISSIONING_TIMEOUT_TYPE_GENERIC_SWITCH,
noOfCommissionedEndpoints,
commissionedEndPoints);
resetOfMultisensorDataSaved(true, &gpdCommDataSaved[0]);
} | //////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Green Power Server Commissioning Event Handlers.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Switch commissioning timeout handler | Green Power Server Commissioning Event Handlers.
Switch commissioning timeout handler | [
"Green",
"Power",
"Server",
"Commissioning",
"Event",
"Handlers",
".",
"Switch",
"commissioning",
"timeout",
"handler"
] | void emberAfPluginGreenPowerServerGenericSwitchCommissioningTimeoutEventHandler(SLXU_UC_EVENT)
{
slxu_zigbee_event_set_inactive(genericSwitchCommissioningTimeout);
emberAfGreenPowerServerCommissioningTimeoutCallback(COMMISSIONING_TIMEOUT_TYPE_GENERIC_SWITCH,
noOfCommissionedEndpoints,
commissionedEndPoints);
resetOfMultisensorDataSaved(true, &gpdCommDataSaved[0]);
} | [
"void",
"emberAfPluginGreenPowerServerGenericSwitchCommissioningTimeoutEventHandler",
"(",
"SLXU_UC_EVENT",
")",
"{",
"slxu_zigbee_event_set_inactive",
"(",
"genericSwitchCommissioningTimeout",
")",
";",
"emberAfGreenPowerServerCommissioningTimeoutCallback",
"(",
"COMMISSIONING_TIMEOUT_TYPE_GENERIC_SWITCH",
",",
"noOfCommissionedEndpoints",
",",
"commissionedEndPoints",
")",
";",
"resetOfMultisensorDataSaved",
"(",
"true",
",",
"&",
"gpdCommDataSaved",
"[",
"0",
"]",
")",
";",
"}"
] | Green Power Server Commissioning Event Handlers. | [
"Green",
"Power",
"Server",
"Commissioning",
"Event",
"Handlers",
"."
] | [
"// stop the delay"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emAfPluginGreenPowerServerGpSinkCommissioningModeCommandHandler | bool | bool emAfPluginGreenPowerServerGpSinkCommissioningModeCommandHandler(uint8_t options,
uint16_t gpmAddrForSecurity,
uint16_t gpmAddrForPairing,
uint8_t sinkEndpoint)
{
// Test 4..4.6 - not a sink ep or bcast ep - drop
if (!isValidAppEndpoint(sinkEndpoint)) {
emberAfGreenPowerClusterPrintln("DROP - Comm Mode Callback: Sink EP not supported");
return false;
}
if ((options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY)
|| (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING)) {
return false;
}
EmberAfAttributeType type;
uint8_t gpsSecurityLevelAttribute = 0;
EmberAfStatus secLevelStatus = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
sizeof(uint8_t),
&type);
// Reject the req if InvolveTC is et in the attribute
if (secLevelStatus == EMBER_ZCL_STATUS_SUCCESS
&& (gpsSecurityLevelAttribute & 0x08)) {
return false;
}
uint16_t commissioningWindow = 0;
uint8_t proxyOptions = 0;
if (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_ACTION) {
commissioningState.inCommissioningMode = true;
commissioningState.endpoint = sinkEndpoint; // The commissioning endpoint can be 0xFF as well
//enter commissioning mode
if (options
& (EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY
| EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING)) {
//these SHALL be 0 for now
//TODO also check involve-TC
return false;
}
if (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_PROXIES) {
commissioningState.proxiesInvolved = true;
} else {
commissioningState.proxiesInvolved = false;
}
// default 180s of GP specification
commissioningWindow = EMBER_AF_ZCL_CLUSTER_GP_GPS_COMMISSIONING_WINDOWS_DEFAULT_TIME_S;
uint8_t gpsCommissioningExitMode;
uint16_t gpsCommissioningWindows;
EmberAfStatus statusExitMode = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_COMMISSIONING_EXIT_MODE_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsCommissioningExitMode,
sizeof(uint8_t),
&type);
EmberAfStatus statusCommWindow = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_COMMISSIONING_WINDOW_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsCommissioningWindows,
sizeof(uint16_t),
&type);
proxyOptions = EMBER_AF_GP_PROXY_COMMISSIONING_MODE_OPTION_ACTION;
// set commissioningWindow based on "gpsCommissioningWindows" attribute if different from
// commissioningWindow will be part of the frame if it is different from default 180s
// in any case there is a timeout running into the GPPs to exit,
// the default one (180s) not include or the one include in the ProxyCommMode(Enter) frame
if (statusCommWindow == EMBER_ZCL_STATUS_SUCCESS
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION)) {
commissioningWindow = gpsCommissioningWindows;
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION;
}
slxu_zigbee_event_set_delay_ms(commissioningWindowTimeout,
commissioningWindow * MILLISECOND_TICKS_PER_SECOND);
// Only one of the 2 next flag shall be set at the same time
if (statusExitMode == EMBER_ZCL_STATUS_SUCCESS
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS)
&& !(gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT)) {
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS;
} else if ((statusExitMode == EMBER_ZCL_STATUS_SUCCESS)
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT)
&& !(gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS)) {
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT;
} else {
// In case both are cleared or both are set, nothing more to do
}
} else if (commissioningState.inCommissioningMode) {
// If commissioning mode is ON and received frame set it to OFF, exit commissioning mode
commissioningState.inCommissioningMode = false;
// Deactive the timer
slxu_zigbee_event_set_inactive(commissioningWindowTimeout);
if (commissioningState.proxiesInvolved) {
//involve proxies
proxyOptions = 0;
}
}
// On commissioning entry or exist, reset the number of report config received
for (int i = 0; i < EMBER_AF_PLUGIN_GREEN_POWER_SERVER_COMMISSIONING_GPD_INSTANCES; i++) {
resetOfMultisensorDataSaved(true, &gpdCommDataSaved[i]);
}
if (commissioningState.unicastCommunication) { // based on the commission mode as decided by sink
proxyOptions |= 0x20; // Flag unicast communication
}
emberAfFillCommandGreenPowerClusterGpProxyCommissioningModeSmart(proxyOptions,
commissioningWindow,
0);
EmberApsFrame *apsFrame;
apsFrame = emberAfGetCommandApsFrame();
apsFrame->sourceEndpoint = GP_ENDPOINT;
apsFrame->destinationEndpoint = GP_ENDPOINT;
if (commissioningState.proxiesInvolved) {
EmberStatus status = emberAfSendCommandBroadcast(EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS);
// Callback to inform the status of message submission to network
emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback(&commissioningState,
apsFrame,
EMBER_OUTGOING_BROADCAST,
EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS,
status);
} else {
#ifdef SL_CATALOG_ZIGBEE_GREEN_POWER_CLIENT_PRESENT
// Put the proxy instance on this node commissioning mode so that it can accept a pairing from itself.
// This is to ensure the node will be able to handle gpdf commands after pairig.
EmberStatus status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, emberAfGetNodeId());
// Callback to inform the status of message submission to network
emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback(&commissioningState,
apsFrame,
EMBER_OUTGOING_DIRECT,
emberAfGetNodeId(),
status);
#endif // SL_CATALOG_ZIGBEE_GREEN_POWER_CLIENT_PRESENT
}
return true;
} | //////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The callbacks are called fromt he call-command-handler.c, which is an autogenerated module baased on the
// device configuration.
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | The callbacks are called fromt he call-command-handler.c, which is an autogenerated module baased on the
device configuration. | [
"The",
"callbacks",
"are",
"called",
"fromt",
"he",
"call",
"-",
"command",
"-",
"handler",
".",
"c",
"which",
"is",
"an",
"autogenerated",
"module",
"baased",
"on",
"the",
"device",
"configuration",
"."
] | bool emAfPluginGreenPowerServerGpSinkCommissioningModeCommandHandler(uint8_t options,
uint16_t gpmAddrForSecurity,
uint16_t gpmAddrForPairing,
uint8_t sinkEndpoint)
{
if (!isValidAppEndpoint(sinkEndpoint)) {
emberAfGreenPowerClusterPrintln("DROP - Comm Mode Callback: Sink EP not supported");
return false;
}
if ((options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY)
|| (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING)) {
return false;
}
EmberAfAttributeType type;
uint8_t gpsSecurityLevelAttribute = 0;
EmberAfStatus secLevelStatus = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID,
(CLUSTER_MASK_SERVER),
(uint8_t*)&gpsSecurityLevelAttribute,
sizeof(uint8_t),
&type);
if (secLevelStatus == EMBER_ZCL_STATUS_SUCCESS
&& (gpsSecurityLevelAttribute & 0x08)) {
return false;
}
uint16_t commissioningWindow = 0;
uint8_t proxyOptions = 0;
if (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_ACTION) {
commissioningState.inCommissioningMode = true;
commissioningState.endpoint = sinkEndpoint;
if (options
& (EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY
| EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING)) {
return false;
}
if (options & EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_PROXIES) {
commissioningState.proxiesInvolved = true;
} else {
commissioningState.proxiesInvolved = false;
}
commissioningWindow = EMBER_AF_ZCL_CLUSTER_GP_GPS_COMMISSIONING_WINDOWS_DEFAULT_TIME_S;
uint8_t gpsCommissioningExitMode;
uint16_t gpsCommissioningWindows;
EmberAfStatus statusExitMode = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_COMMISSIONING_EXIT_MODE_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsCommissioningExitMode,
sizeof(uint8_t),
&type);
EmberAfStatus statusCommWindow = emberAfReadAttribute(GP_ENDPOINT,
ZCL_GREEN_POWER_CLUSTER_ID,
ZCL_GP_SERVER_GPS_COMMISSIONING_WINDOW_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER,
(uint8_t*)&gpsCommissioningWindows,
sizeof(uint16_t),
&type);
proxyOptions = EMBER_AF_GP_PROXY_COMMISSIONING_MODE_OPTION_ACTION;
if (statusCommWindow == EMBER_ZCL_STATUS_SUCCESS
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION)) {
commissioningWindow = gpsCommissioningWindows;
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION;
}
slxu_zigbee_event_set_delay_ms(commissioningWindowTimeout,
commissioningWindow * MILLISECOND_TICKS_PER_SECOND);
if (statusExitMode == EMBER_ZCL_STATUS_SUCCESS
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS)
&& !(gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT)) {
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS;
} else if ((statusExitMode == EMBER_ZCL_STATUS_SUCCESS)
&& (gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT)
&& !(gpsCommissioningExitMode
& EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS)) {
proxyOptions |= EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT;
} else {
}
} else if (commissioningState.inCommissioningMode) {
commissioningState.inCommissioningMode = false;
slxu_zigbee_event_set_inactive(commissioningWindowTimeout);
if (commissioningState.proxiesInvolved) {
proxyOptions = 0;
}
}
for (int i = 0; i < EMBER_AF_PLUGIN_GREEN_POWER_SERVER_COMMISSIONING_GPD_INSTANCES; i++) {
resetOfMultisensorDataSaved(true, &gpdCommDataSaved[i]);
}
if (commissioningState.unicastCommunication) {
proxyOptions |= 0x20;
}
emberAfFillCommandGreenPowerClusterGpProxyCommissioningModeSmart(proxyOptions,
commissioningWindow,
0);
EmberApsFrame *apsFrame;
apsFrame = emberAfGetCommandApsFrame();
apsFrame->sourceEndpoint = GP_ENDPOINT;
apsFrame->destinationEndpoint = GP_ENDPOINT;
if (commissioningState.proxiesInvolved) {
EmberStatus status = emberAfSendCommandBroadcast(EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS);
emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback(&commissioningState,
apsFrame,
EMBER_OUTGOING_BROADCAST,
EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS,
status);
} else {
#ifdef SL_CATALOG_ZIGBEE_GREEN_POWER_CLIENT_PRESENT
EmberStatus status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, emberAfGetNodeId());
emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback(&commissioningState,
apsFrame,
EMBER_OUTGOING_DIRECT,
emberAfGetNodeId(),
status);
#endif
}
return true;
} | [
"bool",
"emAfPluginGreenPowerServerGpSinkCommissioningModeCommandHandler",
"(",
"uint8_t",
"options",
",",
"uint16_t",
"gpmAddrForSecurity",
",",
"uint16_t",
"gpmAddrForPairing",
",",
"uint8_t",
"sinkEndpoint",
")",
"{",
"if",
"(",
"!",
"isValidAppEndpoint",
"(",
"sinkEndpoint",
")",
")",
"{",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"options",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY",
")",
"||",
"(",
"options",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING",
")",
")",
"{",
"return",
"false",
";",
"}",
"EmberAfAttributeType",
"type",
";",
"uint8_t",
"gpsSecurityLevelAttribute",
"=",
"0",
";",
"EmberAfStatus",
"secLevelStatus",
"=",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_SECURITY_LEVEL_ATTRIBUTE_ID",
",",
"(",
"CLUSTER_MASK_SERVER",
")",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsSecurityLevelAttribute",
",",
"sizeof",
"(",
"uint8_t",
")",
",",
"&",
"type",
")",
";",
"if",
"(",
"secLevelStatus",
"==",
"EMBER_ZCL_STATUS_SUCCESS",
"&&",
"(",
"gpsSecurityLevelAttribute",
"&",
"0x08",
")",
")",
"{",
"return",
"false",
";",
"}",
"uint16_t",
"commissioningWindow",
"=",
"0",
";",
"uint8_t",
"proxyOptions",
"=",
"0",
";",
"if",
"(",
"options",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_ACTION",
")",
"{",
"commissioningState",
".",
"inCommissioningMode",
"=",
"true",
";",
"commissioningState",
".",
"endpoint",
"=",
"sinkEndpoint",
";",
"if",
"(",
"options",
"&",
"(",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_SECURITY",
"|",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_GPM_IN_PAIRING",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"options",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_OPTIONS_INVOLVE_PROXIES",
")",
"{",
"commissioningState",
".",
"proxiesInvolved",
"=",
"true",
";",
"}",
"else",
"{",
"commissioningState",
".",
"proxiesInvolved",
"=",
"false",
";",
"}",
"commissioningWindow",
"=",
"EMBER_AF_ZCL_CLUSTER_GP_GPS_COMMISSIONING_WINDOWS_DEFAULT_TIME_S",
";",
"uint8_t",
"gpsCommissioningExitMode",
";",
"uint16_t",
"gpsCommissioningWindows",
";",
"EmberAfStatus",
"statusExitMode",
"=",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_COMMISSIONING_EXIT_MODE_ATTRIBUTE_ID",
",",
"CLUSTER_MASK_SERVER",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsCommissioningExitMode",
",",
"sizeof",
"(",
"uint8_t",
")",
",",
"&",
"type",
")",
";",
"EmberAfStatus",
"statusCommWindow",
"=",
"emberAfReadAttribute",
"(",
"GP_ENDPOINT",
",",
"ZCL_GREEN_POWER_CLUSTER_ID",
",",
"ZCL_GP_SERVER_GPS_COMMISSIONING_WINDOW_ATTRIBUTE_ID",
",",
"CLUSTER_MASK_SERVER",
",",
"(",
"uint8_t",
"*",
")",
"&",
"gpsCommissioningWindows",
",",
"sizeof",
"(",
"uint16_t",
")",
",",
"&",
"type",
")",
";",
"proxyOptions",
"=",
"EMBER_AF_GP_PROXY_COMMISSIONING_MODE_OPTION_ACTION",
";",
"if",
"(",
"statusCommWindow",
"==",
"EMBER_ZCL_STATUS_SUCCESS",
"&&",
"(",
"gpsCommissioningExitMode",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION",
")",
")",
"{",
"commissioningWindow",
"=",
"gpsCommissioningWindows",
";",
"proxyOptions",
"|=",
"EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_COMMISSIONING_WINDOW_EXPIRATION",
";",
"}",
"slxu_zigbee_event_set_delay_ms",
"(",
"commissioningWindowTimeout",
",",
"commissioningWindow",
"*",
"MILLISECOND_TICKS_PER_SECOND",
")",
";",
"if",
"(",
"statusExitMode",
"==",
"EMBER_ZCL_STATUS_SUCCESS",
"&&",
"(",
"gpsCommissioningExitMode",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS",
")",
"&&",
"!",
"(",
"gpsCommissioningExitMode",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT",
")",
")",
"{",
"proxyOptions",
"|=",
"EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS",
";",
"}",
"else",
"if",
"(",
"(",
"statusExitMode",
"==",
"EMBER_ZCL_STATUS_SUCCESS",
")",
"&&",
"(",
"gpsCommissioningExitMode",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT",
")",
"&&",
"!",
"(",
"gpsCommissioningExitMode",
"&",
"EMBER_AF_GP_SINK_COMMISSIONING_MODE_EXIT_MODE_ON_FIRST_PAIRING_SUCCESS",
")",
")",
"{",
"proxyOptions",
"|=",
"EMBER_AF_GP_PROXY_COMMISSIONING_MODE_EXIT_MODE_ON_GP_PROXY_COMMISSIONING_MODE_EXIT",
";",
"}",
"else",
"{",
"}",
"}",
"else",
"if",
"(",
"commissioningState",
".",
"inCommissioningMode",
")",
"{",
"commissioningState",
".",
"inCommissioningMode",
"=",
"false",
";",
"slxu_zigbee_event_set_inactive",
"(",
"commissioningWindowTimeout",
")",
";",
"if",
"(",
"commissioningState",
".",
"proxiesInvolved",
")",
"{",
"proxyOptions",
"=",
"0",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"EMBER_AF_PLUGIN_GREEN_POWER_SERVER_COMMISSIONING_GPD_INSTANCES",
";",
"i",
"++",
")",
"{",
"resetOfMultisensorDataSaved",
"(",
"true",
",",
"&",
"gpdCommDataSaved",
"[",
"i",
"]",
")",
";",
"}",
"if",
"(",
"commissioningState",
".",
"unicastCommunication",
")",
"{",
"proxyOptions",
"|=",
"0x20",
";",
"}",
"emberAfFillCommandGreenPowerClusterGpProxyCommissioningModeSmart",
"(",
"proxyOptions",
",",
"commissioningWindow",
",",
"0",
")",
";",
"EmberApsFrame",
"*",
"apsFrame",
";",
"apsFrame",
"=",
"emberAfGetCommandApsFrame",
"(",
")",
";",
"apsFrame",
"->",
"sourceEndpoint",
"=",
"GP_ENDPOINT",
";",
"apsFrame",
"->",
"destinationEndpoint",
"=",
"GP_ENDPOINT",
";",
"if",
"(",
"commissioningState",
".",
"proxiesInvolved",
")",
"{",
"EmberStatus",
"status",
"=",
"emberAfSendCommandBroadcast",
"(",
"EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS",
")",
";",
"emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback",
"(",
"&",
"commissioningState",
",",
"apsFrame",
",",
"EMBER_OUTGOING_BROADCAST",
",",
"EMBER_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS",
",",
"status",
")",
";",
"}",
"else",
"{",
"#ifdef",
"SL_CATALOG_ZIGBEE_GREEN_POWER_CLIENT_PRESENT",
"EmberStatus",
"status",
"=",
"emberAfSendCommandUnicast",
"(",
"EMBER_OUTGOING_DIRECT",
",",
"emberAfGetNodeId",
"(",
")",
")",
";",
"emberAfGreenPowerClusterCommissioningMessageStatusNotificationCallback",
"(",
"&",
"commissioningState",
",",
"apsFrame",
",",
"EMBER_OUTGOING_DIRECT",
",",
"emberAfGetNodeId",
"(",
")",
",",
"status",
")",
";",
"#endif",
"}",
"return",
"true",
";",
"}"
] | The callbacks are called fromt he call-command-handler.c, which is an autogenerated module baased on the
device configuration. | [
"The",
"callbacks",
"are",
"called",
"fromt",
"he",
"call",
"-",
"command",
"-",
"handler",
".",
"c",
"which",
"is",
"an",
"autogenerated",
"module",
"baased",
"on",
"the",
"device",
"configuration",
"."
] | [
"// Test 4..4.6 - not a sink ep or bcast ep - drop",
"// Reject the req if InvolveTC is et in the attribute",
"// The commissioning endpoint can be 0xFF as well",
"//enter commissioning mode",
"//these SHALL be 0 for now",
"//TODO also check involve-TC",
"// default 180s of GP specification",
"// set commissioningWindow based on \"gpsCommissioningWindows\" attribute if different from",
"// commissioningWindow will be part of the frame if it is different from default 180s",
"// in any case there is a timeout running into the GPPs to exit,",
"// the default one (180s) not include or the one include in the ProxyCommMode(Enter) frame",
"// Only one of the 2 next flag shall be set at the same time",
"// In case both are cleared or both are set, nothing more to do",
"// If commissioning mode is ON and received frame set it to OFF, exit commissioning mode",
"// Deactive the timer",
"//involve proxies",
"// On commissioning entry or exist, reset the number of report config received",
"// based on the commission mode as decided by sink",
"// Flag unicast communication",
"// Callback to inform the status of message submission to network",
"// Put the proxy instance on this node commissioning mode so that it can accept a pairing from itself.",
"// This is to ensure the node will be able to handle gpdf commands after pairig.",
"// Callback to inform the status of message submission to network",
"// SL_CATALOG_ZIGBEE_GREEN_POWER_CLIENT_PRESENT"
] | [
{
"param": "options",
"type": "uint8_t"
},
{
"param": "gpmAddrForSecurity",
"type": "uint16_t"
},
{
"param": "gpmAddrForPairing",
"type": "uint16_t"
},
{
"param": "sinkEndpoint",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpmAddrForSecurity",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpmAddrForPairing",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sinkEndpoint",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emberAfGreenPowerClusterGpCommissioningNotificationCallback | bool | bool emberAfGreenPowerClusterGpCommissioningNotificationCallback(EmberAfClusterCommand *cmd)
{
sl_zcl_green_power_cluster_gp_commissioning_notification_command_t cmd_data;
if (zcl_decode_green_power_cluster_gp_commissioning_notification_command(cmd, &cmd_data)
!= EMBER_ZCL_STATUS_SUCCESS) {
return false;
}
if (!(commissioningState.inCommissioningMode)) {
emberAfGreenPowerClusterPrintln("DROP - GP CN : Sink not in commissioning!");
return true;
}
// Null ieee pointer reassignment for MISRA compliance by pointing to an ieee address with 0s.
if (cmd_data.gpdIeee == NULL) {
cmd_data.gpdIeee = nullEui64;
}
if (cmd_data.gpdCommandPayload == NULL) {
// add a 0 length ZCL OCTATE string type. 1st byte holds the length of rest of the octate string.
cmd_data.gpdCommandPayload = zeroLengthZclOctateString;
}
// Bad address with respect to application type - return back
EmberGpAddress gpdAddr;
if (!emGpMakeAddr(&gpdAddr,
(cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID),
cmd_data.gpdSrcId,
cmd_data.gpdIeee,
cmd_data.endpoint)) {
return true;
}
if (gpdAddrZero(&gpdAddr)
&& (cmd_data.gpdCommandId != EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST)) {
// Address 0 for all other GPDF commands except the channel request.
return true;
}
GpCommDataSaved *commissioningGpd = emberAfGreenPowerServerFindCommissioningGpdInstance(&gpdAddr);
// When the security processing failed sub-field is set, try validating. It can only be validated if there are
// keys sent by GPD in a previous commissioning message which will be temporary collected in the commissioningGpd
// instance.
if (cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED) {
if (commissioningGpd == NULL) {
// In this case, the commissioning notification can not be processed because:
// It is a protected message without earlier information of its security keys.
return true;
}
// Attempt to process the secure GPDF using its earlier credentials
if (commissioningGpd != NULL
&& !processCommNotificationsWithSecurityProcessingFailedFlag(cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
&cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.mic,
&(commissioningGpd->key),
commissioningGpd->securityKeyType)) {
return true;
}
}
int8_t rssi = 0;
uint8_t linkQuality = 0;
uint8_t gppDistance = 0;
if (cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX ) {
gppDistance = cmd_data.gppLink;
} else {
gppGpdLinkUnpack(cmd_data.gppLink, &rssi, &linkQuality);
}
if (emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback(cmd_data.gpdCommandId,
cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
rssi,
linkQuality,
gppDistance,
cmd_data.mic)) {
// User application handled
return true;
}
// If the Application did not handle the notification through the above callback
// The plugin handles it from here.
if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_DECOMMISSIONING) {
gpCommissioningNotificationDecommissioningGpdf(cmd_data.options,
&gpdAddr);
} else if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST) {
handleChannelRequest(cmd_data.options,
cmd_data.gppShortAddress,
((cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX) ? true : false),
cmd_data.gpdCommandPayload);
} else if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_COMMISSIONING) {
if (commissioningGpd == NULL) { // there was no previous temporary transaction, its a new GPD.
commissioningGpd = allocateCommissioningGpdInstance(&gpdAddr); // Allocate one instance if available.
if (commissioningGpd == NULL) {
return true;
}
}
gpCommissioningNotificationCommissioningGpdf(cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
commissioningGpd);
} else {
// All other commands can only be processed if they have an instance else not.
if (commissioningGpd == NULL) {
return true;
}
if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION) {
gpCommissioningNotificationApplicationDescriptionGpdf(cmd_data.options,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
commissioningGpd);
} else {
// Success or any other GPDF needs a GPD instance to be already present to proceed.
// Any valid command that can be processed should behave as success
gpCommissioningNotificationSuccessGpdf(cmd_data.options,
cmd_data.gpdSecurityFrameCounter,
commissioningGpd);
}
}
return true;
} | //Green Power Cluster Gp Commissioning Notification | Green Power Cluster Gp Commissioning Notification | [
"Green",
"Power",
"Cluster",
"Gp",
"Commissioning",
"Notification"
] | bool emberAfGreenPowerClusterGpCommissioningNotificationCallback(EmberAfClusterCommand *cmd)
{
sl_zcl_green_power_cluster_gp_commissioning_notification_command_t cmd_data;
if (zcl_decode_green_power_cluster_gp_commissioning_notification_command(cmd, &cmd_data)
!= EMBER_ZCL_STATUS_SUCCESS) {
return false;
}
if (!(commissioningState.inCommissioningMode)) {
emberAfGreenPowerClusterPrintln("DROP - GP CN : Sink not in commissioning!");
return true;
}
if (cmd_data.gpdIeee == NULL) {
cmd_data.gpdIeee = nullEui64;
}
if (cmd_data.gpdCommandPayload == NULL) {
cmd_data.gpdCommandPayload = zeroLengthZclOctateString;
}
EmberGpAddress gpdAddr;
if (!emGpMakeAddr(&gpdAddr,
(cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID),
cmd_data.gpdSrcId,
cmd_data.gpdIeee,
cmd_data.endpoint)) {
return true;
}
if (gpdAddrZero(&gpdAddr)
&& (cmd_data.gpdCommandId != EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST)) {
return true;
}
GpCommDataSaved *commissioningGpd = emberAfGreenPowerServerFindCommissioningGpdInstance(&gpdAddr);
if (cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED) {
if (commissioningGpd == NULL) {
return true;
}
if (commissioningGpd != NULL
&& !processCommNotificationsWithSecurityProcessingFailedFlag(cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
&cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.mic,
&(commissioningGpd->key),
commissioningGpd->securityKeyType)) {
return true;
}
}
int8_t rssi = 0;
uint8_t linkQuality = 0;
uint8_t gppDistance = 0;
if (cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX ) {
gppDistance = cmd_data.gppLink;
} else {
gppGpdLinkUnpack(cmd_data.gppLink, &rssi, &linkQuality);
}
if (emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback(cmd_data.gpdCommandId,
cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
rssi,
linkQuality,
gppDistance,
cmd_data.mic)) {
return true;
}
if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_DECOMMISSIONING) {
gpCommissioningNotificationDecommissioningGpdf(cmd_data.options,
&gpdAddr);
} else if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST) {
handleChannelRequest(cmd_data.options,
cmd_data.gppShortAddress,
((cmd_data.options & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX) ? true : false),
cmd_data.gpdCommandPayload);
} else if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_COMMISSIONING) {
if (commissioningGpd == NULL) {
commissioningGpd = allocateCommissioningGpdInstance(&gpdAddr);
if (commissioningGpd == NULL) {
return true;
}
}
gpCommissioningNotificationCommissioningGpdf(cmd_data.options,
&gpdAddr,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandId,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
commissioningGpd);
} else {
if (commissioningGpd == NULL) {
return true;
}
if (cmd_data.gpdCommandId == EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION) {
gpCommissioningNotificationApplicationDescriptionGpdf(cmd_data.options,
cmd_data.gpdSecurityFrameCounter,
cmd_data.gpdCommandPayload,
cmd_data.gppShortAddress,
commissioningGpd);
} else {
gpCommissioningNotificationSuccessGpdf(cmd_data.options,
cmd_data.gpdSecurityFrameCounter,
commissioningGpd);
}
}
return true;
} | [
"bool",
"emberAfGreenPowerClusterGpCommissioningNotificationCallback",
"(",
"EmberAfClusterCommand",
"*",
"cmd",
")",
"{",
"sl_zcl_green_power_cluster_gp_commissioning_notification_command_t",
"cmd_data",
";",
"if",
"(",
"zcl_decode_green_power_cluster_gp_commissioning_notification_command",
"(",
"cmd",
",",
"&",
"cmd_data",
")",
"!=",
"EMBER_ZCL_STATUS_SUCCESS",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"(",
"commissioningState",
".",
"inCommissioningMode",
")",
")",
"{",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"cmd_data",
".",
"gpdIeee",
"==",
"NULL",
")",
"{",
"cmd_data",
".",
"gpdIeee",
"=",
"nullEui64",
";",
"}",
"if",
"(",
"cmd_data",
".",
"gpdCommandPayload",
"==",
"NULL",
")",
"{",
"cmd_data",
".",
"gpdCommandPayload",
"=",
"zeroLengthZclOctateString",
";",
"}",
"EmberGpAddress",
"gpdAddr",
";",
"if",
"(",
"!",
"emGpMakeAddr",
"(",
"&",
"gpdAddr",
",",
"(",
"cmd_data",
".",
"options",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID",
")",
",",
"cmd_data",
".",
"gpdSrcId",
",",
"cmd_data",
".",
"gpdIeee",
",",
"cmd_data",
".",
"endpoint",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"gpdAddrZero",
"(",
"&",
"gpdAddr",
")",
"&&",
"(",
"cmd_data",
".",
"gpdCommandId",
"!=",
"EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST",
")",
")",
"{",
"return",
"true",
";",
"}",
"GpCommDataSaved",
"*",
"commissioningGpd",
"=",
"emberAfGreenPowerServerFindCommissioningGpdInstance",
"(",
"&",
"gpdAddr",
")",
";",
"if",
"(",
"cmd_data",
".",
"options",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED",
")",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"commissioningGpd",
"!=",
"NULL",
"&&",
"!",
"processCommNotificationsWithSecurityProcessingFailedFlag",
"(",
"cmd_data",
".",
"options",
",",
"&",
"gpdAddr",
",",
"cmd_data",
".",
"gpdSecurityFrameCounter",
",",
"&",
"cmd_data",
".",
"gpdCommandId",
",",
"cmd_data",
".",
"gpdCommandPayload",
",",
"cmd_data",
".",
"mic",
",",
"&",
"(",
"commissioningGpd",
"->",
"key",
")",
",",
"commissioningGpd",
"->",
"securityKeyType",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"int8_t",
"rssi",
"=",
"0",
";",
"uint8_t",
"linkQuality",
"=",
"0",
";",
"uint8_t",
"gppDistance",
"=",
"0",
";",
"if",
"(",
"cmd_data",
".",
"options",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX",
")",
"{",
"gppDistance",
"=",
"cmd_data",
".",
"gppLink",
";",
"}",
"else",
"{",
"gppGpdLinkUnpack",
"(",
"cmd_data",
".",
"gppLink",
",",
"&",
"rssi",
",",
"&",
"linkQuality",
")",
";",
"}",
"if",
"(",
"emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback",
"(",
"cmd_data",
".",
"gpdCommandId",
",",
"cmd_data",
".",
"options",
",",
"&",
"gpdAddr",
",",
"cmd_data",
".",
"gpdSecurityFrameCounter",
",",
"cmd_data",
".",
"gpdCommandId",
",",
"cmd_data",
".",
"gpdCommandPayload",
",",
"cmd_data",
".",
"gppShortAddress",
",",
"rssi",
",",
"linkQuality",
",",
"gppDistance",
",",
"cmd_data",
".",
"mic",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"cmd_data",
".",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_DECOMMISSIONING",
")",
"{",
"gpCommissioningNotificationDecommissioningGpdf",
"(",
"cmd_data",
".",
"options",
",",
"&",
"gpdAddr",
")",
";",
"}",
"else",
"if",
"(",
"cmd_data",
".",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST",
")",
"{",
"handleChannelRequest",
"(",
"cmd_data",
".",
"options",
",",
"cmd_data",
".",
"gppShortAddress",
",",
"(",
"(",
"cmd_data",
".",
"options",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX",
")",
"?",
"true",
":",
"false",
")",
",",
"cmd_data",
".",
"gpdCommandPayload",
")",
";",
"}",
"else",
"if",
"(",
"cmd_data",
".",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_COMMISSIONING",
")",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"commissioningGpd",
"=",
"allocateCommissioningGpdInstance",
"(",
"&",
"gpdAddr",
")",
";",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"}",
"gpCommissioningNotificationCommissioningGpdf",
"(",
"cmd_data",
".",
"options",
",",
"&",
"gpdAddr",
",",
"cmd_data",
".",
"gpdSecurityFrameCounter",
",",
"cmd_data",
".",
"gpdCommandId",
",",
"cmd_data",
".",
"gpdCommandPayload",
",",
"cmd_data",
".",
"gppShortAddress",
",",
"commissioningGpd",
")",
";",
"}",
"else",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"cmd_data",
".",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION",
")",
"{",
"gpCommissioningNotificationApplicationDescriptionGpdf",
"(",
"cmd_data",
".",
"options",
",",
"cmd_data",
".",
"gpdSecurityFrameCounter",
",",
"cmd_data",
".",
"gpdCommandPayload",
",",
"cmd_data",
".",
"gppShortAddress",
",",
"commissioningGpd",
")",
";",
"}",
"else",
"{",
"gpCommissioningNotificationSuccessGpdf",
"(",
"cmd_data",
".",
"options",
",",
"cmd_data",
".",
"gpdSecurityFrameCounter",
",",
"commissioningGpd",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Green Power Cluster Gp Commissioning Notification | [
"Green",
"Power",
"Cluster",
"Gp",
"Commissioning",
"Notification"
] | [
"// Null ieee pointer reassignment for MISRA compliance by pointing to an ieee address with 0s.",
"// add a 0 length ZCL OCTATE string type. 1st byte holds the length of rest of the octate string.",
"// Bad address with respect to application type - return back",
"// Address 0 for all other GPDF commands except the channel request.",
"// When the security processing failed sub-field is set, try validating. It can only be validated if there are",
"// keys sent by GPD in a previous commissioning message which will be temporary collected in the commissioningGpd",
"// instance.",
"// In this case, the commissioning notification can not be processed because:",
"// It is a protected message without earlier information of its security keys.",
"// Attempt to process the secure GPDF using its earlier credentials",
"// User application handled",
"// If the Application did not handle the notification through the above callback",
"// The plugin handles it from here.",
"// there was no previous temporary transaction, its a new GPD.",
"// Allocate one instance if available.",
"// All other commands can only be processed if they have an instance else not.",
"// Success or any other GPDF needs a GPD instance to be already present to proceed.",
"// Any valid command that can be processed should behave as success"
] | [
{
"param": "cmd",
"type": "EmberAfClusterCommand"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cmd",
"type": "EmberAfClusterCommand",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a725547f0dd0f2ce15cba9a6a5b8d5267e56fb9 | SiliconLabs/Gecko_SDK | protocol/zigbee/app/framework/plugin/green-power-server/green-power-server.c | [
"Zlib"
] | C | emberAfGreenPowerClusterGpCommissioningNotificationCallback | bool | bool emberAfGreenPowerClusterGpCommissioningNotificationCallback(uint16_t commNotificationOptions,
uint32_t gpdSrcId,
uint8_t *gpdIeee,
uint8_t gpdEndpoint,
uint32_t gpdSecurityFrameCounter,
uint8_t gpdCommandId,
uint8_t *gpdCommandPayload,
uint16_t gppShortAddress,
uint8_t gppLink,
uint32_t commissioningNotificationMic)
{
if (!(commissioningState.inCommissioningMode)) {
emberAfGreenPowerClusterPrintln("DROP - GP CN : Sink not in commissioning!");
return true;
}
// Null ieee pointer reassignment for MISRA compliance by pointing to an ieee address with 0s.
if (gpdIeee == NULL) {
gpdIeee = nullEui64;
}
if (gpdCommandPayload == NULL) {
// add a 0 length ZCL OCTATE string type. 1st byte holds the length of rest of the octate string.
gpdCommandPayload = zeroLengthZclOctateString;
}
// Bad address with respect to application type - return back
EmberGpAddress gpdAddr;
if (!emGpMakeAddr(&gpdAddr,
(commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID),
gpdSrcId,
gpdIeee,
gpdEndpoint)) {
return true;
}
if (gpdAddrZero(&gpdAddr)
&& (gpdCommandId != EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST)) {
// Address 0 for all other GPDF commands except the channel request.
return true;
}
GpCommDataSaved *commissioningGpd = emberAfGreenPowerServerFindCommissioningGpdInstance(&gpdAddr);
// When the security processing failed sub-field is set, try validating. It can only be validated if there are
// keys sent by GPD in a previous commissioning message which will be temporary collected in the commissioningGpd
// instance.
if (commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED) {
if (commissioningGpd == NULL) {
// In this case, the commissioning notification can not be processed because:
// It is a protected message without earlier information of its security keys.
return true;
}
// Attempt to process the secure GPDF using its earlier credentials
if (commissioningGpd != NULL
&& !processCommNotificationsWithSecurityProcessingFailedFlag(commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
&gpdCommandId,
gpdCommandPayload,
commissioningNotificationMic,
&(commissioningGpd->key),
commissioningGpd->securityKeyType)) {
return true;
}
}
int8_t rssi = 0;
uint8_t linkQuality = 0;
uint8_t gppDistance = 0;
if (commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX ) {
gppDistance = gppLink;
} else {
gppGpdLinkUnpack(gppLink, &rssi, &linkQuality);
}
if (emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback(gpdCommandId,
commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
gpdCommandId,
gpdCommandPayload,
gppShortAddress,
rssi,
linkQuality,
gppDistance,
commissioningNotificationMic)) {
// User application handled
return true;
}
// If the Application did not handle the notification through the above callback
// The plugin handles it from here.
if (gpdCommandId == EMBER_ZCL_GP_GPDF_DECOMMISSIONING) {
gpCommissioningNotificationDecommissioningGpdf(commNotificationOptions,
&gpdAddr);
} else if (gpdCommandId == EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST) {
handleChannelRequest(commNotificationOptions,
gppShortAddress,
((commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX) ? true : false),
gpdCommandPayload);
} else if (gpdCommandId == EMBER_ZCL_GP_GPDF_COMMISSIONING) {
if (commissioningGpd == NULL) { // there was no previous temporary transaction, its a new GPD.
commissioningGpd = allocateCommissioningGpdInstance(&gpdAddr); // Allocate one instance if available.
if (commissioningGpd == NULL) {
return true;
}
}
gpCommissioningNotificationCommissioningGpdf(commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
gpdCommandId,
gpdCommandPayload,
gppShortAddress,
commissioningGpd);
} else {
// All other commands can only be processed if they have an instance else not.
if (commissioningGpd == NULL) {
return true;
}
if (gpdCommandId == EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION) {
gpCommissioningNotificationApplicationDescriptionGpdf(commNotificationOptions,
gpdSecurityFrameCounter,
gpdCommandPayload,
gppShortAddress,
commissioningGpd);
} else {
// Success or any other GPDF needs a GPD instance to be already present to proceed.
// Any valid command that can be processed should behave as success
gpCommissioningNotificationSuccessGpdf(commNotificationOptions,
gpdSecurityFrameCounter,
commissioningGpd);
}
}
return true;
} | //Green Power Cluster Gp Commissioning Notification | Green Power Cluster Gp Commissioning Notification | [
"Green",
"Power",
"Cluster",
"Gp",
"Commissioning",
"Notification"
] | bool emberAfGreenPowerClusterGpCommissioningNotificationCallback(uint16_t commNotificationOptions,
uint32_t gpdSrcId,
uint8_t *gpdIeee,
uint8_t gpdEndpoint,
uint32_t gpdSecurityFrameCounter,
uint8_t gpdCommandId,
uint8_t *gpdCommandPayload,
uint16_t gppShortAddress,
uint8_t gppLink,
uint32_t commissioningNotificationMic)
{
if (!(commissioningState.inCommissioningMode)) {
emberAfGreenPowerClusterPrintln("DROP - GP CN : Sink not in commissioning!");
return true;
}
if (gpdIeee == NULL) {
gpdIeee = nullEui64;
}
if (gpdCommandPayload == NULL) {
gpdCommandPayload = zeroLengthZclOctateString;
}
EmberGpAddress gpdAddr;
if (!emGpMakeAddr(&gpdAddr,
(commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID),
gpdSrcId,
gpdIeee,
gpdEndpoint)) {
return true;
}
if (gpdAddrZero(&gpdAddr)
&& (gpdCommandId != EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST)) {
return true;
}
GpCommDataSaved *commissioningGpd = emberAfGreenPowerServerFindCommissioningGpdInstance(&gpdAddr);
if (commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED) {
if (commissioningGpd == NULL) {
return true;
}
if (commissioningGpd != NULL
&& !processCommNotificationsWithSecurityProcessingFailedFlag(commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
&gpdCommandId,
gpdCommandPayload,
commissioningNotificationMic,
&(commissioningGpd->key),
commissioningGpd->securityKeyType)) {
return true;
}
}
int8_t rssi = 0;
uint8_t linkQuality = 0;
uint8_t gppDistance = 0;
if (commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX ) {
gppDistance = gppLink;
} else {
gppGpdLinkUnpack(gppLink, &rssi, &linkQuality);
}
if (emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback(gpdCommandId,
commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
gpdCommandId,
gpdCommandPayload,
gppShortAddress,
rssi,
linkQuality,
gppDistance,
commissioningNotificationMic)) {
return true;
}
if (gpdCommandId == EMBER_ZCL_GP_GPDF_DECOMMISSIONING) {
gpCommissioningNotificationDecommissioningGpdf(commNotificationOptions,
&gpdAddr);
} else if (gpdCommandId == EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST) {
handleChannelRequest(commNotificationOptions,
gppShortAddress,
((commNotificationOptions & EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX) ? true : false),
gpdCommandPayload);
} else if (gpdCommandId == EMBER_ZCL_GP_GPDF_COMMISSIONING) {
if (commissioningGpd == NULL) {
commissioningGpd = allocateCommissioningGpdInstance(&gpdAddr);
if (commissioningGpd == NULL) {
return true;
}
}
gpCommissioningNotificationCommissioningGpdf(commNotificationOptions,
&gpdAddr,
gpdSecurityFrameCounter,
gpdCommandId,
gpdCommandPayload,
gppShortAddress,
commissioningGpd);
} else {
if (commissioningGpd == NULL) {
return true;
}
if (gpdCommandId == EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION) {
gpCommissioningNotificationApplicationDescriptionGpdf(commNotificationOptions,
gpdSecurityFrameCounter,
gpdCommandPayload,
gppShortAddress,
commissioningGpd);
} else {
gpCommissioningNotificationSuccessGpdf(commNotificationOptions,
gpdSecurityFrameCounter,
commissioningGpd);
}
}
return true;
} | [
"bool",
"emberAfGreenPowerClusterGpCommissioningNotificationCallback",
"(",
"uint16_t",
"commNotificationOptions",
",",
"uint32_t",
"gpdSrcId",
",",
"uint8_t",
"*",
"gpdIeee",
",",
"uint8_t",
"gpdEndpoint",
",",
"uint32_t",
"gpdSecurityFrameCounter",
",",
"uint8_t",
"gpdCommandId",
",",
"uint8_t",
"*",
"gpdCommandPayload",
",",
"uint16_t",
"gppShortAddress",
",",
"uint8_t",
"gppLink",
",",
"uint32_t",
"commissioningNotificationMic",
")",
"{",
"if",
"(",
"!",
"(",
"commissioningState",
".",
"inCommissioningMode",
")",
")",
"{",
"emberAfGreenPowerClusterPrintln",
"(",
"\"",
"\"",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"gpdIeee",
"==",
"NULL",
")",
"{",
"gpdIeee",
"=",
"nullEui64",
";",
"}",
"if",
"(",
"gpdCommandPayload",
"==",
"NULL",
")",
"{",
"gpdCommandPayload",
"=",
"zeroLengthZclOctateString",
";",
"}",
"EmberGpAddress",
"gpdAddr",
";",
"if",
"(",
"!",
"emGpMakeAddr",
"(",
"&",
"gpdAddr",
",",
"(",
"commNotificationOptions",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_APPLICATION_ID",
")",
",",
"gpdSrcId",
",",
"gpdIeee",
",",
"gpdEndpoint",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"gpdAddrZero",
"(",
"&",
"gpdAddr",
")",
"&&",
"(",
"gpdCommandId",
"!=",
"EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST",
")",
")",
"{",
"return",
"true",
";",
"}",
"GpCommDataSaved",
"*",
"commissioningGpd",
"=",
"emberAfGreenPowerServerFindCommissioningGpdInstance",
"(",
"&",
"gpdAddr",
")",
";",
"if",
"(",
"commNotificationOptions",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_SECURITY_PROCESSING_FAILED",
")",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"commissioningGpd",
"!=",
"NULL",
"&&",
"!",
"processCommNotificationsWithSecurityProcessingFailedFlag",
"(",
"commNotificationOptions",
",",
"&",
"gpdAddr",
",",
"gpdSecurityFrameCounter",
",",
"&",
"gpdCommandId",
",",
"gpdCommandPayload",
",",
"commissioningNotificationMic",
",",
"&",
"(",
"commissioningGpd",
"->",
"key",
")",
",",
"commissioningGpd",
"->",
"securityKeyType",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"int8_t",
"rssi",
"=",
"0",
";",
"uint8_t",
"linkQuality",
"=",
"0",
";",
"uint8_t",
"gppDistance",
"=",
"0",
";",
"if",
"(",
"commNotificationOptions",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX",
")",
"{",
"gppDistance",
"=",
"gppLink",
";",
"}",
"else",
"{",
"gppGpdLinkUnpack",
"(",
"gppLink",
",",
"&",
"rssi",
",",
"&",
"linkQuality",
")",
";",
"}",
"if",
"(",
"emberAfPluginGreenPowerServerGpdCommissioningNotificationCallback",
"(",
"gpdCommandId",
",",
"commNotificationOptions",
",",
"&",
"gpdAddr",
",",
"gpdSecurityFrameCounter",
",",
"gpdCommandId",
",",
"gpdCommandPayload",
",",
"gppShortAddress",
",",
"rssi",
",",
"linkQuality",
",",
"gppDistance",
",",
"commissioningNotificationMic",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_DECOMMISSIONING",
")",
"{",
"gpCommissioningNotificationDecommissioningGpdf",
"(",
"commNotificationOptions",
",",
"&",
"gpdAddr",
")",
";",
"}",
"else",
"if",
"(",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_CHANNEL_REQUEST",
")",
"{",
"handleChannelRequest",
"(",
"commNotificationOptions",
",",
"gppShortAddress",
",",
"(",
"(",
"commNotificationOptions",
"&",
"EMBER_AF_GP_COMMISSIONING_NOTIFICATION_OPTION_RX_AFTER_TX",
")",
"?",
"true",
":",
"false",
")",
",",
"gpdCommandPayload",
")",
";",
"}",
"else",
"if",
"(",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_COMMISSIONING",
")",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"commissioningGpd",
"=",
"allocateCommissioningGpdInstance",
"(",
"&",
"gpdAddr",
")",
";",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"}",
"gpCommissioningNotificationCommissioningGpdf",
"(",
"commNotificationOptions",
",",
"&",
"gpdAddr",
",",
"gpdSecurityFrameCounter",
",",
"gpdCommandId",
",",
"gpdCommandPayload",
",",
"gppShortAddress",
",",
"commissioningGpd",
")",
";",
"}",
"else",
"{",
"if",
"(",
"commissioningGpd",
"==",
"NULL",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"gpdCommandId",
"==",
"EMBER_ZCL_GP_GPDF_APPLICATION_DESCRIPTION",
")",
"{",
"gpCommissioningNotificationApplicationDescriptionGpdf",
"(",
"commNotificationOptions",
",",
"gpdSecurityFrameCounter",
",",
"gpdCommandPayload",
",",
"gppShortAddress",
",",
"commissioningGpd",
")",
";",
"}",
"else",
"{",
"gpCommissioningNotificationSuccessGpdf",
"(",
"commNotificationOptions",
",",
"gpdSecurityFrameCounter",
",",
"commissioningGpd",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Green Power Cluster Gp Commissioning Notification | [
"Green",
"Power",
"Cluster",
"Gp",
"Commissioning",
"Notification"
] | [
"// Null ieee pointer reassignment for MISRA compliance by pointing to an ieee address with 0s.",
"// add a 0 length ZCL OCTATE string type. 1st byte holds the length of rest of the octate string.",
"// Bad address with respect to application type - return back",
"// Address 0 for all other GPDF commands except the channel request.",
"// When the security processing failed sub-field is set, try validating. It can only be validated if there are",
"// keys sent by GPD in a previous commissioning message which will be temporary collected in the commissioningGpd",
"// instance.",
"// In this case, the commissioning notification can not be processed because:",
"// It is a protected message without earlier information of its security keys.",
"// Attempt to process the secure GPDF using its earlier credentials",
"// User application handled",
"// If the Application did not handle the notification through the above callback",
"// The plugin handles it from here.",
"// there was no previous temporary transaction, its a new GPD.",
"// Allocate one instance if available.",
"// All other commands can only be processed if they have an instance else not.",
"// Success or any other GPDF needs a GPD instance to be already present to proceed.",
"// Any valid command that can be processed should behave as success"
] | [
{
"param": "commNotificationOptions",
"type": "uint16_t"
},
{
"param": "gpdSrcId",
"type": "uint32_t"
},
{
"param": "gpdIeee",
"type": "uint8_t"
},
{
"param": "gpdEndpoint",
"type": "uint8_t"
},
{
"param": "gpdSecurityFrameCounter",
"type": "uint32_t"
},
{
"param": "gpdCommandId",
"type": "uint8_t"
},
{
"param": "gpdCommandPayload",
"type": "uint8_t"
},
{
"param": "gppShortAddress",
"type": "uint16_t"
},
{
"param": "gppLink",
"type": "uint8_t"
},
{
"param": "commissioningNotificationMic",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "commNotificationOptions",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdSrcId",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdIeee",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdEndpoint",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdSecurityFrameCounter",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandId",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpdCommandPayload",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gppShortAddress",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gppLink",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commissioningNotificationMic",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f7a7870aa047e2c5983d5f8a3b5fd3daec1d5404 | SiliconLabs/Gecko_SDK | app/flex/component/connect/sl_connect_sdk_ota_bootloader_test_common/sl_connect_sdk_ota_bootloader_test_common.c | [
"Zlib"
] | C | bootloader_flash_image | void | void bootloader_flash_image(void)
{
if (!emberAfPluginBootloaderInterfaceIsBootloaderInitialized()) {
if (!emberAfPluginBootloaderInterfaceInit()) {
app_log_error("bootloader init failed\n");
return;
}
}
emberAfPluginBootloaderInterfaceBootload();
// If we get here bootload process failed.
app_log_info("bootload failed!\n");
} | // -----------------------------------------------------------------------------
// Public Function Definitions
// -----------------------------------------------------------------------------
/**************************************************************************/
/**
* This function initiates a bootload.
*****************************************************************************/ | Public Function Definitions
This function initiates a bootload. | [
"Public",
"Function",
"Definitions",
"This",
"function",
"initiates",
"a",
"bootload",
"."
] | void bootloader_flash_image(void)
{
if (!emberAfPluginBootloaderInterfaceIsBootloaderInitialized()) {
if (!emberAfPluginBootloaderInterfaceInit()) {
app_log_error("bootloader init failed\n");
return;
}
}
emberAfPluginBootloaderInterfaceBootload();
app_log_info("bootload failed!\n");
} | [
"void",
"bootloader_flash_image",
"(",
"void",
")",
"{",
"if",
"(",
"!",
"emberAfPluginBootloaderInterfaceIsBootloaderInitialized",
"(",
")",
")",
"{",
"if",
"(",
"!",
"emberAfPluginBootloaderInterfaceInit",
"(",
")",
")",
"{",
"app_log_error",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
";",
"}",
"}",
"emberAfPluginBootloaderInterfaceBootload",
"(",
")",
";",
"app_log_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}"
] | Public Function Definitions
This function initiates a bootload. | [
"Public",
"Function",
"Definitions",
"This",
"function",
"initiates",
"a",
"bootload",
"."
] | [
"// If we get here bootload process failed."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | handle_boot_event | void | static void handle_boot_event(void)
{
sl_status_t sc;
bd_addr address;
uint8_t address_type;
char buf[BOOT_ERR_MSG_BUF_LEN];
// Check reset conditions and continue if not reset.
if (handle_reset_conditions()) {
sc = sl_bt_system_get_identity_address(&address, &address_type);
app_assert_status_f(sc, "Failed to get Bluetooth address\r\n");
set_device_name(&address);
// Initialize Mesh stack in Node operation mode, wait for initialized event
sc = sl_btmesh_node_init();
if (sc != SL_STATUS_OK) {
snprintf(buf, BOOT_ERR_MSG_BUF_LEN, "init failed (0x%lx)", sc);
lcd_print(buf, BTMESH_WSTK_LCD_ROW_STATUS);
}
}
} | /***************************************************************************/
/**
* Handling of boot event.
* If needed it performs factory reset. In other case it sets device name
* and initialize mesh node.
******************************************************************************/ | Handling of boot event.
If needed it performs factory reset. In other case it sets device name
and initialize mesh node. | [
"Handling",
"of",
"boot",
"event",
".",
"If",
"needed",
"it",
"performs",
"factory",
"reset",
".",
"In",
"other",
"case",
"it",
"sets",
"device",
"name",
"and",
"initialize",
"mesh",
"node",
"."
] | static void handle_boot_event(void)
{
sl_status_t sc;
bd_addr address;
uint8_t address_type;
char buf[BOOT_ERR_MSG_BUF_LEN];
if (handle_reset_conditions()) {
sc = sl_bt_system_get_identity_address(&address, &address_type);
app_assert_status_f(sc, "Failed to get Bluetooth address\r\n");
set_device_name(&address);
sc = sl_btmesh_node_init();
if (sc != SL_STATUS_OK) {
snprintf(buf, BOOT_ERR_MSG_BUF_LEN, "init failed (0x%lx)", sc);
lcd_print(buf, BTMESH_WSTK_LCD_ROW_STATUS);
}
}
} | [
"static",
"void",
"handle_boot_event",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
";",
"bd_addr",
"address",
";",
"uint8_t",
"address_type",
";",
"char",
"buf",
"[",
"BOOT_ERR_MSG_BUF_LEN",
"]",
";",
"if",
"(",
"handle_reset_conditions",
"(",
")",
")",
"{",
"sc",
"=",
"sl_bt_system_get_identity_address",
"(",
"&",
"address",
",",
"&",
"address_type",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"set_device_name",
"(",
"&",
"address",
")",
";",
"sc",
"=",
"sl_btmesh_node_init",
"(",
")",
";",
"if",
"(",
"sc",
"!=",
"SL_STATUS_OK",
")",
"{",
"snprintf",
"(",
"buf",
",",
"BOOT_ERR_MSG_BUF_LEN",
",",
"\"",
"\"",
",",
"sc",
")",
";",
"lcd_print",
"(",
"buf",
",",
"BTMESH_WSTK_LCD_ROW_STATUS",
")",
";",
"}",
"}",
"}"
] | Handling of boot event. | [
"Handling",
"of",
"boot",
"event",
"."
] | [
"// Check reset conditions and continue if not reset.",
"// Initialize Mesh stack in Node operation mode, wait for initialized event"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | handle_node_initialized_event | void | static void handle_node_initialized_event(
sl_btmesh_evt_node_initialized_t* evt)
{
if (evt->provisioned) {
sl_status_t sc =
sl_simple_timer_start(&app_update_registered_devices_timer,
DEVICE_REGISTER_SHORT_TIMEOUT,
app_update_registered_devices_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start timer\r\n");
} else {
// Enable ADV and GATT provisioning bearer
sl_status_t sc = sl_btmesh_node_start_unprov_beaconing(PB_ADV | PB_GATT);
app_assert_status_f(sc, "Failed to start unprovisioned beaconing\n");
}
} | /***************************************************************************/
/**
* Handling of mesh node initialized event.
* If device is provisioned it initializes the sensor server node.
* If device is unprovisioned it starts sending Unprovisioned Device Beacons.
*
* @param[in] evt Pointer to mesh node initialized event.
******************************************************************************/ | Handling of mesh node initialized event.
If device is provisioned it initializes the sensor server node.
If device is unprovisioned it starts sending Unprovisioned Device Beacons.
@param[in] evt Pointer to mesh node initialized event. | [
"Handling",
"of",
"mesh",
"node",
"initialized",
"event",
".",
"If",
"device",
"is",
"provisioned",
"it",
"initializes",
"the",
"sensor",
"server",
"node",
".",
"If",
"device",
"is",
"unprovisioned",
"it",
"starts",
"sending",
"Unprovisioned",
"Device",
"Beacons",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"mesh",
"node",
"initialized",
"event",
"."
] | static void handle_node_initialized_event(
sl_btmesh_evt_node_initialized_t* evt)
{
if (evt->provisioned) {
sl_status_t sc =
sl_simple_timer_start(&app_update_registered_devices_timer,
DEVICE_REGISTER_SHORT_TIMEOUT,
app_update_registered_devices_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start timer\r\n");
} else {
sl_status_t sc = sl_btmesh_node_start_unprov_beaconing(PB_ADV | PB_GATT);
app_assert_status_f(sc, "Failed to start unprovisioned beaconing\n");
}
} | [
"static",
"void",
"handle_node_initialized_event",
"(",
"sl_btmesh_evt_node_initialized_t",
"*",
"evt",
")",
"{",
"if",
"(",
"evt",
"->",
"provisioned",
")",
"{",
"sl_status_t",
"sc",
"=",
"sl_simple_timer_start",
"(",
"&",
"app_update_registered_devices_timer",
",",
"DEVICE_REGISTER_SHORT_TIMEOUT",
",",
"app_update_registered_devices_timer_cb",
",",
"NO_CALLBACK_DATA",
",",
"false",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"sl_status_t",
"sc",
"=",
"sl_btmesh_node_start_unprov_beaconing",
"(",
"PB_ADV",
"|",
"PB_GATT",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}"
] | Handling of mesh node initialized event. | [
"Handling",
"of",
"mesh",
"node",
"initialized",
"event",
"."
] | [
"// Enable ADV and GATT provisioning bearer"
] | [
{
"param": "evt",
"type": "sl_btmesh_evt_node_initialized_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_node_initialized_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | handle_node_provisioning_events | void | void handle_node_provisioning_events(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
sl_status_t sc;
case sl_btmesh_evt_node_provisioned_id:
// Update registered devices after startup
sc = sl_simple_timer_start(&app_update_registered_devices_timer,
DEVICE_REGISTER_LONG_TIMEOUT,
app_update_registered_devices_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start timer\r\n");
break;
default:
break;
}
} | /***************************************************************************/
/**
* Handling of mesh node provisioning events.
* It handles:
* - mesh_node_provisioning_started
* - mesh_node_provisioned
* - mesh_node_provisioning_failed
*
* @param[in] evt Pointer to incoming provisioning event.
******************************************************************************/ | Handling of mesh node provisioning events.
@param[in] evt Pointer to incoming provisioning event. | [
"Handling",
"of",
"mesh",
"node",
"provisioning",
"events",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"incoming",
"provisioning",
"event",
"."
] | void handle_node_provisioning_events(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
sl_status_t sc;
case sl_btmesh_evt_node_provisioned_id:
sc = sl_simple_timer_start(&app_update_registered_devices_timer,
DEVICE_REGISTER_LONG_TIMEOUT,
app_update_registered_devices_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start timer\r\n");
break;
default:
break;
}
} | [
"void",
"handle_node_provisioning_events",
"(",
"sl_btmesh_msg_t",
"*",
"evt",
")",
"{",
"switch",
"(",
"SL_BT_MSG_ID",
"(",
"evt",
"->",
"header",
")",
")",
"{",
"sl_status_t",
"sc",
";",
"case",
"sl_btmesh_evt_node_provisioned_id",
":",
"sc",
"=",
"sl_simple_timer_start",
"(",
"&",
"app_update_registered_devices_timer",
",",
"DEVICE_REGISTER_LONG_TIMEOUT",
",",
"app_update_registered_devices_timer_cb",
",",
"NO_CALLBACK_DATA",
",",
"false",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | Handling of mesh node provisioning events. | [
"Handling",
"of",
"mesh",
"node",
"provisioning",
"events",
"."
] | [
"// Update registered devices after startup"
] | [
{
"param": "evt",
"type": "sl_btmesh_msg_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_msg_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | sl_btmesh_on_event | void | void sl_btmesh_on_event(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
case sl_btmesh_evt_node_initialized_id:
handle_node_initialized_event(&(evt->data.evt_node_initialized));
break;
case sl_btmesh_evt_node_provisioned_id:
handle_node_provisioning_events(evt);
break;
default:
break;
}
} | /***************************************************************************/
/**
* Bluetooth Mesh stack event handler.
* This overrides the dummy weak implementation.
*
* @param[in] evt Pointer to incoming event from the Bluetooth Mesh stack.
******************************************************************************/ | Bluetooth Mesh stack event handler.
This overrides the dummy weak implementation.
@param[in] evt Pointer to incoming event from the Bluetooth Mesh stack. | [
"Bluetooth",
"Mesh",
"stack",
"event",
"handler",
".",
"This",
"overrides",
"the",
"dummy",
"weak",
"implementation",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"incoming",
"event",
"from",
"the",
"Bluetooth",
"Mesh",
"stack",
"."
] | void sl_btmesh_on_event(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
case sl_btmesh_evt_node_initialized_id:
handle_node_initialized_event(&(evt->data.evt_node_initialized));
break;
case sl_btmesh_evt_node_provisioned_id:
handle_node_provisioning_events(evt);
break;
default:
break;
}
} | [
"void",
"sl_btmesh_on_event",
"(",
"sl_btmesh_msg_t",
"*",
"evt",
")",
"{",
"switch",
"(",
"SL_BT_MSG_ID",
"(",
"evt",
"->",
"header",
")",
")",
"{",
"case",
"sl_btmesh_evt_node_initialized_id",
":",
"handle_node_initialized_event",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_node_initialized",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_node_provisioned_id",
":",
"handle_node_provisioning_events",
"(",
"evt",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | Bluetooth Mesh stack event handler. | [
"Bluetooth",
"Mesh",
"stack",
"event",
"handler",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_msg_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_msg_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | sensor_client_change_current_property | void | static void sensor_client_change_current_property(void)
{
switch (current_property) {
case PRESENT_AMBIENT_TEMPERATURE:
current_property = PEOPLE_COUNT;
break;
case PEOPLE_COUNT:
current_property = PRESENT_AMBIENT_LIGHT_LEVEL;
break;
case PRESENT_AMBIENT_LIGHT_LEVEL:
current_property = PRESENT_AMBIENT_TEMPERATURE;
break;
default:
app_log("Unsupported property ID change\r\n");
break;
}
} | /***************************************************************************/
/**
* It changes currently displayed property ID.
******************************************************************************/ | It changes currently displayed property ID. | [
"It",
"changes",
"currently",
"displayed",
"property",
"ID",
"."
] | static void sensor_client_change_current_property(void)
{
switch (current_property) {
case PRESENT_AMBIENT_TEMPERATURE:
current_property = PEOPLE_COUNT;
break;
case PEOPLE_COUNT:
current_property = PRESENT_AMBIENT_LIGHT_LEVEL;
break;
case PRESENT_AMBIENT_LIGHT_LEVEL:
current_property = PRESENT_AMBIENT_TEMPERATURE;
break;
default:
app_log("Unsupported property ID change\r\n");
break;
}
} | [
"static",
"void",
"sensor_client_change_current_property",
"(",
"void",
")",
"{",
"switch",
"(",
"current_property",
")",
"{",
"case",
"PRESENT_AMBIENT_TEMPERATURE",
":",
"current_property",
"=",
"PEOPLE_COUNT",
";",
"break",
";",
"case",
"PEOPLE_COUNT",
":",
"current_property",
"=",
"PRESENT_AMBIENT_LIGHT_LEVEL",
";",
"break",
";",
"case",
"PRESENT_AMBIENT_LIGHT_LEVEL",
":",
"current_property",
"=",
"PRESENT_AMBIENT_TEMPERATURE",
";",
"break",
";",
"default",
":",
"app_log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"}",
"}"
] | It changes currently displayed property ID. | [
"It",
"changes",
"currently",
"displayed",
"property",
"ID",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e1e6e1d28741be69a6ebdb0bb863ae84d3d9556c | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_sensor_client/app.c | [
"Zlib"
] | C | sl_btmesh_on_node_provisioned | void | void sl_btmesh_on_node_provisioned(uint16_t address,
uint32_t iv_index)
{
sl_status_t sc = sl_simple_timer_stop(&app_led_blinking_timer);
app_assert_status_f(sc, "Failed to stop periodic timer\r\n");
// Turn off LED
init_done = true;
sl_led_led0.turn_off(sl_led_led0.context);
#ifndef SINGLE_LED
sl_led_led1.turn_off(sl_led_led1.context);
#endif // SINGLE_LED
// Change LEDs to buttons in case of shared pin
change_leds_to_buttons();
app_show_btmesh_node_provisioned(address, iv_index);
} | // Called when the Provisioning finishes successfully | Called when the Provisioning finishes successfully | [
"Called",
"when",
"the",
"Provisioning",
"finishes",
"successfully"
] | void sl_btmesh_on_node_provisioned(uint16_t address,
uint32_t iv_index)
{
sl_status_t sc = sl_simple_timer_stop(&app_led_blinking_timer);
app_assert_status_f(sc, "Failed to stop periodic timer\r\n");
init_done = true;
sl_led_led0.turn_off(sl_led_led0.context);
#ifndef SINGLE_LED
sl_led_led1.turn_off(sl_led_led1.context);
#endif
change_leds_to_buttons();
app_show_btmesh_node_provisioned(address, iv_index);
} | [
"void",
"sl_btmesh_on_node_provisioned",
"(",
"uint16_t",
"address",
",",
"uint32_t",
"iv_index",
")",
"{",
"sl_status_t",
"sc",
"=",
"sl_simple_timer_stop",
"(",
"&",
"app_led_blinking_timer",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"init_done",
"=",
"true",
";",
"sl_led_led0",
".",
"turn_off",
"(",
"sl_led_led0",
".",
"context",
")",
";",
"#ifndef",
"SINGLE_LED",
"sl_led_led1",
".",
"turn_off",
"(",
"sl_led_led1",
".",
"context",
")",
";",
"#endif",
"change_leds_to_buttons",
"(",
")",
";",
"app_show_btmesh_node_provisioned",
"(",
"address",
",",
"iv_index",
")",
";",
"}"
] | Called when the Provisioning finishes successfully | [
"Called",
"when",
"the",
"Provisioning",
"finishes",
"successfully"
] | [
"// Turn off LED",
"// SINGLE_LED",
"// Change LEDs to buttons in case of shared pin"
] | [
{
"param": "address",
"type": "uint16_t"
},
{
"param": "iv_index",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "address",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iv_index",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d89b8c815a0d2113026017e5f76f62ab3a7a6b3 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_light/app_out_lcd.c | [
"Zlib"
] | C | sl_btmesh_ctl_on_ui_update | void | void sl_btmesh_ctl_on_ui_update(uint16_t temperature,
uint16_t deltauv)
{
// Temporary buffer to format the LCD output text
char tmp_str[LCD_ROW_LEN];
char deltauv_str[8] = { 0 };
sl_btmesh_ctl_server_snprint_deltauv(deltauv_str,
sizeof(deltauv_str),
deltauv);
snprintf(tmp_str, LCD_ROW_LEN, "ColorTemp: %5uK", temperature);
app_log("BT mesh CTL Color temperature: %5uK\r\n", temperature);
sl_status_t status = sl_btmesh_LCD_write(tmp_str,
BTMESH_WSTK_LCD_ROW_TEMPERATURE);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
snprintf(tmp_str, LCD_ROW_LEN, "Delta UV: %6s ", deltauv_str);
app_log("BT mesh CTL Delta UV: %6s\r\n", deltauv_str);
status = sl_btmesh_LCD_write(tmp_str, BTMESH_WSTK_LCD_ROW_DELTAUV);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
} | /*******************************************************************************
* Called when the UI shall be updated with the changed CTL Model state during
* a transition. The rate of this callback can be controlled by changing the
* CTL_SERVER_UI_UPDATE_PERIOD macro.
*
* @param[in] temperature Temperature of color.
* @param[in] deltauv Delta UV value.
******************************************************************************/ | Called when the UI shall be updated with the changed CTL Model state during
a transition. The rate of this callback can be controlled by changing the
CTL_SERVER_UI_UPDATE_PERIOD macro.
@param[in] temperature Temperature of color.
@param[in] deltauv Delta UV value. | [
"Called",
"when",
"the",
"UI",
"shall",
"be",
"updated",
"with",
"the",
"changed",
"CTL",
"Model",
"state",
"during",
"a",
"transition",
".",
"The",
"rate",
"of",
"this",
"callback",
"can",
"be",
"controlled",
"by",
"changing",
"the",
"CTL_SERVER_UI_UPDATE_PERIOD",
"macro",
".",
"@param",
"[",
"in",
"]",
"temperature",
"Temperature",
"of",
"color",
".",
"@param",
"[",
"in",
"]",
"deltauv",
"Delta",
"UV",
"value",
"."
] | void sl_btmesh_ctl_on_ui_update(uint16_t temperature,
uint16_t deltauv)
{
char tmp_str[LCD_ROW_LEN];
char deltauv_str[8] = { 0 };
sl_btmesh_ctl_server_snprint_deltauv(deltauv_str,
sizeof(deltauv_str),
deltauv);
snprintf(tmp_str, LCD_ROW_LEN, "ColorTemp: %5uK", temperature);
app_log("BT mesh CTL Color temperature: %5uK\r\n", temperature);
sl_status_t status = sl_btmesh_LCD_write(tmp_str,
BTMESH_WSTK_LCD_ROW_TEMPERATURE);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
snprintf(tmp_str, LCD_ROW_LEN, "Delta UV: %6s ", deltauv_str);
app_log("BT mesh CTL Delta UV: %6s\r\n", deltauv_str);
status = sl_btmesh_LCD_write(tmp_str, BTMESH_WSTK_LCD_ROW_DELTAUV);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
} | [
"void",
"sl_btmesh_ctl_on_ui_update",
"(",
"uint16_t",
"temperature",
",",
"uint16_t",
"deltauv",
")",
"{",
"char",
"tmp_str",
"[",
"LCD_ROW_LEN",
"]",
";",
"char",
"deltauv_str",
"[",
"8",
"]",
"=",
"{",
"0",
"}",
";",
"sl_btmesh_ctl_server_snprint_deltauv",
"(",
"deltauv_str",
",",
"sizeof",
"(",
"deltauv_str",
")",
",",
"deltauv",
")",
";",
"snprintf",
"(",
"tmp_str",
",",
"LCD_ROW_LEN",
",",
"\"",
"\"",
",",
"temperature",
")",
";",
"app_log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"temperature",
")",
";",
"sl_status_t",
"status",
"=",
"sl_btmesh_LCD_write",
"(",
"tmp_str",
",",
"BTMESH_WSTK_LCD_ROW_TEMPERATURE",
")",
";",
"app_log_status_level_f",
"(",
"APP_LOG_LEVEL_ERROR",
",",
"status",
",",
"\"",
"\"",
")",
";",
"snprintf",
"(",
"tmp_str",
",",
"LCD_ROW_LEN",
",",
"\"",
"\"",
",",
"deltauv_str",
")",
";",
"app_log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"deltauv_str",
")",
";",
"status",
"=",
"sl_btmesh_LCD_write",
"(",
"tmp_str",
",",
"BTMESH_WSTK_LCD_ROW_DELTAUV",
")",
";",
"app_log_status_level_f",
"(",
"APP_LOG_LEVEL_ERROR",
",",
"status",
",",
"\"",
"\"",
")",
";",
"}"
] | Called when the UI shall be updated with the changed CTL Model state during
a transition. | [
"Called",
"when",
"the",
"UI",
"shall",
"be",
"updated",
"with",
"the",
"changed",
"CTL",
"Model",
"state",
"during",
"a",
"transition",
"."
] | [
"// Temporary buffer to format the LCD output text"
] | [
{
"param": "temperature",
"type": "uint16_t"
},
{
"param": "deltauv",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "temperature",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "deltauv",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d89b8c815a0d2113026017e5f76f62ab3a7a6b3 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_light/app_out_lcd.c | [
"Zlib"
] | C | sl_btmesh_lighting_server_on_ui_update | void | void sl_btmesh_lighting_server_on_ui_update(uint16_t lightness_level)
{
// Temporary buffer to format the LCD output text
char tmp_str[LCD_ROW_LEN];
uint16_t lightness_percent = (lightness_level * 100 + 99) / 65535;
app_log("BT mesh Lightness: %5u%%\r\n", lightness_percent);
snprintf(tmp_str, LCD_ROW_LEN, "Lightness: %5u%%", lightness_percent);
sl_status_t status = sl_btmesh_LCD_write(tmp_str,
BTMESH_WSTK_LCD_ROW_LIGHTNESS);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
} | /*******************************************************************************
* Called when the UI shall be updated with the changed state of
* lightning server during a transition. The rate of this callback can be
* controlled by changing the LIGHTING_SERVER_UI_UPDATE_PERIOD macro.
*
* @param[in] lightness_level lightness level (0x0001 - FFFE)
******************************************************************************/ | Called when the UI shall be updated with the changed state of
lightning server during a transition. The rate of this callback can be
controlled by changing the LIGHTING_SERVER_UI_UPDATE_PERIOD macro.
@param[in] lightness_level lightness level (0x0001 - FFFE) | [
"Called",
"when",
"the",
"UI",
"shall",
"be",
"updated",
"with",
"the",
"changed",
"state",
"of",
"lightning",
"server",
"during",
"a",
"transition",
".",
"The",
"rate",
"of",
"this",
"callback",
"can",
"be",
"controlled",
"by",
"changing",
"the",
"LIGHTING_SERVER_UI_UPDATE_PERIOD",
"macro",
".",
"@param",
"[",
"in",
"]",
"lightness_level",
"lightness",
"level",
"(",
"0x0001",
"-",
"FFFE",
")"
] | void sl_btmesh_lighting_server_on_ui_update(uint16_t lightness_level)
{
char tmp_str[LCD_ROW_LEN];
uint16_t lightness_percent = (lightness_level * 100 + 99) / 65535;
app_log("BT mesh Lightness: %5u%%\r\n", lightness_percent);
snprintf(tmp_str, LCD_ROW_LEN, "Lightness: %5u%%", lightness_percent);
sl_status_t status = sl_btmesh_LCD_write(tmp_str,
BTMESH_WSTK_LCD_ROW_LIGHTNESS);
app_log_status_level_f(APP_LOG_LEVEL_ERROR, status, "LCD write failed");
} | [
"void",
"sl_btmesh_lighting_server_on_ui_update",
"(",
"uint16_t",
"lightness_level",
")",
"{",
"char",
"tmp_str",
"[",
"LCD_ROW_LEN",
"]",
";",
"uint16_t",
"lightness_percent",
"=",
"(",
"lightness_level",
"*",
"100",
"+",
"99",
")",
"/",
"65535",
";",
"app_log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lightness_percent",
")",
";",
"snprintf",
"(",
"tmp_str",
",",
"LCD_ROW_LEN",
",",
"\"",
"\"",
",",
"lightness_percent",
")",
";",
"sl_status_t",
"status",
"=",
"sl_btmesh_LCD_write",
"(",
"tmp_str",
",",
"BTMESH_WSTK_LCD_ROW_LIGHTNESS",
")",
";",
"app_log_status_level_f",
"(",
"APP_LOG_LEVEL_ERROR",
",",
"status",
",",
"\"",
"\"",
")",
";",
"}"
] | Called when the UI shall be updated with the changed state of
lightning server during a transition. | [
"Called",
"when",
"the",
"UI",
"shall",
"be",
"updated",
"with",
"the",
"changed",
"state",
"of",
"lightning",
"server",
"during",
"a",
"transition",
"."
] | [
"// Temporary buffer to format the LCD output text"
] | [
{
"param": "lightness_level",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lightness_level",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_state_load | sl_status_t | static sl_status_t lc_state_load(void)
{
sl_status_t sc;
size_t ps_len = 0;
struct lc_state ps_data;
sc = sl_bt_nvm_load(LC_SERVER_PS_KEY,
sizeof(ps_data),
&ps_len,
(uint8_t *)&ps_data);
// Set default values if ps_load fail or size of lc_state has changed
if ((sc != SL_STATUS_OK) || (ps_len != sizeof(lc_state))) {
memset(&lc_state, 0, sizeof(lc_state));
lc_state.mode = LC_MODE_DEFAULT;
lc_state.occupancy_mode = LC_OCCUPANCY_MODE_DEFAULT;
if (sc == SL_STATUS_OK) {
// The sl_bt_nvm_load call was successful but the size of the loaded data
// differs from the expected size therefore error code shall be set
sc = SL_STATUS_INVALID_STATE;
log("LC server lc_state loaded from PS with invalid size, "
"use defaults. (expected=%zd,actual=%zd)\r\n",
sizeof(lc_state),
ps_len);
} else {
log_status_f(sc,
"LC server lc_state load from PS failed "
"or nvm is empty, use defaults.\r\n");
}
} else {
memcpy(&lc_state, &ps_data, ps_len);
}
return sc;
} | /***************************************************************************/
/**
* This function loads the saved light controller state from Persistent Storage
* and copies the data in the global variable lc_state.
* If PS key with ID 0x4005 does not exist or loading failed,
* lc_state is set to zero and some default values are written to it.
*
* @return Returns SL_STATUS_OK (0) if succeeds, non-zero otherwise.
******************************************************************************/ | This function loads the saved light controller state from Persistent Storage
and copies the data in the global variable lc_state.
If PS key with ID 0x4005 does not exist or loading failed,
lc_state is set to zero and some default values are written to it.
@return Returns SL_STATUS_OK (0) if succeeds, non-zero otherwise. | [
"This",
"function",
"loads",
"the",
"saved",
"light",
"controller",
"state",
"from",
"Persistent",
"Storage",
"and",
"copies",
"the",
"data",
"in",
"the",
"global",
"variable",
"lc_state",
".",
"If",
"PS",
"key",
"with",
"ID",
"0x4005",
"does",
"not",
"exist",
"or",
"loading",
"failed",
"lc_state",
"is",
"set",
"to",
"zero",
"and",
"some",
"default",
"values",
"are",
"written",
"to",
"it",
".",
"@return",
"Returns",
"SL_STATUS_OK",
"(",
"0",
")",
"if",
"succeeds",
"non",
"-",
"zero",
"otherwise",
"."
] | static sl_status_t lc_state_load(void)
{
sl_status_t sc;
size_t ps_len = 0;
struct lc_state ps_data;
sc = sl_bt_nvm_load(LC_SERVER_PS_KEY,
sizeof(ps_data),
&ps_len,
(uint8_t *)&ps_data);
if ((sc != SL_STATUS_OK) || (ps_len != sizeof(lc_state))) {
memset(&lc_state, 0, sizeof(lc_state));
lc_state.mode = LC_MODE_DEFAULT;
lc_state.occupancy_mode = LC_OCCUPANCY_MODE_DEFAULT;
if (sc == SL_STATUS_OK) {
sc = SL_STATUS_INVALID_STATE;
log("LC server lc_state loaded from PS with invalid size, "
"use defaults. (expected=%zd,actual=%zd)\r\n",
sizeof(lc_state),
ps_len);
} else {
log_status_f(sc,
"LC server lc_state load from PS failed "
"or nvm is empty, use defaults.\r\n");
}
} else {
memcpy(&lc_state, &ps_data, ps_len);
}
return sc;
} | [
"static",
"sl_status_t",
"lc_state_load",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
";",
"size_t",
"ps_len",
"=",
"0",
";",
"struct",
"lc_state",
"ps_data",
";",
"sc",
"=",
"sl_bt_nvm_load",
"(",
"LC_SERVER_PS_KEY",
",",
"sizeof",
"(",
"ps_data",
")",
",",
"&",
"ps_len",
",",
"(",
"uint8_t",
"*",
")",
"&",
"ps_data",
")",
";",
"if",
"(",
"(",
"sc",
"!=",
"SL_STATUS_OK",
")",
"||",
"(",
"ps_len",
"!=",
"sizeof",
"(",
"lc_state",
")",
")",
")",
"{",
"memset",
"(",
"&",
"lc_state",
",",
"0",
",",
"sizeof",
"(",
"lc_state",
")",
")",
";",
"lc_state",
".",
"mode",
"=",
"LC_MODE_DEFAULT",
";",
"lc_state",
".",
"occupancy_mode",
"=",
"LC_OCCUPANCY_MODE_DEFAULT",
";",
"if",
"(",
"sc",
"==",
"SL_STATUS_OK",
")",
"{",
"sc",
"=",
"SL_STATUS_INVALID_STATE",
";",
"log",
"(",
"\"",
"\"",
"\"",
"\\r",
"\\n",
"\"",
",",
"sizeof",
"(",
"lc_state",
")",
",",
"ps_len",
")",
";",
"}",
"else",
"{",
"log_status_f",
"(",
"sc",
",",
"\"",
"\"",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"}",
"else",
"{",
"memcpy",
"(",
"&",
"lc_state",
",",
"&",
"ps_data",
",",
"ps_len",
")",
";",
"}",
"return",
"sc",
";",
"}"
] | This function loads the saved light controller state from Persistent Storage
and copies the data in the global variable lc_state. | [
"This",
"function",
"loads",
"the",
"saved",
"light",
"controller",
"state",
"from",
"Persistent",
"Storage",
"and",
"copies",
"the",
"data",
"in",
"the",
"global",
"variable",
"lc_state",
"."
] | [
"// Set default values if ps_load fail or size of lc_state has changed",
"// The sl_bt_nvm_load call was successful but the size of the loaded data",
"// differs from the expected size therefore error code shall be set"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_state_store | int | static int lc_state_store(void)
{
sl_status_t sc = sl_bt_nvm_save(LC_SERVER_PS_KEY,
sizeof(struct lc_state),
(const uint8_t *)&lc_state);
log_status_level_f(APP_LOG_LEVEL_ERROR,
sc,
"LC server lc_state store in PS failed.\r\n");
return sc;
} | /***************************************************************************/
/**
* This function saves the current light controller state in Persistent Storage
* so that the data is preserved over reboots and power cycles.
* The light controller state is hold in a global variable lc_state.
* A PS key with ID 0x4005 is used to store the whole structure.
*
* @return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise.
******************************************************************************/ | This function saves the current light controller state in Persistent Storage
so that the data is preserved over reboots and power cycles.
The light controller state is hold in a global variable lc_state.
A PS key with ID 0x4005 is used to store the whole structure.
@return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise. | [
"This",
"function",
"saves",
"the",
"current",
"light",
"controller",
"state",
"in",
"Persistent",
"Storage",
"so",
"that",
"the",
"data",
"is",
"preserved",
"over",
"reboots",
"and",
"power",
"cycles",
".",
"The",
"light",
"controller",
"state",
"is",
"hold",
"in",
"a",
"global",
"variable",
"lc_state",
".",
"A",
"PS",
"key",
"with",
"ID",
"0x4005",
"is",
"used",
"to",
"store",
"the",
"whole",
"structure",
".",
"@return",
"Returns",
"SL_STATUS_OK",
"(",
"0",
")",
"if",
"succeed",
"non",
"-",
"zero",
"otherwise",
"."
] | static int lc_state_store(void)
{
sl_status_t sc = sl_bt_nvm_save(LC_SERVER_PS_KEY,
sizeof(struct lc_state),
(const uint8_t *)&lc_state);
log_status_level_f(APP_LOG_LEVEL_ERROR,
sc,
"LC server lc_state store in PS failed.\r\n");
return sc;
} | [
"static",
"int",
"lc_state_store",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
"=",
"sl_bt_nvm_save",
"(",
"LC_SERVER_PS_KEY",
",",
"sizeof",
"(",
"struct",
"lc_state",
")",
",",
"(",
"const",
"uint8_t",
"*",
")",
"&",
"lc_state",
")",
";",
"log_status_level_f",
"(",
"APP_LOG_LEVEL_ERROR",
",",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"return",
"sc",
";",
"}"
] | This function saves the current light controller state in Persistent Storage
so that the data is preserved over reboots and power cycles. | [
"This",
"function",
"saves",
"the",
"current",
"light",
"controller",
"state",
"in",
"Persistent",
"Storage",
"so",
"that",
"the",
"data",
"is",
"preserved",
"over",
"reboots",
"and",
"power",
"cycles",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_state_changed | void | static void lc_state_changed(void)
{
sl_status_t sc = sl_simple_timer_start(&lc_save_state_timer,
LC_SERVER_NVM_SAVE_TIME,
lc_save_state_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC State save timer\n");
} | /***************************************************************************/
/**
* This function is called each time the light controller state in RAM
* is changed. It sets up a soft timer that will save the state in flash after
* small delay. The purpose is to reduce amount of unnecessary flash writes.
******************************************************************************/ | This function is called each time the light controller state in RAM
is changed. It sets up a soft timer that will save the state in flash after
small delay. The purpose is to reduce amount of unnecessary flash writes. | [
"This",
"function",
"is",
"called",
"each",
"time",
"the",
"light",
"controller",
"state",
"in",
"RAM",
"is",
"changed",
".",
"It",
"sets",
"up",
"a",
"soft",
"timer",
"that",
"will",
"save",
"the",
"state",
"in",
"flash",
"after",
"small",
"delay",
".",
"The",
"purpose",
"is",
"to",
"reduce",
"amount",
"of",
"unnecessary",
"flash",
"writes",
"."
] | static void lc_state_changed(void)
{
sl_status_t sc = sl_simple_timer_start(&lc_save_state_timer,
LC_SERVER_NVM_SAVE_TIME,
lc_save_state_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC State save timer\n");
} | [
"static",
"void",
"lc_state_changed",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
"=",
"sl_simple_timer_start",
"(",
"&",
"lc_save_state_timer",
",",
"LC_SERVER_NVM_SAVE_TIME",
",",
"lc_save_state_timer_cb",
",",
"NO_CALLBACK_DATA",
",",
"false",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\n",
"\"",
")",
";",
"}"
] | This function is called each time the light controller state in RAM
is changed. | [
"This",
"function",
"is",
"called",
"each",
"time",
"the",
"light",
"controller",
"state",
"in",
"RAM",
"is",
"changed",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_onpowerup_update | void | void lc_onpowerup_update(uint16_t element, uint8_t onpowerup)
{
sl_status_t sc_mode = SL_STATUS_OK;
sl_status_t sc_om = SL_STATUS_OK;
sl_status_t sc_onoff = SL_STATUS_OK;
switch (onpowerup) {
case MESH_GENERIC_ON_POWER_UP_STATE_OFF:
case MESH_GENERIC_ON_POWER_UP_STATE_ON:
lc_state.mode = 0;
lc_state.light_onoff = 0;
lc_state.onoff_current = MESH_GENERIC_ON_OFF_STATE_OFF;
lc_state.onoff_target = MESH_GENERIC_ON_OFF_STATE_OFF;
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
sc_onoff = sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
IMMEDIATE);
break;
case MESH_GENERIC_ON_POWER_UP_STATE_RESTORE:
if (lc_state.mode == 0) {
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
} else {
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
if (lc_state.light_onoff == 0) {
sc_onoff = sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
IMMEDIATE);
} else {
sc_onoff =
sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
lc_property_state.time_fade_on);
}
}
break;
default:
break;
}
log_btmesh_status_f(sc_mode,
"lc_server_update_mode failed (elem=%d)\r\n",
element);
log_btmesh_status_f(sc_om,
"lc_server_update_om failed (elem=%d)\r\n",
element);
log_btmesh_status_f(sc_onoff,
"lc_server_update_light_onoff failed (elem=%d)\r\n",
element);
lc_state_changed();
} | /*******************************************************************************
* Light Controller state update on power up sequence.
*
* @param[in] element Index of the element.
* @param[in] onpowerup Value of OnPowerUp state.
******************************************************************************/ | Light Controller state update on power up sequence.
@param[in] element Index of the element.
@param[in] onpowerup Value of OnPowerUp state. | [
"Light",
"Controller",
"state",
"update",
"on",
"power",
"up",
"sequence",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
".",
"@param",
"[",
"in",
"]",
"onpowerup",
"Value",
"of",
"OnPowerUp",
"state",
"."
] | void lc_onpowerup_update(uint16_t element, uint8_t onpowerup)
{
sl_status_t sc_mode = SL_STATUS_OK;
sl_status_t sc_om = SL_STATUS_OK;
sl_status_t sc_onoff = SL_STATUS_OK;
switch (onpowerup) {
case MESH_GENERIC_ON_POWER_UP_STATE_OFF:
case MESH_GENERIC_ON_POWER_UP_STATE_ON:
lc_state.mode = 0;
lc_state.light_onoff = 0;
lc_state.onoff_current = MESH_GENERIC_ON_OFF_STATE_OFF;
lc_state.onoff_target = MESH_GENERIC_ON_OFF_STATE_OFF;
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
sc_onoff = sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
IMMEDIATE);
break;
case MESH_GENERIC_ON_POWER_UP_STATE_RESTORE:
if (lc_state.mode == 0) {
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
} else {
sc_mode = sl_btmesh_lc_server_update_mode(element, lc_state.mode);
sc_om = sl_btmesh_lc_server_update_om(element, lc_state.occupancy_mode);
if (lc_state.light_onoff == 0) {
sc_onoff = sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
IMMEDIATE);
} else {
sc_onoff =
sl_btmesh_lc_server_update_light_onoff(element,
lc_state.light_onoff,
lc_property_state.time_fade_on);
}
}
break;
default:
break;
}
log_btmesh_status_f(sc_mode,
"lc_server_update_mode failed (elem=%d)\r\n",
element);
log_btmesh_status_f(sc_om,
"lc_server_update_om failed (elem=%d)\r\n",
element);
log_btmesh_status_f(sc_onoff,
"lc_server_update_light_onoff failed (elem=%d)\r\n",
element);
lc_state_changed();
} | [
"void",
"lc_onpowerup_update",
"(",
"uint16_t",
"element",
",",
"uint8_t",
"onpowerup",
")",
"{",
"sl_status_t",
"sc_mode",
"=",
"SL_STATUS_OK",
";",
"sl_status_t",
"sc_om",
"=",
"SL_STATUS_OK",
";",
"sl_status_t",
"sc_onoff",
"=",
"SL_STATUS_OK",
";",
"switch",
"(",
"onpowerup",
")",
"{",
"case",
"MESH_GENERIC_ON_POWER_UP_STATE_OFF",
":",
"case",
"MESH_GENERIC_ON_POWER_UP_STATE_ON",
":",
"lc_state",
".",
"mode",
"=",
"0",
";",
"lc_state",
".",
"light_onoff",
"=",
"0",
";",
"lc_state",
".",
"onoff_current",
"=",
"MESH_GENERIC_ON_OFF_STATE_OFF",
";",
"lc_state",
".",
"onoff_target",
"=",
"MESH_GENERIC_ON_OFF_STATE_OFF",
";",
"sc_mode",
"=",
"sl_btmesh_lc_server_update_mode",
"(",
"element",
",",
"lc_state",
".",
"mode",
")",
";",
"sc_om",
"=",
"sl_btmesh_lc_server_update_om",
"(",
"element",
",",
"lc_state",
".",
"occupancy_mode",
")",
";",
"sc_onoff",
"=",
"sl_btmesh_lc_server_update_light_onoff",
"(",
"element",
",",
"lc_state",
".",
"light_onoff",
",",
"IMMEDIATE",
")",
";",
"break",
";",
"case",
"MESH_GENERIC_ON_POWER_UP_STATE_RESTORE",
":",
"if",
"(",
"lc_state",
".",
"mode",
"==",
"0",
")",
"{",
"sc_mode",
"=",
"sl_btmesh_lc_server_update_mode",
"(",
"element",
",",
"lc_state",
".",
"mode",
")",
";",
"sc_om",
"=",
"sl_btmesh_lc_server_update_om",
"(",
"element",
",",
"lc_state",
".",
"occupancy_mode",
")",
";",
"}",
"else",
"{",
"sc_mode",
"=",
"sl_btmesh_lc_server_update_mode",
"(",
"element",
",",
"lc_state",
".",
"mode",
")",
";",
"sc_om",
"=",
"sl_btmesh_lc_server_update_om",
"(",
"element",
",",
"lc_state",
".",
"occupancy_mode",
")",
";",
"if",
"(",
"lc_state",
".",
"light_onoff",
"==",
"0",
")",
"{",
"sc_onoff",
"=",
"sl_btmesh_lc_server_update_light_onoff",
"(",
"element",
",",
"lc_state",
".",
"light_onoff",
",",
"IMMEDIATE",
")",
";",
"}",
"else",
"{",
"sc_onoff",
"=",
"sl_btmesh_lc_server_update_light_onoff",
"(",
"element",
",",
"lc_state",
".",
"light_onoff",
",",
"lc_property_state",
".",
"time_fade_on",
")",
";",
"}",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"log_btmesh_status_f",
"(",
"sc_mode",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
")",
";",
"log_btmesh_status_f",
"(",
"sc_om",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
")",
";",
"log_btmesh_status_f",
"(",
"sc_onoff",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
")",
";",
"lc_state_changed",
"(",
")",
";",
"}"
] | Light Controller state update on power up sequence. | [
"Light",
"Controller",
"state",
"update",
"on",
"power",
"up",
"sequence",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
},
{
"param": "onpowerup",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "onpowerup",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_property_state_load | sl_status_t | static sl_status_t lc_property_state_load(void)
{
sl_status_t sc;
size_t ps_len = 0;
struct lc_property_state ps_data;
sc = sl_bt_nvm_load(LC_SERVER_PROPERTY_PS_KEY,
sizeof(ps_data),
&ps_len,
(uint8_t *)&ps_data);
// Set default values if ps_load fail or size of lc_property_state has changed
if ((sc != SL_STATUS_OK) || (ps_len != sizeof(lc_property_state))) {
memset(&lc_property_state, 0, sizeof(lc_property_state));
#if LC_SERVER_PROPERTY_STATE_DEFAULT_ENABLE
lc_property_state.time_occupancy_delay =
LC_SERVER_TIME_OCCUPANCY_DELAY_DEFAULT;
lc_property_state.time_fade_on = LC_SERVER_TIME_FADE_ON_DEFAULT;
lc_property_state.time_run_on = LC_SERVER_TIME_RUN_ON_DEFAULT;
lc_property_state.time_fade = LC_SERVER_TIME_FADE_DEFAULT;
lc_property_state.time_prolong = LC_SERVER_TIME_PROLONG_DEFAULT;
lc_property_state.time_fade_standby_auto =
LC_SERVER_TIME_FADE_STANDBY_AUTO_DEFAULT;
lc_property_state.time_fade_standby_manual =
LC_SERVER_TIME_FADE_STANDBY_MANUAL_DEFAULT;
lc_property_state.lightness_on = LC_SERVER_LIGHTNESS_ON_DEFAULT;
lc_property_state.lightness_prolong = LC_SERVER_LIGHTNESS_PROLONG_DEFAULT;
lc_property_state.lightness_standby = LC_SERVER_LIGHTNESS_STANDBY_DEFAULT;
lc_property_state.ambient_luxlevel_on =
LC_SERVER_AMBIENT_LUX_LEVEL_ON_DEFAULT;
lc_property_state.ambient_luxlevel_prolong =
LC_SERVER_AMBIENT_LUX_LEVEL_PROLONG_DEFAULT;
lc_property_state.ambient_luxlevel_standby =
LC_SERVER_AMBIENT_LUX_LEVEL_STANDBY_DEFAULT;
#endif // LC_SERVER_PROPERTY_STATE_DEFAULT_ENABLE
lc_property_state.regulator_kiu = LC_REGULATOR_KIU_DEFAULT;
lc_property_state.regulator_kid = LC_REGULATOR_KID_DEFAULT;
lc_property_state.regulator_kpu = LC_REGULATOR_KPU_DEFAULT;
lc_property_state.regulator_kpd = LC_REGULATOR_KPD_DEFAULT;
lc_property_state.regulator_accuracy = LC_REGULATOR_ACCURACY_DEFAULT;
if (sc == SL_STATUS_OK) {
// The sl_bt_nvm_load call was successful but the size of the loaded data
// differs from the expected size therefore error code shall be set
sc = SL_STATUS_INVALID_STATE;
log("LC server lc_property_state loaded from PS with invalid size, "
"use defaults. (expected=%zd,actual=%zd)\r\n",
sizeof(lc_property_state),
ps_len);
} else {
log_status_f(sc,
"LC server lc_property_state load from PS failed "
"or nvm is empty, use defaults.\r\n");
}
} else {
memcpy(&lc_property_state, &ps_data, ps_len);
}
return sc;
} | /***************************************************************************/
/**
* This function loads the saved light controller property state from Persistent
* Storage and copies the data in the global variable lc_property_state.
* If PS key with ID 0x4006 does not exist or loading failed,
* lc_property_state is set to zero and some default values are written to it.
*
* @return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise.
******************************************************************************/ | This function loads the saved light controller property state from Persistent
Storage and copies the data in the global variable lc_property_state.
If PS key with ID 0x4006 does not exist or loading failed,
lc_property_state is set to zero and some default values are written to it.
@return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise. | [
"This",
"function",
"loads",
"the",
"saved",
"light",
"controller",
"property",
"state",
"from",
"Persistent",
"Storage",
"and",
"copies",
"the",
"data",
"in",
"the",
"global",
"variable",
"lc_property_state",
".",
"If",
"PS",
"key",
"with",
"ID",
"0x4006",
"does",
"not",
"exist",
"or",
"loading",
"failed",
"lc_property_state",
"is",
"set",
"to",
"zero",
"and",
"some",
"default",
"values",
"are",
"written",
"to",
"it",
".",
"@return",
"Returns",
"SL_STATUS_OK",
"(",
"0",
")",
"if",
"succeed",
"non",
"-",
"zero",
"otherwise",
"."
] | static sl_status_t lc_property_state_load(void)
{
sl_status_t sc;
size_t ps_len = 0;
struct lc_property_state ps_data;
sc = sl_bt_nvm_load(LC_SERVER_PROPERTY_PS_KEY,
sizeof(ps_data),
&ps_len,
(uint8_t *)&ps_data);
if ((sc != SL_STATUS_OK) || (ps_len != sizeof(lc_property_state))) {
memset(&lc_property_state, 0, sizeof(lc_property_state));
#if LC_SERVER_PROPERTY_STATE_DEFAULT_ENABLE
lc_property_state.time_occupancy_delay =
LC_SERVER_TIME_OCCUPANCY_DELAY_DEFAULT;
lc_property_state.time_fade_on = LC_SERVER_TIME_FADE_ON_DEFAULT;
lc_property_state.time_run_on = LC_SERVER_TIME_RUN_ON_DEFAULT;
lc_property_state.time_fade = LC_SERVER_TIME_FADE_DEFAULT;
lc_property_state.time_prolong = LC_SERVER_TIME_PROLONG_DEFAULT;
lc_property_state.time_fade_standby_auto =
LC_SERVER_TIME_FADE_STANDBY_AUTO_DEFAULT;
lc_property_state.time_fade_standby_manual =
LC_SERVER_TIME_FADE_STANDBY_MANUAL_DEFAULT;
lc_property_state.lightness_on = LC_SERVER_LIGHTNESS_ON_DEFAULT;
lc_property_state.lightness_prolong = LC_SERVER_LIGHTNESS_PROLONG_DEFAULT;
lc_property_state.lightness_standby = LC_SERVER_LIGHTNESS_STANDBY_DEFAULT;
lc_property_state.ambient_luxlevel_on =
LC_SERVER_AMBIENT_LUX_LEVEL_ON_DEFAULT;
lc_property_state.ambient_luxlevel_prolong =
LC_SERVER_AMBIENT_LUX_LEVEL_PROLONG_DEFAULT;
lc_property_state.ambient_luxlevel_standby =
LC_SERVER_AMBIENT_LUX_LEVEL_STANDBY_DEFAULT;
#endif
lc_property_state.regulator_kiu = LC_REGULATOR_KIU_DEFAULT;
lc_property_state.regulator_kid = LC_REGULATOR_KID_DEFAULT;
lc_property_state.regulator_kpu = LC_REGULATOR_KPU_DEFAULT;
lc_property_state.regulator_kpd = LC_REGULATOR_KPD_DEFAULT;
lc_property_state.regulator_accuracy = LC_REGULATOR_ACCURACY_DEFAULT;
if (sc == SL_STATUS_OK) {
sc = SL_STATUS_INVALID_STATE;
log("LC server lc_property_state loaded from PS with invalid size, "
"use defaults. (expected=%zd,actual=%zd)\r\n",
sizeof(lc_property_state),
ps_len);
} else {
log_status_f(sc,
"LC server lc_property_state load from PS failed "
"or nvm is empty, use defaults.\r\n");
}
} else {
memcpy(&lc_property_state, &ps_data, ps_len);
}
return sc;
} | [
"static",
"sl_status_t",
"lc_property_state_load",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
";",
"size_t",
"ps_len",
"=",
"0",
";",
"struct",
"lc_property_state",
"ps_data",
";",
"sc",
"=",
"sl_bt_nvm_load",
"(",
"LC_SERVER_PROPERTY_PS_KEY",
",",
"sizeof",
"(",
"ps_data",
")",
",",
"&",
"ps_len",
",",
"(",
"uint8_t",
"*",
")",
"&",
"ps_data",
")",
";",
"if",
"(",
"(",
"sc",
"!=",
"SL_STATUS_OK",
")",
"||",
"(",
"ps_len",
"!=",
"sizeof",
"(",
"lc_property_state",
")",
")",
")",
"{",
"memset",
"(",
"&",
"lc_property_state",
",",
"0",
",",
"sizeof",
"(",
"lc_property_state",
")",
")",
";",
"#if",
"LC_SERVER_PROPERTY_STATE_DEFAULT_ENABLE",
"\n",
"lc_property_state",
".",
"time_occupancy_delay",
"=",
"LC_SERVER_TIME_OCCUPANCY_DELAY_DEFAULT",
";",
"lc_property_state",
".",
"time_fade_on",
"=",
"LC_SERVER_TIME_FADE_ON_DEFAULT",
";",
"lc_property_state",
".",
"time_run_on",
"=",
"LC_SERVER_TIME_RUN_ON_DEFAULT",
";",
"lc_property_state",
".",
"time_fade",
"=",
"LC_SERVER_TIME_FADE_DEFAULT",
";",
"lc_property_state",
".",
"time_prolong",
"=",
"LC_SERVER_TIME_PROLONG_DEFAULT",
";",
"lc_property_state",
".",
"time_fade_standby_auto",
"=",
"LC_SERVER_TIME_FADE_STANDBY_AUTO_DEFAULT",
";",
"lc_property_state",
".",
"time_fade_standby_manual",
"=",
"LC_SERVER_TIME_FADE_STANDBY_MANUAL_DEFAULT",
";",
"lc_property_state",
".",
"lightness_on",
"=",
"LC_SERVER_LIGHTNESS_ON_DEFAULT",
";",
"lc_property_state",
".",
"lightness_prolong",
"=",
"LC_SERVER_LIGHTNESS_PROLONG_DEFAULT",
";",
"lc_property_state",
".",
"lightness_standby",
"=",
"LC_SERVER_LIGHTNESS_STANDBY_DEFAULT",
";",
"lc_property_state",
".",
"ambient_luxlevel_on",
"=",
"LC_SERVER_AMBIENT_LUX_LEVEL_ON_DEFAULT",
";",
"lc_property_state",
".",
"ambient_luxlevel_prolong",
"=",
"LC_SERVER_AMBIENT_LUX_LEVEL_PROLONG_DEFAULT",
";",
"lc_property_state",
".",
"ambient_luxlevel_standby",
"=",
"LC_SERVER_AMBIENT_LUX_LEVEL_STANDBY_DEFAULT",
";",
"#endif",
"lc_property_state",
".",
"regulator_kiu",
"=",
"LC_REGULATOR_KIU_DEFAULT",
";",
"lc_property_state",
".",
"regulator_kid",
"=",
"LC_REGULATOR_KID_DEFAULT",
";",
"lc_property_state",
".",
"regulator_kpu",
"=",
"LC_REGULATOR_KPU_DEFAULT",
";",
"lc_property_state",
".",
"regulator_kpd",
"=",
"LC_REGULATOR_KPD_DEFAULT",
";",
"lc_property_state",
".",
"regulator_accuracy",
"=",
"LC_REGULATOR_ACCURACY_DEFAULT",
";",
"if",
"(",
"sc",
"==",
"SL_STATUS_OK",
")",
"{",
"sc",
"=",
"SL_STATUS_INVALID_STATE",
";",
"log",
"(",
"\"",
"\"",
"\"",
"\\r",
"\\n",
"\"",
",",
"sizeof",
"(",
"lc_property_state",
")",
",",
"ps_len",
")",
";",
"}",
"else",
"{",
"log_status_f",
"(",
"sc",
",",
"\"",
"\"",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"}",
"else",
"{",
"memcpy",
"(",
"&",
"lc_property_state",
",",
"&",
"ps_data",
",",
"ps_len",
")",
";",
"}",
"return",
"sc",
";",
"}"
] | This function loads the saved light controller property state from Persistent
Storage and copies the data in the global variable lc_property_state. | [
"This",
"function",
"loads",
"the",
"saved",
"light",
"controller",
"property",
"state",
"from",
"Persistent",
"Storage",
"and",
"copies",
"the",
"data",
"in",
"the",
"global",
"variable",
"lc_property_state",
"."
] | [
"// Set default values if ps_load fail or size of lc_property_state has changed",
"// LC_SERVER_PROPERTY_STATE_DEFAULT_ENABLE",
"// The sl_bt_nvm_load call was successful but the size of the loaded data",
"// differs from the expected size therefore error code shall be set"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_property_state_store | int | static int lc_property_state_store(void)
{
sl_status_t sc;
sc = sl_bt_nvm_save(LC_SERVER_PROPERTY_PS_KEY,
sizeof(struct lc_property_state),
(const uint8_t *)&lc_property_state);
log_status_level_f(APP_LOG_LEVEL_ERROR,
sc,
"LC server lc_property_state store in PS failed.\r\n");
return sc;
} | /***************************************************************************/
/**
* This function saves the current light controller property state in Persistent
* Storage so that the data is preserved over reboots and power cycles.
* The light controller property state is hold in a global variable
* lc_property_state. A PS key with ID 0x4006 is used to store the
* whole structure.
*
* @return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise.
******************************************************************************/ | This function saves the current light controller property state in Persistent
Storage so that the data is preserved over reboots and power cycles.
The light controller property state is hold in a global variable
lc_property_state. A PS key with ID 0x4006 is used to store the
whole structure.
@return Returns SL_STATUS_OK (0) if succeed, non-zero otherwise. | [
"This",
"function",
"saves",
"the",
"current",
"light",
"controller",
"property",
"state",
"in",
"Persistent",
"Storage",
"so",
"that",
"the",
"data",
"is",
"preserved",
"over",
"reboots",
"and",
"power",
"cycles",
".",
"The",
"light",
"controller",
"property",
"state",
"is",
"hold",
"in",
"a",
"global",
"variable",
"lc_property_state",
".",
"A",
"PS",
"key",
"with",
"ID",
"0x4006",
"is",
"used",
"to",
"store",
"the",
"whole",
"structure",
".",
"@return",
"Returns",
"SL_STATUS_OK",
"(",
"0",
")",
"if",
"succeed",
"non",
"-",
"zero",
"otherwise",
"."
] | static int lc_property_state_store(void)
{
sl_status_t sc;
sc = sl_bt_nvm_save(LC_SERVER_PROPERTY_PS_KEY,
sizeof(struct lc_property_state),
(const uint8_t *)&lc_property_state);
log_status_level_f(APP_LOG_LEVEL_ERROR,
sc,
"LC server lc_property_state store in PS failed.\r\n");
return sc;
} | [
"static",
"int",
"lc_property_state_store",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
";",
"sc",
"=",
"sl_bt_nvm_save",
"(",
"LC_SERVER_PROPERTY_PS_KEY",
",",
"sizeof",
"(",
"struct",
"lc_property_state",
")",
",",
"(",
"const",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
")",
";",
"log_status_level_f",
"(",
"APP_LOG_LEVEL_ERROR",
",",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"return",
"sc",
";",
"}"
] | This function saves the current light controller property state in Persistent
Storage so that the data is preserved over reboots and power cycles. | [
"This",
"function",
"saves",
"the",
"current",
"light",
"controller",
"property",
"state",
"in",
"Persistent",
"Storage",
"so",
"that",
"the",
"data",
"is",
"preserved",
"over",
"reboots",
"and",
"power",
"cycles",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_property_state_changed | void | static void lc_property_state_changed(void)
{
sl_status_t sc = sl_simple_timer_start(&lc_save_property_state_timer,
LC_SERVER_NVM_SAVE_TIME,
lc_save_property_state_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC Property Save timer\n");
} | /***************************************************************************/
/**
* This function is called each time the light controller property state in RAM
* is changed. It sets up a soft timer that will save the state in flash after
* small delay. The purpose is to reduce amount of unnecessary flash writes.
******************************************************************************/ | This function is called each time the light controller property state in RAM
is changed. It sets up a soft timer that will save the state in flash after
small delay. The purpose is to reduce amount of unnecessary flash writes. | [
"This",
"function",
"is",
"called",
"each",
"time",
"the",
"light",
"controller",
"property",
"state",
"in",
"RAM",
"is",
"changed",
".",
"It",
"sets",
"up",
"a",
"soft",
"timer",
"that",
"will",
"save",
"the",
"state",
"in",
"flash",
"after",
"small",
"delay",
".",
"The",
"purpose",
"is",
"to",
"reduce",
"amount",
"of",
"unnecessary",
"flash",
"writes",
"."
] | static void lc_property_state_changed(void)
{
sl_status_t sc = sl_simple_timer_start(&lc_save_property_state_timer,
LC_SERVER_NVM_SAVE_TIME,
lc_save_property_state_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC Property Save timer\n");
} | [
"static",
"void",
"lc_property_state_changed",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
"=",
"sl_simple_timer_start",
"(",
"&",
"lc_save_property_state_timer",
",",
"LC_SERVER_NVM_SAVE_TIME",
",",
"lc_save_property_state_timer_cb",
",",
"NO_CALLBACK_DATA",
",",
"false",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\n",
"\"",
")",
";",
"}"
] | This function is called each time the light controller property state in RAM
is changed. | [
"This",
"function",
"is",
"called",
"each",
"time",
"the",
"light",
"controller",
"property",
"state",
"in",
"RAM",
"is",
"changed",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | update_property | void | static void update_property(uint16_t element, const uint8_t *property_data)
{
uint16_t property_id = (uint16_t)property_data[0]
| ((uint16_t)property_data[1] << 8);
sl_status_t sc =
sl_btmesh_lc_setup_server_update_property(element,
property_id,
property_data[2],
&property_data[3]);
log_btmesh_status_f(sc,
"lc_setup_server_update_property failed "
"(elem=%d,property=0x%04x)\r\n",
element,
property_id);
} | /***************************************************************************/
/**
* This function update property in stack based on property data.
*
* @param[in] element Index of the element.
* @param[in] property_data Pointer to property data array that contains:
* - property ID in first two bytes,
* - length of data in third byte,
* - property value in the next bytes.
******************************************************************************/ | This function update property in stack based on property data.
@param[in] element Index of the element.
@param[in] property_data Pointer to property data array that contains:
- property ID in first two bytes,
- length of data in third byte,
- property value in the next bytes. | [
"This",
"function",
"update",
"property",
"in",
"stack",
"based",
"on",
"property",
"data",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
".",
"@param",
"[",
"in",
"]",
"property_data",
"Pointer",
"to",
"property",
"data",
"array",
"that",
"contains",
":",
"-",
"property",
"ID",
"in",
"first",
"two",
"bytes",
"-",
"length",
"of",
"data",
"in",
"third",
"byte",
"-",
"property",
"value",
"in",
"the",
"next",
"bytes",
"."
] | static void update_property(uint16_t element, const uint8_t *property_data)
{
uint16_t property_id = (uint16_t)property_data[0]
| ((uint16_t)property_data[1] << 8);
sl_status_t sc =
sl_btmesh_lc_setup_server_update_property(element,
property_id,
property_data[2],
&property_data[3]);
log_btmesh_status_f(sc,
"lc_setup_server_update_property failed "
"(elem=%d,property=0x%04x)\r\n",
element,
property_id);
} | [
"static",
"void",
"update_property",
"(",
"uint16_t",
"element",
",",
"const",
"uint8_t",
"*",
"property_data",
")",
"{",
"uint16_t",
"property_id",
"=",
"(",
"uint16_t",
")",
"property_data",
"[",
"0",
"]",
"|",
"(",
"(",
"uint16_t",
")",
"property_data",
"[",
"1",
"]",
"<<",
"8",
")",
";",
"sl_status_t",
"sc",
"=",
"sl_btmesh_lc_setup_server_update_property",
"(",
"element",
",",
"property_id",
",",
"property_data",
"[",
"2",
"]",
",",
"&",
"property_data",
"[",
"3",
"]",
")",
";",
"log_btmesh_status_f",
"(",
"sc",
",",
"\"",
"\"",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
",",
"property_id",
")",
";",
"}"
] | This function update property in stack based on property data. | [
"This",
"function",
"update",
"property",
"in",
"stack",
"based",
"on",
"property",
"data",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
},
{
"param": "property_data",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "property_data",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_occupancy_delay_update | void | static void lc_time_occupancy_delay_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_occupancy_delay delay = lc_property_state.time_occupancy_delay;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_OCCUPANCY_DELAY,
property_data,
(uint8_t *)&delay);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Occupancy Delay property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Occupancy Delay property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Occupancy",
"Delay",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_occupancy_delay_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_occupancy_delay delay = lc_property_state.time_occupancy_delay;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_OCCUPANCY_DELAY,
property_data,
(uint8_t *)&delay);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_occupancy_delay_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_occupancy_delay",
"delay",
"=",
"lc_property_state",
".",
"time_occupancy_delay",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_OCCUPANCY_DELAY",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"delay",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Occupancy Delay property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Occupancy",
"Delay",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_fade_on_update | void | static void lc_time_fade_on_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_fade_on fade_on = lc_property_state.time_fade_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_ON,
property_data,
(uint8_t *)&fade_on);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Fade On property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Fade On property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"On",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_fade_on_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_fade_on fade_on = lc_property_state.time_fade_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_ON,
property_data,
(uint8_t *)&fade_on);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_fade_on_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_fade_on",
"fade_on",
"=",
"lc_property_state",
".",
"time_fade_on",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_ON",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"fade_on",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Fade On property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"On",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_run_on_update | void | static void lc_time_run_on_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_run_on run_on = lc_property_state.time_run_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_RUN_ON,
property_data,
(uint8_t *)&run_on);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Run On property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Run On property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Run",
"On",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_run_on_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_run_on run_on = lc_property_state.time_run_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_RUN_ON,
property_data,
(uint8_t *)&run_on);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_run_on_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_run_on",
"run_on",
"=",
"lc_property_state",
".",
"time_run_on",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_RUN_ON",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"run_on",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Run On property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Run",
"On",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_fade_update | void | static void lc_time_fade_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_fade fade = lc_property_state.time_fade;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE,
property_data,
(uint8_t *)&fade);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Fade property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Fade property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_fade_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_fade fade = lc_property_state.time_fade;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE,
property_data,
(uint8_t *)&fade);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_fade_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_fade",
"fade",
"=",
"lc_property_state",
".",
"time_fade",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_FADE",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"fade",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Fade property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_prolong_update | void | static void lc_time_prolong_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_prolong prolong = lc_property_state.time_prolong;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_PROLONG,
property_data,
(uint8_t *)&prolong);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Prolong property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Prolong property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Prolong",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_prolong_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_prolong prolong = lc_property_state.time_prolong;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_PROLONG,
property_data,
(uint8_t *)&prolong);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_prolong_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_prolong",
"prolong",
"=",
"lc_property_state",
".",
"time_prolong",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_PROLONG",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"prolong",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Prolong property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Prolong",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_fade_standby_auto_update | void | static void lc_time_fade_standby_auto_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_standby_auto standby_auto = lc_property_state.time_fade_standby_auto;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO,
property_data,
(uint8_t *)&standby_auto);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Fade Standby Auto property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Fade Standby Auto property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"Standby",
"Auto",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_fade_standby_auto_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_standby_auto standby_auto = lc_property_state.time_fade_standby_auto;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO,
property_data,
(uint8_t *)&standby_auto);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_fade_standby_auto_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_standby_auto",
"standby_auto",
"=",
"lc_property_state",
".",
"time_fade_standby_auto",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"standby_auto",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Fade Standby Auto property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"Standby",
"Auto",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_time_fade_standby_manual_update | void | static void lc_time_fade_standby_manual_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_standby_manual standby_manual = lc_property_state.time_fade_standby_manual;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL,
property_data,
(uint8_t *)&standby_manual);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Time Fade Standby Manual property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Time Fade Standby Manual property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"Standby",
"Manual",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_time_fade_standby_manual_update(uint16_t element)
{
uint8_t property_data[6];
light_control_time_standby_manual standby_manual = lc_property_state.time_fade_standby_manual;
mesh_sensor_data_to_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL,
property_data,
(uint8_t *)&standby_manual);
update_property(element, property_data);
} | [
"static",
"void",
"lc_time_fade_standby_manual_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"light_control_time_standby_manual",
"standby_manual",
"=",
"lc_property_state",
".",
"time_fade_standby_manual",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"standby_manual",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Time Fade Standby Manual property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Time",
"Fade",
"Standby",
"Manual",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_lightness_on_update | void | static void lc_lightness_on_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_ON,
property_data,
(uint8_t *)&lc_property_state.lightness_on);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Lightness On property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Lightness On property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"On",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_lightness_on_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_ON,
property_data,
(uint8_t *)&lc_property_state.lightness_on);
update_property(element, property_data);
} | [
"static",
"void",
"lc_lightness_on_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"5",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_ON",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"lightness_on",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Lightness On property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"On",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_lightness_prolong_update | void | static void lc_lightness_prolong_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_PROLONG,
property_data,
(uint8_t *)&lc_property_state.lightness_prolong);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Lightness Prolong property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Lightness Prolong property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"Prolong",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_lightness_prolong_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_PROLONG,
property_data,
(uint8_t *)&lc_property_state.lightness_prolong);
update_property(element, property_data);
} | [
"static",
"void",
"lc_lightness_prolong_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"5",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_PROLONG",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"lightness_prolong",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Lightness Prolong property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"Prolong",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_lightness_standby_update | void | static void lc_lightness_standby_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_STANDBY,
property_data,
(uint8_t *)&lc_property_state.lightness_standby);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Lightness Standby property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Lightness Standby property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"Standby",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_lightness_standby_update(uint16_t element)
{
uint8_t property_data[5];
mesh_sensor_data_to_buf(LIGHT_CONTROL_LIGHTNESS_STANDBY,
property_data,
(uint8_t *)&lc_property_state.lightness_standby);
update_property(element, property_data);
} | [
"static",
"void",
"lc_lightness_standby_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"5",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_STANDBY",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"lightness_standby",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Lightness Standby property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Lightness",
"Standby",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_ambient_luxlevel_on_update | void | static void lc_ambient_luxlevel_on_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_on = lc_property_state.ambient_luxlevel_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON,
property_data,
(uint8_t *)&ambient_luxlevel_on);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Ambient LuxLevel On property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Ambient LuxLevel On property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"On",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_ambient_luxlevel_on_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_on = lc_property_state.ambient_luxlevel_on;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON,
property_data,
(uint8_t *)&ambient_luxlevel_on);
update_property(element, property_data);
} | [
"static",
"void",
"lc_ambient_luxlevel_on_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"illuminance_t",
"ambient_luxlevel_on",
"=",
"lc_property_state",
".",
"ambient_luxlevel_on",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"ambient_luxlevel_on",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Ambient LuxLevel On property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"On",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_ambient_luxlevel_prolong_update | void | static void lc_ambient_luxlevel_prolong_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_prolong = lc_property_state.ambient_luxlevel_prolong;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG,
property_data,
(uint8_t *)&ambient_luxlevel_prolong);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Ambient LuxLevel Prolong property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Ambient LuxLevel Prolong property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"Prolong",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_ambient_luxlevel_prolong_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_prolong = lc_property_state.ambient_luxlevel_prolong;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG,
property_data,
(uint8_t *)&ambient_luxlevel_prolong);
update_property(element, property_data);
} | [
"static",
"void",
"lc_ambient_luxlevel_prolong_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"illuminance_t",
"ambient_luxlevel_prolong",
"=",
"lc_property_state",
".",
"ambient_luxlevel_prolong",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"ambient_luxlevel_prolong",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Ambient LuxLevel Prolong property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"Prolong",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_ambient_luxlevel_standby_update | void | static void lc_ambient_luxlevel_standby_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_standby = lc_property_state.ambient_luxlevel_standby;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY,
property_data,
(uint8_t *)&ambient_luxlevel_standby);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Ambient LuxLevel Standby property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Ambient LuxLevel Standby property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"Standby",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_ambient_luxlevel_standby_update(uint16_t element)
{
uint8_t property_data[6];
illuminance_t ambient_luxlevel_standby = lc_property_state.ambient_luxlevel_standby;
mesh_sensor_data_to_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY,
property_data,
(uint8_t *)&ambient_luxlevel_standby);
update_property(element, property_data);
} | [
"static",
"void",
"lc_ambient_luxlevel_standby_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"6",
"]",
";",
"illuminance_t",
"ambient_luxlevel_standby",
"=",
"lc_property_state",
".",
"ambient_luxlevel_standby",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"ambient_luxlevel_standby",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Ambient LuxLevel Standby property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Ambient",
"LuxLevel",
"Standby",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_regulator_kiu_update | void | static void lc_regulator_kiu_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KIU,
property_data,
(uint8_t *)&lc_property_state.regulator_kiu);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Regulator Kiu property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Regulator Kiu property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kiu",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_regulator_kiu_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KIU,
property_data,
(uint8_t *)&lc_property_state.regulator_kiu);
update_property(element, property_data);
} | [
"static",
"void",
"lc_regulator_kiu_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"7",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KIU",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"regulator_kiu",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Regulator Kiu property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kiu",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_regulator_kid_update | void | static void lc_regulator_kid_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KID,
property_data,
(uint8_t *)&lc_property_state.regulator_kid);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Regulator Kid property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Regulator Kid property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kid",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_regulator_kid_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KID,
property_data,
(uint8_t *)&lc_property_state.regulator_kid);
update_property(element, property_data);
} | [
"static",
"void",
"lc_regulator_kid_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"7",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KID",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"regulator_kid",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Regulator Kid property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kid",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_regulator_kpu_update | void | static void lc_regulator_kpu_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KPU,
property_data,
(uint8_t *)&lc_property_state.regulator_kpu);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Regulator Kpu property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Regulator Kpu property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kpu",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_regulator_kpu_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KPU,
property_data,
(uint8_t *)&lc_property_state.regulator_kpu);
update_property(element, property_data);
} | [
"static",
"void",
"lc_regulator_kpu_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"7",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KPU",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"regulator_kpu",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Regulator Kpu property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kpu",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_regulator_kpd_update | void | static void lc_regulator_kpd_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KPD,
property_data,
(uint8_t *)&lc_property_state.regulator_kpd);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Regulator Kpd property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Regulator Kpd property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kpd",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_regulator_kpd_update(uint16_t element)
{
uint8_t property_data[7];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_KPD,
property_data,
(uint8_t *)&lc_property_state.regulator_kpd);
update_property(element, property_data);
} | [
"static",
"void",
"lc_regulator_kpd_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"7",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KPD",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"regulator_kpd",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Regulator Kpd property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Kpd",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_regulator_accuracy_update | void | static void lc_regulator_accuracy_update(uint16_t element)
{
uint8_t property_data[4];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_ACCURACY,
property_data,
(uint8_t *)&lc_property_state.regulator_accuracy);
update_property(element, property_data);
} | /***************************************************************************/
/**
* This function update Light LC Regulator Accuracy property in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update Light LC Regulator Accuracy property in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Accuracy",
"property",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_regulator_accuracy_update(uint16_t element)
{
uint8_t property_data[4];
mesh_sensor_data_to_buf(LIGHT_CONTROL_REGULATOR_ACCURACY,
property_data,
(uint8_t *)&lc_property_state.regulator_accuracy);
update_property(element, property_data);
} | [
"static",
"void",
"lc_regulator_accuracy_update",
"(",
"uint16_t",
"element",
")",
"{",
"uint8_t",
"property_data",
"[",
"4",
"]",
";",
"mesh_sensor_data_to_buf",
"(",
"LIGHT_CONTROL_REGULATOR_ACCURACY",
",",
"property_data",
",",
"(",
"uint8_t",
"*",
")",
"&",
"lc_property_state",
".",
"regulator_accuracy",
")",
";",
"update_property",
"(",
"element",
",",
"property_data",
")",
";",
"}"
] | This function update Light LC Regulator Accuracy property in stack. | [
"This",
"function",
"update",
"Light",
"LC",
"Regulator",
"Accuracy",
"property",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_property_state_update | void | static void lc_property_state_update(uint16_t element)
{
lc_time_occupancy_delay_update(element);
lc_time_fade_on_update(element);
lc_time_run_on_update(element);
lc_time_fade_update(element);
lc_time_prolong_update(element);
lc_time_fade_standby_auto_update(element);
lc_time_fade_standby_manual_update(element);
lc_lightness_on_update(element);
lc_lightness_prolong_update(element);
lc_lightness_standby_update(element);
lc_ambient_luxlevel_on_update(element);
lc_ambient_luxlevel_prolong_update(element);
lc_ambient_luxlevel_standby_update(element);
lc_regulator_kiu_update(element);
lc_regulator_kid_update(element);
lc_regulator_kpu_update(element);
lc_regulator_kpd_update(element);
lc_regulator_accuracy_update(element);
} | /***************************************************************************/
/**
* This function update all light controller properties in stack.
*
* @param[in] element Index of the element.
******************************************************************************/ | This function update all light controller properties in stack.
@param[in] element Index of the element. | [
"This",
"function",
"update",
"all",
"light",
"controller",
"properties",
"in",
"stack",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"."
] | static void lc_property_state_update(uint16_t element)
{
lc_time_occupancy_delay_update(element);
lc_time_fade_on_update(element);
lc_time_run_on_update(element);
lc_time_fade_update(element);
lc_time_prolong_update(element);
lc_time_fade_standby_auto_update(element);
lc_time_fade_standby_manual_update(element);
lc_lightness_on_update(element);
lc_lightness_prolong_update(element);
lc_lightness_standby_update(element);
lc_ambient_luxlevel_on_update(element);
lc_ambient_luxlevel_prolong_update(element);
lc_ambient_luxlevel_standby_update(element);
lc_regulator_kiu_update(element);
lc_regulator_kid_update(element);
lc_regulator_kpu_update(element);
lc_regulator_kpd_update(element);
lc_regulator_accuracy_update(element);
} | [
"static",
"void",
"lc_property_state_update",
"(",
"uint16_t",
"element",
")",
"{",
"lc_time_occupancy_delay_update",
"(",
"element",
")",
";",
"lc_time_fade_on_update",
"(",
"element",
")",
";",
"lc_time_run_on_update",
"(",
"element",
")",
";",
"lc_time_fade_update",
"(",
"element",
")",
";",
"lc_time_prolong_update",
"(",
"element",
")",
";",
"lc_time_fade_standby_auto_update",
"(",
"element",
")",
";",
"lc_time_fade_standby_manual_update",
"(",
"element",
")",
";",
"lc_lightness_on_update",
"(",
"element",
")",
";",
"lc_lightness_prolong_update",
"(",
"element",
")",
";",
"lc_lightness_standby_update",
"(",
"element",
")",
";",
"lc_ambient_luxlevel_on_update",
"(",
"element",
")",
";",
"lc_ambient_luxlevel_prolong_update",
"(",
"element",
")",
";",
"lc_ambient_luxlevel_standby_update",
"(",
"element",
")",
";",
"lc_regulator_kiu_update",
"(",
"element",
")",
";",
"lc_regulator_kid_update",
"(",
"element",
")",
";",
"lc_regulator_kpu_update",
"(",
"element",
")",
";",
"lc_regulator_kpd_update",
"(",
"element",
")",
";",
"lc_regulator_accuracy_update",
"(",
"element",
")",
";",
"}"
] | This function update all light controller properties in stack. | [
"This",
"function",
"update",
"all",
"light",
"controller",
"properties",
"in",
"stack",
"."
] | [] | [
{
"param": "element",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | sl_btmesh_lc_init | sl_status_t | sl_status_t sl_btmesh_lc_init(void)
{
// Initialize lc server models
const uint16_t element = BTMESH_LC_SERVER_LIGHT_LC;
sl_status_t result;
sl_status_t sc;
result = sl_btmesh_lc_server_init(element);
log_status_f(result,
"sl_btmesh_lc_server_init failed (elem=%d)\r\n",
element);
memset(&lc_state, 0, sizeof(lc_state));
lc_state_load();
memset(&lc_property_state, 0, sizeof(lc_property_state));
lc_property_state_load();
// Set the regulator interval to 100 milliseconds. If you want to use shorter
// intervals, you should disable some logs in order not to affect performance.
sc = sl_btmesh_lc_server_set_regulator_interval(element, 100);
log_status_f(sc, "sl_btmesh_lc_server_init failed (elem=%d)\r\n", element);
lc_property_state_update(element);
lc_property_state_changed();
lc_onpowerup_update(element, sl_btmesh_get_lightness_onpowerup());
init_models();
// The status code of the sl_btmesh_lc_server_init is returned because the
// successful initialization of the btmesh stack lc feature is essential
// for the proper behavior of the module while the improper setup of some
// properties and states are not that critical.
return result;
} | /*******************************************************************************
* LC initialization.
* This should be called at each boot if provisioning is already done.
* Otherwise this function should be called after provisioning is completed.
*
* @param[in] element Index of the element where LC model is initialized.
*
* @return Status of the initialization operation.
* Returns SL_STATUS_OK (0) if succeed, non-zero otherwise.
******************************************************************************/ | LC initialization.
This should be called at each boot if provisioning is already done.
Otherwise this function should be called after provisioning is completed.
@param[in] element Index of the element where LC model is initialized.
@return Status of the initialization operation.
Returns SL_STATUS_OK (0) if succeed, non-zero otherwise. | [
"LC",
"initialization",
".",
"This",
"should",
"be",
"called",
"at",
"each",
"boot",
"if",
"provisioning",
"is",
"already",
"done",
".",
"Otherwise",
"this",
"function",
"should",
"be",
"called",
"after",
"provisioning",
"is",
"completed",
".",
"@param",
"[",
"in",
"]",
"element",
"Index",
"of",
"the",
"element",
"where",
"LC",
"model",
"is",
"initialized",
".",
"@return",
"Status",
"of",
"the",
"initialization",
"operation",
".",
"Returns",
"SL_STATUS_OK",
"(",
"0",
")",
"if",
"succeed",
"non",
"-",
"zero",
"otherwise",
"."
] | sl_status_t sl_btmesh_lc_init(void)
{
const uint16_t element = BTMESH_LC_SERVER_LIGHT_LC;
sl_status_t result;
sl_status_t sc;
result = sl_btmesh_lc_server_init(element);
log_status_f(result,
"sl_btmesh_lc_server_init failed (elem=%d)\r\n",
element);
memset(&lc_state, 0, sizeof(lc_state));
lc_state_load();
memset(&lc_property_state, 0, sizeof(lc_property_state));
lc_property_state_load();
sc = sl_btmesh_lc_server_set_regulator_interval(element, 100);
log_status_f(sc, "sl_btmesh_lc_server_init failed (elem=%d)\r\n", element);
lc_property_state_update(element);
lc_property_state_changed();
lc_onpowerup_update(element, sl_btmesh_get_lightness_onpowerup());
init_models();
return result;
} | [
"sl_status_t",
"sl_btmesh_lc_init",
"(",
"void",
")",
"{",
"const",
"uint16_t",
"element",
"=",
"BTMESH_LC_SERVER_LIGHT_LC",
";",
"sl_status_t",
"result",
";",
"sl_status_t",
"sc",
";",
"result",
"=",
"sl_btmesh_lc_server_init",
"(",
"element",
")",
";",
"log_status_f",
"(",
"result",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
")",
";",
"memset",
"(",
"&",
"lc_state",
",",
"0",
",",
"sizeof",
"(",
"lc_state",
")",
")",
";",
"lc_state_load",
"(",
")",
";",
"memset",
"(",
"&",
"lc_property_state",
",",
"0",
",",
"sizeof",
"(",
"lc_property_state",
")",
")",
";",
"lc_property_state_load",
"(",
")",
";",
"sc",
"=",
"sl_btmesh_lc_server_set_regulator_interval",
"(",
"element",
",",
"100",
")",
";",
"log_status_f",
"(",
"sc",
",",
"\"",
"\\r",
"\\n",
"\"",
",",
"element",
")",
";",
"lc_property_state_update",
"(",
"element",
")",
";",
"lc_property_state_changed",
"(",
")",
";",
"lc_onpowerup_update",
"(",
"element",
",",
"sl_btmesh_get_lightness_onpowerup",
"(",
")",
")",
";",
"init_models",
"(",
")",
";",
"return",
"result",
";",
"}"
] | LC initialization. | [
"LC",
"initialization",
"."
] | [
"// Initialize lc server models",
"// Set the regulator interval to 100 milliseconds. If you want to use shorter",
"// intervals, you should disable some logs in order not to affect performance.",
"// The status code of the sl_btmesh_lc_server_init is returned because the",
"// successful initialization of the btmesh stack lc feature is essential",
"// for the proper behavior of the module while the improper setup of some",
"// properties and states are not that critical."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | handle_lc_server_mode_updated_event | void | static void handle_lc_server_mode_updated_event(
sl_btmesh_evt_lc_server_mode_updated_t *evt)
{
lc_state.mode = evt->mode_value;
lc_state_changed();
} | /***************************************************************************/
/**
* Handling of lc server mode updated event.
*
* @param[in] evt Pointer to lc server mode updated event.
******************************************************************************/ | Handling of lc server mode updated event.
@param[in] evt Pointer to lc server mode updated event. | [
"Handling",
"of",
"lc",
"server",
"mode",
"updated",
"event",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"lc",
"server",
"mode",
"updated",
"event",
"."
] | static void handle_lc_server_mode_updated_event(
sl_btmesh_evt_lc_server_mode_updated_t *evt)
{
lc_state.mode = evt->mode_value;
lc_state_changed();
} | [
"static",
"void",
"handle_lc_server_mode_updated_event",
"(",
"sl_btmesh_evt_lc_server_mode_updated_t",
"*",
"evt",
")",
"{",
"lc_state",
".",
"mode",
"=",
"evt",
"->",
"mode_value",
";",
"lc_state_changed",
"(",
")",
";",
"}"
] | Handling of lc server mode updated event. | [
"Handling",
"of",
"lc",
"server",
"mode",
"updated",
"event",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_evt_lc_server_mode_updated_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_lc_server_mode_updated_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | handle_lc_server_om_updated_event | void | static void handle_lc_server_om_updated_event(
sl_btmesh_evt_lc_server_om_updated_t *evt)
{
log("evt:sl_btmesh_evt_lc_server_om_updated_id, om=%u\r\n", evt->om_value);
lc_state.occupancy_mode = evt->om_value;
lc_state_changed();
} | /***************************************************************************/
/**
* Handling of lc server occupancy mode updated event.
*
* @param[in] evt Pointer to lc server occupancy mode updated event.
******************************************************************************/ | Handling of lc server occupancy mode updated event.
@param[in] evt Pointer to lc server occupancy mode updated event. | [
"Handling",
"of",
"lc",
"server",
"occupancy",
"mode",
"updated",
"event",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"lc",
"server",
"occupancy",
"mode",
"updated",
"event",
"."
] | static void handle_lc_server_om_updated_event(
sl_btmesh_evt_lc_server_om_updated_t *evt)
{
log("evt:sl_btmesh_evt_lc_server_om_updated_id, om=%u\r\n", evt->om_value);
lc_state.occupancy_mode = evt->om_value;
lc_state_changed();
} | [
"static",
"void",
"handle_lc_server_om_updated_event",
"(",
"sl_btmesh_evt_lc_server_om_updated_t",
"*",
"evt",
")",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"evt",
"->",
"om_value",
")",
";",
"lc_state",
".",
"occupancy_mode",
"=",
"evt",
"->",
"om_value",
";",
"lc_state_changed",
"(",
")",
";",
"}"
] | Handling of lc server occupancy mode updated event. | [
"Handling",
"of",
"lc",
"server",
"occupancy",
"mode",
"updated",
"event",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_evt_lc_server_om_updated_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_lc_server_om_updated_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | handle_lc_server_light_onoff_updated_event | void | static void handle_lc_server_light_onoff_updated_event(
sl_btmesh_evt_lc_server_light_onoff_updated_t *evt)
{
lc_state.light_onoff = evt->onoff_state;
lc_state_changed();
} | /***************************************************************************/
/**
* Handling of lc server light onoff updated event.
*
* @param[in] evt Pointer to lc server light onoff updated event.
******************************************************************************/ | Handling of lc server light onoff updated event.
@param[in] evt Pointer to lc server light onoff updated event. | [
"Handling",
"of",
"lc",
"server",
"light",
"onoff",
"updated",
"event",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"lc",
"server",
"light",
"onoff",
"updated",
"event",
"."
] | static void handle_lc_server_light_onoff_updated_event(
sl_btmesh_evt_lc_server_light_onoff_updated_t *evt)
{
lc_state.light_onoff = evt->onoff_state;
lc_state_changed();
} | [
"static",
"void",
"handle_lc_server_light_onoff_updated_event",
"(",
"sl_btmesh_evt_lc_server_light_onoff_updated_t",
"*",
"evt",
")",
"{",
"lc_state",
".",
"light_onoff",
"=",
"evt",
"->",
"onoff_state",
";",
"lc_state_changed",
"(",
")",
";",
"}"
] | Handling of lc server light onoff updated event. | [
"Handling",
"of",
"lc",
"server",
"light",
"onoff",
"updated",
"event",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_evt_lc_server_light_onoff_updated_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_lc_server_light_onoff_updated_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | handle_lc_server_linear_output_updated_event | void | static void handle_lc_server_linear_output_updated_event(
sl_btmesh_evt_lc_server_linear_output_updated_t *evt)
{
// Convert from linear to actual lightness value
uint32_t lightness = (uint32_t)sqrt(65535
* (uint32_t)(evt->linear_output_value));
// Update LED
sl_btmesh_lighting_set_level(lightness, IMMEDIATE);
} | /***************************************************************************/
/**
* Handling of lc server linear output updated event.
*
* @param[in] evt Pointer to lc server linear output updated event.
******************************************************************************/ | Handling of lc server linear output updated event.
@param[in] evt Pointer to lc server linear output updated event. | [
"Handling",
"of",
"lc",
"server",
"linear",
"output",
"updated",
"event",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"lc",
"server",
"linear",
"output",
"updated",
"event",
"."
] | static void handle_lc_server_linear_output_updated_event(
sl_btmesh_evt_lc_server_linear_output_updated_t *evt)
{
uint32_t lightness = (uint32_t)sqrt(65535
* (uint32_t)(evt->linear_output_value));
sl_btmesh_lighting_set_level(lightness, IMMEDIATE);
} | [
"static",
"void",
"handle_lc_server_linear_output_updated_event",
"(",
"sl_btmesh_evt_lc_server_linear_output_updated_t",
"*",
"evt",
")",
"{",
"uint32_t",
"lightness",
"=",
"(",
"uint32_t",
")",
"sqrt",
"(",
"65535",
"*",
"(",
"uint32_t",
")",
"(",
"evt",
"->",
"linear_output_value",
")",
")",
";",
"sl_btmesh_lighting_set_level",
"(",
"lightness",
",",
"IMMEDIATE",
")",
";",
"}"
] | Handling of lc server linear output updated event. | [
"Handling",
"of",
"lc",
"server",
"linear",
"output",
"updated",
"event",
"."
] | [
"// Convert from linear to actual lightness value",
"// Update LED"
] | [
{
"param": "evt",
"type": "sl_btmesh_evt_lc_server_linear_output_updated_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_lc_server_linear_output_updated_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | print_float | void | static void print_float(float number)
{
if (number > INT32_MAX) {
log("> %ld", INT32_MAX);
} else if (number < INT32_MIN) {
log("< %ld", INT32_MIN);
} else {
log("%ld.%03u", (int32_t)number, FRACTION(number));
}
} | /***************************************************************************/
/**
* Printing the float number using integers.
*
* @param[in] number Number to print.
******************************************************************************/ | Printing the float number using integers.
@param[in] number Number to print. | [
"Printing",
"the",
"float",
"number",
"using",
"integers",
".",
"@param",
"[",
"in",
"]",
"number",
"Number",
"to",
"print",
"."
] | static void print_float(float number)
{
if (number > INT32_MAX) {
log("> %ld", INT32_MAX);
} else if (number < INT32_MIN) {
log("< %ld", INT32_MIN);
} else {
log("%ld.%03u", (int32_t)number, FRACTION(number));
}
} | [
"static",
"void",
"print_float",
"(",
"float",
"number",
")",
"{",
"if",
"(",
"number",
">",
"INT32_MAX",
")",
"{",
"log",
"(",
"\"",
"\"",
",",
"INT32_MAX",
")",
";",
"}",
"else",
"if",
"(",
"number",
"<",
"INT32_MIN",
")",
"{",
"log",
"(",
"\"",
"\"",
",",
"INT32_MIN",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"",
"\"",
",",
"(",
"int32_t",
")",
"number",
",",
"FRACTION",
"(",
"number",
")",
")",
";",
"}",
"}"
] | Printing the float number using integers. | [
"Printing",
"the",
"float",
"number",
"using",
"integers",
"."
] | [] | [
{
"param": "number",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "number",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | handle_lc_setup_server_set_property | void | static void handle_lc_setup_server_set_property(
sl_btmesh_evt_lc_setup_server_set_property_t *evt)
{
for (int i = 0; i < evt->property_value.len; i++) {
log("%2.2x", evt->property_value.data[i]);
}
log("\r\n");
switch (evt->property_id) {
case LIGHT_CONTROL_TIME_OCCUPANCY_DELAY:
lc_property_state.time_occupancy_delay =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_OCCUPANCY_DELAY,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Occupancy Delay = %u.%03us\r\n",
lc_property_state.time_occupancy_delay / 1000,
lc_property_state.time_occupancy_delay % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_ON:
lc_property_state.time_fade_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_ON,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade On = %u.%03us\r\n",
lc_property_state.time_fade_on / 1000,
lc_property_state.time_fade_on % 1000);
break;
case LIGHT_CONTROL_TIME_RUN_ON:
lc_property_state.time_run_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_RUN_ON,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Run On = %u.%03us\r\n",
lc_property_state.time_run_on / 1000,
lc_property_state.time_run_on % 1000);
break;
case LIGHT_CONTROL_TIME_FADE:
lc_property_state.time_fade =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade = %u.%03us\r\n",
lc_property_state.time_fade / 1000,
lc_property_state.time_fade % 1000);
break;
case LIGHT_CONTROL_TIME_PROLONG:
lc_property_state.time_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_PROLONG,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Prolong = %u.%03us\r\n",
lc_property_state.time_prolong / 1000,
lc_property_state.time_prolong % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO:
lc_property_state.time_fade_standby_auto =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade Standby Auto = %u.%03us\r\n",
lc_property_state.time_fade_standby_auto / 1000,
lc_property_state.time_fade_standby_auto % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL:
lc_property_state.time_fade_standby_manual =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade Standby Manual = %u.%03us\r\n",
lc_property_state.time_fade_standby_manual / 1000,
lc_property_state.time_fade_standby_manual % 1000);
break;
case LIGHT_CONTROL_LIGHTNESS_ON:
lc_property_state.lightness_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_ON,
evt->property_value.data)
.uint16;
log("Light Control Lightness On = %u\r\n",
lc_property_state.lightness_on);
break;
case LIGHT_CONTROL_LIGHTNESS_PROLONG:
lc_property_state.lightness_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_PROLONG,
evt->property_value.data)
.uint16;
log("Light Control Lightness Prolong = %u\r\n",
lc_property_state.lightness_prolong);
break;
case LIGHT_CONTROL_LIGHTNESS_STANDBY:
lc_property_state.lightness_standby =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_STANDBY,
evt->property_value.data)
.uint16;
log("Light Control Lightness Standby = %u\r\n",
lc_property_state.lightness_standby);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON:
lc_property_state.ambient_luxlevel_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel On = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_on / 100,
lc_property_state.ambient_luxlevel_on % 100);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG:
lc_property_state.ambient_luxlevel_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel Prolong = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_prolong / 100,
lc_property_state.ambient_luxlevel_prolong % 100);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY:
lc_property_state.ambient_luxlevel_standby =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel Standby = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_standby / 100,
lc_property_state.ambient_luxlevel_standby % 100);
break;
case LIGHT_CONTROL_REGULATOR_KIU:
lc_property_state.regulator_kiu =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KIU,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kiu = ");
print_float(lc_property_state.regulator_kiu);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KID:
lc_property_state.regulator_kid =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KID,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kid = ");
print_float(lc_property_state.regulator_kid);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KPU:
lc_property_state.regulator_kpu =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KPU,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kpu = ");
print_float(lc_property_state.regulator_kpu);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KPD:
lc_property_state.regulator_kpd =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KPD,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kpd = ");
print_float(lc_property_state.regulator_kpd);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_ACCURACY:
lc_property_state.regulator_accuracy =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_ACCURACY,
evt->property_value.data)
.percentage;
if (lc_property_state.regulator_accuracy == 0xFF) {
log("Light Control Regulator Accuracy = Value is not known\r\n");
} else {
log("Light Control Regulator Accuracy = %u.%u%%\r\n",
lc_property_state.regulator_accuracy / 2,
(lc_property_state.regulator_accuracy % 2) * 5);
}
break;
default:
break;
}
lc_property_state_changed();
} | /***************************************************************************/
/**
* Handling of lc setup server set property event.
*
* @param[in] evt Pointer to lc setup server set property event.
******************************************************************************/ | Handling of lc setup server set property event.
@param[in] evt Pointer to lc setup server set property event. | [
"Handling",
"of",
"lc",
"setup",
"server",
"set",
"property",
"event",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"lc",
"setup",
"server",
"set",
"property",
"event",
"."
] | static void handle_lc_setup_server_set_property(
sl_btmesh_evt_lc_setup_server_set_property_t *evt)
{
for (int i = 0; i < evt->property_value.len; i++) {
log("%2.2x", evt->property_value.data[i]);
}
log("\r\n");
switch (evt->property_id) {
case LIGHT_CONTROL_TIME_OCCUPANCY_DELAY:
lc_property_state.time_occupancy_delay =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_OCCUPANCY_DELAY,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Occupancy Delay = %u.%03us\r\n",
lc_property_state.time_occupancy_delay / 1000,
lc_property_state.time_occupancy_delay % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_ON:
lc_property_state.time_fade_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_ON,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade On = %u.%03us\r\n",
lc_property_state.time_fade_on / 1000,
lc_property_state.time_fade_on % 1000);
break;
case LIGHT_CONTROL_TIME_RUN_ON:
lc_property_state.time_run_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_RUN_ON,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Run On = %u.%03us\r\n",
lc_property_state.time_run_on / 1000,
lc_property_state.time_run_on % 1000);
break;
case LIGHT_CONTROL_TIME_FADE:
lc_property_state.time_fade =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade = %u.%03us\r\n",
lc_property_state.time_fade / 1000,
lc_property_state.time_fade % 1000);
break;
case LIGHT_CONTROL_TIME_PROLONG:
lc_property_state.time_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_PROLONG,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Prolong = %u.%03us\r\n",
lc_property_state.time_prolong / 1000,
lc_property_state.time_prolong % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO:
lc_property_state.time_fade_standby_auto =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade Standby Auto = %u.%03us\r\n",
lc_property_state.time_fade_standby_auto / 1000,
lc_property_state.time_fade_standby_auto % 1000);
break;
case LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL:
lc_property_state.time_fade_standby_manual =
mesh_sensor_data_from_buf(LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL,
evt->property_value.data)
.time_millisecond_24;
log("Light Control Time Fade Standby Manual = %u.%03us\r\n",
lc_property_state.time_fade_standby_manual / 1000,
lc_property_state.time_fade_standby_manual % 1000);
break;
case LIGHT_CONTROL_LIGHTNESS_ON:
lc_property_state.lightness_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_ON,
evt->property_value.data)
.uint16;
log("Light Control Lightness On = %u\r\n",
lc_property_state.lightness_on);
break;
case LIGHT_CONTROL_LIGHTNESS_PROLONG:
lc_property_state.lightness_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_PROLONG,
evt->property_value.data)
.uint16;
log("Light Control Lightness Prolong = %u\r\n",
lc_property_state.lightness_prolong);
break;
case LIGHT_CONTROL_LIGHTNESS_STANDBY:
lc_property_state.lightness_standby =
mesh_sensor_data_from_buf(LIGHT_CONTROL_LIGHTNESS_STANDBY,
evt->property_value.data)
.uint16;
log("Light Control Lightness Standby = %u\r\n",
lc_property_state.lightness_standby);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON:
lc_property_state.ambient_luxlevel_on =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel On = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_on / 100,
lc_property_state.ambient_luxlevel_on % 100);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG:
lc_property_state.ambient_luxlevel_prolong =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel Prolong = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_prolong / 100,
lc_property_state.ambient_luxlevel_prolong % 100);
break;
case LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY:
lc_property_state.ambient_luxlevel_standby =
mesh_sensor_data_from_buf(LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY,
evt->property_value.data)
.illuminance;
log("Light Control Ambient LuxLevel Standby = %u.%02ulux\r\n",
lc_property_state.ambient_luxlevel_standby / 100,
lc_property_state.ambient_luxlevel_standby % 100);
break;
case LIGHT_CONTROL_REGULATOR_KIU:
lc_property_state.regulator_kiu =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KIU,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kiu = ");
print_float(lc_property_state.regulator_kiu);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KID:
lc_property_state.regulator_kid =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KID,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kid = ");
print_float(lc_property_state.regulator_kid);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KPU:
lc_property_state.regulator_kpu =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KPU,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kpu = ");
print_float(lc_property_state.regulator_kpu);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_KPD:
lc_property_state.regulator_kpd =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_KPD,
evt->property_value.data)
.coefficient;
log("Light Control Regulator Kpd = ");
print_float(lc_property_state.regulator_kpd);
log("\r\n");
break;
case LIGHT_CONTROL_REGULATOR_ACCURACY:
lc_property_state.regulator_accuracy =
mesh_sensor_data_from_buf(LIGHT_CONTROL_REGULATOR_ACCURACY,
evt->property_value.data)
.percentage;
if (lc_property_state.regulator_accuracy == 0xFF) {
log("Light Control Regulator Accuracy = Value is not known\r\n");
} else {
log("Light Control Regulator Accuracy = %u.%u%%\r\n",
lc_property_state.regulator_accuracy / 2,
(lc_property_state.regulator_accuracy % 2) * 5);
}
break;
default:
break;
}
lc_property_state_changed();
} | [
"static",
"void",
"handle_lc_setup_server_set_property",
"(",
"sl_btmesh_evt_lc_setup_server_set_property_t",
"*",
"evt",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"evt",
"->",
"property_value",
".",
"len",
";",
"i",
"++",
")",
"{",
"log",
"(",
"\"",
"\"",
",",
"evt",
"->",
"property_value",
".",
"data",
"[",
"i",
"]",
")",
";",
"}",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"switch",
"(",
"evt",
"->",
"property_id",
")",
"{",
"case",
"LIGHT_CONTROL_TIME_OCCUPANCY_DELAY",
":",
"lc_property_state",
".",
"time_occupancy_delay",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_OCCUPANCY_DELAY",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_occupancy_delay",
"/",
"1000",
",",
"lc_property_state",
".",
"time_occupancy_delay",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_FADE_ON",
":",
"lc_property_state",
".",
"time_fade_on",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_ON",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_fade_on",
"/",
"1000",
",",
"lc_property_state",
".",
"time_fade_on",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_RUN_ON",
":",
"lc_property_state",
".",
"time_run_on",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_RUN_ON",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_run_on",
"/",
"1000",
",",
"lc_property_state",
".",
"time_run_on",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_FADE",
":",
"lc_property_state",
".",
"time_fade",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_FADE",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_fade",
"/",
"1000",
",",
"lc_property_state",
".",
"time_fade",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_PROLONG",
":",
"lc_property_state",
".",
"time_prolong",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_PROLONG",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_prolong",
"/",
"1000",
",",
"lc_property_state",
".",
"time_prolong",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO",
":",
"lc_property_state",
".",
"time_fade_standby_auto",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_fade_standby_auto",
"/",
"1000",
",",
"lc_property_state",
".",
"time_fade_standby_auto",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL",
":",
"lc_property_state",
".",
"time_fade_standby_manual",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"time_millisecond_24",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"time_fade_standby_manual",
"/",
"1000",
",",
"lc_property_state",
".",
"time_fade_standby_manual",
"%",
"1000",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_LIGHTNESS_ON",
":",
"lc_property_state",
".",
"lightness_on",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_ON",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"uint16",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"lightness_on",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_LIGHTNESS_PROLONG",
":",
"lc_property_state",
".",
"lightness_prolong",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_PROLONG",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"uint16",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"lightness_prolong",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_LIGHTNESS_STANDBY",
":",
"lc_property_state",
".",
"lightness_standby",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_LIGHTNESS_STANDBY",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"uint16",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"lightness_standby",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON",
":",
"lc_property_state",
".",
"ambient_luxlevel_on",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"illuminance",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"ambient_luxlevel_on",
"/",
"100",
",",
"lc_property_state",
".",
"ambient_luxlevel_on",
"%",
"100",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG",
":",
"lc_property_state",
".",
"ambient_luxlevel_prolong",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"illuminance",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"ambient_luxlevel_prolong",
"/",
"100",
",",
"lc_property_state",
".",
"ambient_luxlevel_prolong",
"%",
"100",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY",
":",
"lc_property_state",
".",
"ambient_luxlevel_standby",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"illuminance",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"ambient_luxlevel_standby",
"/",
"100",
",",
"lc_property_state",
".",
"ambient_luxlevel_standby",
"%",
"100",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_REGULATOR_KIU",
":",
"lc_property_state",
".",
"regulator_kiu",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KIU",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"coefficient",
";",
"log",
"(",
"\"",
"\"",
")",
";",
"print_float",
"(",
"lc_property_state",
".",
"regulator_kiu",
")",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_REGULATOR_KID",
":",
"lc_property_state",
".",
"regulator_kid",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KID",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"coefficient",
";",
"log",
"(",
"\"",
"\"",
")",
";",
"print_float",
"(",
"lc_property_state",
".",
"regulator_kid",
")",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_REGULATOR_KPU",
":",
"lc_property_state",
".",
"regulator_kpu",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KPU",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"coefficient",
";",
"log",
"(",
"\"",
"\"",
")",
";",
"print_float",
"(",
"lc_property_state",
".",
"regulator_kpu",
")",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_REGULATOR_KPD",
":",
"lc_property_state",
".",
"regulator_kpd",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_REGULATOR_KPD",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"coefficient",
";",
"log",
"(",
"\"",
"\"",
")",
";",
"print_float",
"(",
"lc_property_state",
".",
"regulator_kpd",
")",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"LIGHT_CONTROL_REGULATOR_ACCURACY",
":",
"lc_property_state",
".",
"regulator_accuracy",
"=",
"mesh_sensor_data_from_buf",
"(",
"LIGHT_CONTROL_REGULATOR_ACCURACY",
",",
"evt",
"->",
"property_value",
".",
"data",
")",
".",
"percentage",
";",
"if",
"(",
"lc_property_state",
".",
"regulator_accuracy",
"==",
"0xFF",
")",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_property_state",
".",
"regulator_accuracy",
"/",
"2",
",",
"(",
"lc_property_state",
".",
"regulator_accuracy",
"%",
"2",
")",
"*",
"5",
")",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"lc_property_state_changed",
"(",
")",
";",
"}"
] | Handling of lc setup server set property event. | [
"Handling",
"of",
"lc",
"setup",
"server",
"set",
"property",
"event",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_evt_lc_setup_server_set_property_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_evt_lc_setup_server_set_property_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | sl_btmesh_lc_server_on_event | void | void sl_btmesh_lc_server_on_event(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
case sl_btmesh_evt_lc_server_mode_updated_id:
handle_lc_server_mode_updated_event(
&(evt->data.evt_lc_server_mode_updated));
break;
case sl_btmesh_evt_lc_server_om_updated_id:
handle_lc_server_om_updated_event(
&(evt->data.evt_lc_server_om_updated));
break;
case sl_btmesh_evt_lc_server_light_onoff_updated_id:
handle_lc_server_light_onoff_updated_event(
&(evt->data.evt_lc_server_light_onoff_updated));
break;
case sl_btmesh_evt_lc_server_linear_output_updated_id:
handle_lc_server_linear_output_updated_event(
&(evt->data.evt_lc_server_linear_output_updated));
break;
case sl_btmesh_evt_lc_setup_server_set_property_id:
handle_lc_setup_server_set_property(
&(evt->data.evt_lc_setup_server_set_property));
break;
case sl_btmesh_evt_node_provisioned_id:
sl_btmesh_lc_init();
break;
case sl_btmesh_evt_node_initialized_id:
if (evt->data.evt_node_initialized.provisioned) {
sl_btmesh_lc_init();
}
break;
case sl_btmesh_evt_node_reset_id:
sl_bt_nvm_erase(LC_SERVER_PS_KEY);
sl_bt_nvm_erase(LC_SERVER_PROPERTY_PS_KEY);
break;
default:
break;
}
} | /*******************************************************************************
* Handle LC Server events.
*
* This function is called automatically by Universal Configurator after
* enabling the component.
*
* @param[in] evt Pointer to incoming event.
******************************************************************************/ | Handle LC Server events.
This function is called automatically by Universal Configurator after
enabling the component.
@param[in] evt Pointer to incoming event. | [
"Handle",
"LC",
"Server",
"events",
".",
"This",
"function",
"is",
"called",
"automatically",
"by",
"Universal",
"Configurator",
"after",
"enabling",
"the",
"component",
".",
"@param",
"[",
"in",
"]",
"evt",
"Pointer",
"to",
"incoming",
"event",
"."
] | void sl_btmesh_lc_server_on_event(sl_btmesh_msg_t *evt)
{
switch (SL_BT_MSG_ID(evt->header)) {
case sl_btmesh_evt_lc_server_mode_updated_id:
handle_lc_server_mode_updated_event(
&(evt->data.evt_lc_server_mode_updated));
break;
case sl_btmesh_evt_lc_server_om_updated_id:
handle_lc_server_om_updated_event(
&(evt->data.evt_lc_server_om_updated));
break;
case sl_btmesh_evt_lc_server_light_onoff_updated_id:
handle_lc_server_light_onoff_updated_event(
&(evt->data.evt_lc_server_light_onoff_updated));
break;
case sl_btmesh_evt_lc_server_linear_output_updated_id:
handle_lc_server_linear_output_updated_event(
&(evt->data.evt_lc_server_linear_output_updated));
break;
case sl_btmesh_evt_lc_setup_server_set_property_id:
handle_lc_setup_server_set_property(
&(evt->data.evt_lc_setup_server_set_property));
break;
case sl_btmesh_evt_node_provisioned_id:
sl_btmesh_lc_init();
break;
case sl_btmesh_evt_node_initialized_id:
if (evt->data.evt_node_initialized.provisioned) {
sl_btmesh_lc_init();
}
break;
case sl_btmesh_evt_node_reset_id:
sl_bt_nvm_erase(LC_SERVER_PS_KEY);
sl_bt_nvm_erase(LC_SERVER_PROPERTY_PS_KEY);
break;
default:
break;
}
} | [
"void",
"sl_btmesh_lc_server_on_event",
"(",
"sl_btmesh_msg_t",
"*",
"evt",
")",
"{",
"switch",
"(",
"SL_BT_MSG_ID",
"(",
"evt",
"->",
"header",
")",
")",
"{",
"case",
"sl_btmesh_evt_lc_server_mode_updated_id",
":",
"handle_lc_server_mode_updated_event",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_lc_server_mode_updated",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_lc_server_om_updated_id",
":",
"handle_lc_server_om_updated_event",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_lc_server_om_updated",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_lc_server_light_onoff_updated_id",
":",
"handle_lc_server_light_onoff_updated_event",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_lc_server_light_onoff_updated",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_lc_server_linear_output_updated_id",
":",
"handle_lc_server_linear_output_updated_event",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_lc_server_linear_output_updated",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_lc_setup_server_set_property_id",
":",
"handle_lc_setup_server_set_property",
"(",
"&",
"(",
"evt",
"->",
"data",
".",
"evt_lc_setup_server_set_property",
")",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_node_provisioned_id",
":",
"sl_btmesh_lc_init",
"(",
")",
";",
"break",
";",
"case",
"sl_btmesh_evt_node_initialized_id",
":",
"if",
"(",
"evt",
"->",
"data",
".",
"evt_node_initialized",
".",
"provisioned",
")",
"{",
"sl_btmesh_lc_init",
"(",
")",
";",
"}",
"break",
";",
"case",
"sl_btmesh_evt_node_reset_id",
":",
"sl_bt_nvm_erase",
"(",
"LC_SERVER_PS_KEY",
")",
";",
"sl_bt_nvm_erase",
"(",
"LC_SERVER_PROPERTY_PS_KEY",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | Handle LC Server events. | [
"Handle",
"LC",
"Server",
"events",
"."
] | [] | [
{
"param": "evt",
"type": "sl_btmesh_msg_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evt",
"type": "sl_btmesh_msg_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_onoff_change | void | static void lc_onoff_change(uint16_t model_id,
uint16_t element_index,
const struct mesh_generic_state *current,
const struct mesh_generic_state *target,
uint32_t remaining_ms)
{
(void)model_id;
(void)element_index;
(void)target;
(void)remaining_ms;
if (current->on_off.on != lc_state.onoff_current) {
log("LC ON/OFF state changed %u to %u\r\n",
lc_state.onoff_current,
current->on_off.on);
lc_state.onoff_current = current->on_off.on;
lc_state_changed();
} else {
log("Dummy LC ON/OFF change - same state as before\r\n");
}
} | /*******************************************************************************
* This function is a handler for LC generic on/off change event.
*
* @param[in] model_id Server model ID.
* @param[in] element_index Server model element index.
* @param[in] current Pointer to current state structure.
* @param[in] target Pointer to target state structure.
* @param[in] remaining_ms Time (in milliseconds) remaining before transition
* from current state to target state is complete.
******************************************************************************/ | This function is a handler for LC generic on/off change event.
@param[in] model_id Server model ID.
@param[in] element_index Server model element index.
@param[in] current Pointer to current state structure.
@param[in] target Pointer to target state structure.
@param[in] remaining_ms Time (in milliseconds) remaining before transition
from current state to target state is complete. | [
"This",
"function",
"is",
"a",
"handler",
"for",
"LC",
"generic",
"on",
"/",
"off",
"change",
"event",
".",
"@param",
"[",
"in",
"]",
"model_id",
"Server",
"model",
"ID",
".",
"@param",
"[",
"in",
"]",
"element_index",
"Server",
"model",
"element",
"index",
".",
"@param",
"[",
"in",
"]",
"current",
"Pointer",
"to",
"current",
"state",
"structure",
".",
"@param",
"[",
"in",
"]",
"target",
"Pointer",
"to",
"target",
"state",
"structure",
".",
"@param",
"[",
"in",
"]",
"remaining_ms",
"Time",
"(",
"in",
"milliseconds",
")",
"remaining",
"before",
"transition",
"from",
"current",
"state",
"to",
"target",
"state",
"is",
"complete",
"."
] | static void lc_onoff_change(uint16_t model_id,
uint16_t element_index,
const struct mesh_generic_state *current,
const struct mesh_generic_state *target,
uint32_t remaining_ms)
{
(void)model_id;
(void)element_index;
(void)target;
(void)remaining_ms;
if (current->on_off.on != lc_state.onoff_current) {
log("LC ON/OFF state changed %u to %u\r\n",
lc_state.onoff_current,
current->on_off.on);
lc_state.onoff_current = current->on_off.on;
lc_state_changed();
} else {
log("Dummy LC ON/OFF change - same state as before\r\n");
}
} | [
"static",
"void",
"lc_onoff_change",
"(",
"uint16_t",
"model_id",
",",
"uint16_t",
"element_index",
",",
"const",
"struct",
"mesh_generic_state",
"*",
"current",
",",
"const",
"struct",
"mesh_generic_state",
"*",
"target",
",",
"uint32_t",
"remaining_ms",
")",
"{",
"(",
"void",
")",
"model_id",
";",
"(",
"void",
")",
"element_index",
";",
"(",
"void",
")",
"target",
";",
"(",
"void",
")",
"remaining_ms",
";",
"if",
"(",
"current",
"->",
"on_off",
".",
"on",
"!=",
"lc_state",
".",
"onoff_current",
")",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_state",
".",
"onoff_current",
",",
"current",
"->",
"on_off",
".",
"on",
")",
";",
"lc_state",
".",
"onoff_current",
"=",
"current",
"->",
"on_off",
".",
"on",
";",
"lc_state_changed",
"(",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
";",
"}",
"}"
] | This function is a handler for LC generic on/off change event. | [
"This",
"function",
"is",
"a",
"handler",
"for",
"LC",
"generic",
"on",
"/",
"off",
"change",
"event",
"."
] | [] | [
{
"param": "model_id",
"type": "uint16_t"
},
{
"param": "element_index",
"type": "uint16_t"
},
{
"param": "current",
"type": "struct mesh_generic_state"
},
{
"param": "target",
"type": "struct mesh_generic_state"
},
{
"param": "remaining_ms",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model_id",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "element_index",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "current",
"type": "struct mesh_generic_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": "struct mesh_generic_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "remaining_ms",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | lc_onoff_transition_complete | void | static void lc_onoff_transition_complete(void)
{
// transition done -> set state, update and publish
lc_state.onoff_current = lc_state.onoff_target;
log("Transition complete. New state is %s\r\n",
lc_state.onoff_current ? "ON" : "OFF");
lc_state_changed();
lc_onoff_update_and_publish(BTMESH_LC_SERVER_LIGHT_LC,
IMMEDIATE);
} | /***************************************************************************/
/**
* This function is called when a LC on/off request
* with non-zero transition time has completed.
******************************************************************************/ | This function is called when a LC on/off request
with non-zero transition time has completed. | [
"This",
"function",
"is",
"called",
"when",
"a",
"LC",
"on",
"/",
"off",
"request",
"with",
"non",
"-",
"zero",
"transition",
"time",
"has",
"completed",
"."
] | static void lc_onoff_transition_complete(void)
{
lc_state.onoff_current = lc_state.onoff_target;
log("Transition complete. New state is %s\r\n",
lc_state.onoff_current ? "ON" : "OFF");
lc_state_changed();
lc_onoff_update_and_publish(BTMESH_LC_SERVER_LIGHT_LC,
IMMEDIATE);
} | [
"static",
"void",
"lc_onoff_transition_complete",
"(",
"void",
")",
"{",
"lc_state",
".",
"onoff_current",
"=",
"lc_state",
".",
"onoff_target",
";",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_state",
".",
"onoff_current",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"lc_state_changed",
"(",
")",
";",
"lc_onoff_update_and_publish",
"(",
"BTMESH_LC_SERVER_LIGHT_LC",
",",
"IMMEDIATE",
")",
";",
"}"
] | This function is called when a LC on/off request
with non-zero transition time has completed. | [
"This",
"function",
"is",
"called",
"when",
"a",
"LC",
"on",
"/",
"off",
"request",
"with",
"non",
"-",
"zero",
"transition",
"time",
"has",
"completed",
"."
] | [
"// transition done -> set state, update and publish"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | delayed_lc_onoff_request | void | static void delayed_lc_onoff_request(void)
{
log("Starting delayed LC ON/OFF request: %u -> %u, %lu ms\r\n",
lc_state.onoff_current,
lc_state.onoff_target,
delayed_lc_onoff_trans
);
if (delayed_lc_onoff_trans == 0) {
// no transition delay, update state immediately
lc_state.onoff_current = lc_state.onoff_target;
lc_state_changed();
lc_onoff_update_and_publish(BTMESH_LC_SERVER_LIGHT_LC,
delayed_lc_onoff_trans);
} else {
if (lc_state.onoff_target == MESH_GENERIC_ON_OFF_STATE_ON) {
lc_state.onoff_current = MESH_GENERIC_ON_OFF_STATE_ON;
lc_onoff_update(BTMESH_LC_SERVER_LIGHT_LC, delayed_lc_onoff_trans);
}
// state is updated when transition is complete
sl_status_t sc = sl_simple_timer_start(&lc_onoff_transition_timer,
delayed_lc_onoff_trans,
lc_onoff_transition_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC Onoff Transition timer\n");
}
} | /***************************************************************************/
/**
* This function is called when delay for LC on/off request has completed.
******************************************************************************/ | This function is called when delay for LC on/off request has completed. | [
"This",
"function",
"is",
"called",
"when",
"delay",
"for",
"LC",
"on",
"/",
"off",
"request",
"has",
"completed",
"."
] | static void delayed_lc_onoff_request(void)
{
log("Starting delayed LC ON/OFF request: %u -> %u, %lu ms\r\n",
lc_state.onoff_current,
lc_state.onoff_target,
delayed_lc_onoff_trans
);
if (delayed_lc_onoff_trans == 0) {
lc_state.onoff_current = lc_state.onoff_target;
lc_state_changed();
lc_onoff_update_and_publish(BTMESH_LC_SERVER_LIGHT_LC,
delayed_lc_onoff_trans);
} else {
if (lc_state.onoff_target == MESH_GENERIC_ON_OFF_STATE_ON) {
lc_state.onoff_current = MESH_GENERIC_ON_OFF_STATE_ON;
lc_onoff_update(BTMESH_LC_SERVER_LIGHT_LC, delayed_lc_onoff_trans);
}
sl_status_t sc = sl_simple_timer_start(&lc_onoff_transition_timer,
delayed_lc_onoff_trans,
lc_onoff_transition_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start LC Onoff Transition timer\n");
}
} | [
"static",
"void",
"delayed_lc_onoff_request",
"(",
"void",
")",
"{",
"log",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"lc_state",
".",
"onoff_current",
",",
"lc_state",
".",
"onoff_target",
",",
"delayed_lc_onoff_trans",
")",
";",
"if",
"(",
"delayed_lc_onoff_trans",
"==",
"0",
")",
"{",
"lc_state",
".",
"onoff_current",
"=",
"lc_state",
".",
"onoff_target",
";",
"lc_state_changed",
"(",
")",
";",
"lc_onoff_update_and_publish",
"(",
"BTMESH_LC_SERVER_LIGHT_LC",
",",
"delayed_lc_onoff_trans",
")",
";",
"}",
"else",
"{",
"if",
"(",
"lc_state",
".",
"onoff_target",
"==",
"MESH_GENERIC_ON_OFF_STATE_ON",
")",
"{",
"lc_state",
".",
"onoff_current",
"=",
"MESH_GENERIC_ON_OFF_STATE_ON",
";",
"lc_onoff_update",
"(",
"BTMESH_LC_SERVER_LIGHT_LC",
",",
"delayed_lc_onoff_trans",
")",
";",
"}",
"sl_status_t",
"sc",
"=",
"sl_simple_timer_start",
"(",
"&",
"lc_onoff_transition_timer",
",",
"delayed_lc_onoff_trans",
",",
"lc_onoff_transition_timer_cb",
",",
"NO_CALLBACK_DATA",
",",
"false",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}"
] | This function is called when delay for LC on/off request has completed. | [
"This",
"function",
"is",
"called",
"when",
"delay",
"for",
"LC",
"on",
"/",
"off",
"request",
"has",
"completed",
"."
] | [
"// no transition delay, update state immediately",
"// state is updated when transition is complete"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2feef4b4c54941a838e245347d0dfe46720256e7 | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_lc_server/sl_btmesh_lc_server.c | [
"Zlib"
] | C | init_models | void | static void init_models(void)
{
sl_status_t sc;
sc = mesh_lib_generic_server_register_handler(MESH_GENERIC_ON_OFF_SERVER_MODEL_ID,
BTMESH_LC_SERVER_LIGHT_LC,
lc_onoff_request,
lc_onoff_change,
lc_onoff_recall);
app_assert_status_f(sc,
"LC server failed to register handlers (mdl=0x%04x,elem=%d)\n",
MESH_GENERIC_ON_OFF_SERVER_MODEL_ID,
BTMESH_LC_SERVER_LIGHT_LC);
} | /***************************************************************************/
/**
* Initialization of the models supported by this node.
* This function registers callbacks for each of the supported models.
******************************************************************************/ | Initialization of the models supported by this node.
This function registers callbacks for each of the supported models. | [
"Initialization",
"of",
"the",
"models",
"supported",
"by",
"this",
"node",
".",
"This",
"function",
"registers",
"callbacks",
"for",
"each",
"of",
"the",
"supported",
"models",
"."
] | static void init_models(void)
{
sl_status_t sc;
sc = mesh_lib_generic_server_register_handler(MESH_GENERIC_ON_OFF_SERVER_MODEL_ID,
BTMESH_LC_SERVER_LIGHT_LC,
lc_onoff_request,
lc_onoff_change,
lc_onoff_recall);
app_assert_status_f(sc,
"LC server failed to register handlers (mdl=0x%04x,elem=%d)\n",
MESH_GENERIC_ON_OFF_SERVER_MODEL_ID,
BTMESH_LC_SERVER_LIGHT_LC);
} | [
"static",
"void",
"init_models",
"(",
"void",
")",
"{",
"sl_status_t",
"sc",
";",
"sc",
"=",
"mesh_lib_generic_server_register_handler",
"(",
"MESH_GENERIC_ON_OFF_SERVER_MODEL_ID",
",",
"BTMESH_LC_SERVER_LIGHT_LC",
",",
"lc_onoff_request",
",",
"lc_onoff_change",
",",
"lc_onoff_recall",
")",
";",
"app_assert_status_f",
"(",
"sc",
",",
"\"",
"\\n",
"\"",
",",
"MESH_GENERIC_ON_OFF_SERVER_MODEL_ID",
",",
"BTMESH_LC_SERVER_LIGHT_LC",
")",
";",
"}"
] | Initialization of the models supported by this node. | [
"Initialization",
"of",
"the",
"models",
"supported",
"by",
"this",
"node",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6d864022a53cff7b98ff67b6c0ffd42284f02fec | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_wstk_lcd/sl_btmesh_wstk_lcd.c | [
"Zlib"
] | C | rtcIntCallbackRegister | int | int rtcIntCallbackRegister(void (*pFunction)(void *),
void *argument,
unsigned int frequency)
{
(void)pFunction;
(void)argument;
(void)frequency;
return 0;
} | /***************************************************************************/
/**
* Call a callback function at the given frequency.
*
* @param[in] pFunction Pointer to function that should be called at the
* given frequency.
* @param[in] argument Argument to be given to the function.
* @param[in] frequency Frequency at which to call function at.
*
* @return Status code of the operation.
*
* @note This is needed by the LCD driver
******************************************************************************/ | Call a callback function at the given frequency.
@param[in] pFunction Pointer to function that should be called at the
given frequency.
@param[in] argument Argument to be given to the function.
@param[in] frequency Frequency at which to call function at.
@return Status code of the operation.
@note This is needed by the LCD driver | [
"Call",
"a",
"callback",
"function",
"at",
"the",
"given",
"frequency",
".",
"@param",
"[",
"in",
"]",
"pFunction",
"Pointer",
"to",
"function",
"that",
"should",
"be",
"called",
"at",
"the",
"given",
"frequency",
".",
"@param",
"[",
"in",
"]",
"argument",
"Argument",
"to",
"be",
"given",
"to",
"the",
"function",
".",
"@param",
"[",
"in",
"]",
"frequency",
"Frequency",
"at",
"which",
"to",
"call",
"function",
"at",
".",
"@return",
"Status",
"code",
"of",
"the",
"operation",
".",
"@note",
"This",
"is",
"needed",
"by",
"the",
"LCD",
"driver"
] | int rtcIntCallbackRegister(void (*pFunction)(void *),
void *argument,
unsigned int frequency)
{
(void)pFunction;
(void)argument;
(void)frequency;
return 0;
} | [
"int",
"rtcIntCallbackRegister",
"(",
"void",
"(",
"*",
"pFunction",
")",
"(",
"void",
"*",
")",
",",
"void",
"*",
"argument",
",",
"unsigned",
"int",
"frequency",
")",
"{",
"(",
"void",
")",
"pFunction",
";",
"(",
"void",
")",
"argument",
";",
"(",
"void",
")",
"frequency",
";",
"return",
"0",
";",
"}"
] | Call a callback function at the given frequency. | [
"Call",
"a",
"callback",
"function",
"at",
"the",
"given",
"frequency",
"."
] | [] | [
{
"param": "pFunction",
"type": "void"
},
{
"param": "argument",
"type": "void"
},
{
"param": "frequency",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pFunction",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argument",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frequency",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d864022a53cff7b98ff67b6c0ffd42284f02fec | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_wstk_lcd/sl_btmesh_wstk_lcd.c | [
"Zlib"
] | C | sl_btmesh_LCD_init | sl_status_t | sl_status_t sl_btmesh_LCD_init(void)
{
memset(&LCD_data, 0, sizeof(LCD_data));
graphInit(BTMESH_WSTK_LCD_GRAPH_INIT_TEXT);
return sl_btmesh_LCD_write(BTMESH_WSTK_LCD_INIT_TEXT, BTMESH_WSTK_LCD_ROW_STATUS);
} | /*******************************************************************************
* LCD initialization, called once at startup.
******************************************************************************/ | LCD initialization, called once at startup. | [
"LCD",
"initialization",
"called",
"once",
"at",
"startup",
"."
] | sl_status_t sl_btmesh_LCD_init(void)
{
memset(&LCD_data, 0, sizeof(LCD_data));
graphInit(BTMESH_WSTK_LCD_GRAPH_INIT_TEXT);
return sl_btmesh_LCD_write(BTMESH_WSTK_LCD_INIT_TEXT, BTMESH_WSTK_LCD_ROW_STATUS);
} | [
"sl_status_t",
"sl_btmesh_LCD_init",
"(",
"void",
")",
"{",
"memset",
"(",
"&",
"LCD_data",
",",
"0",
",",
"sizeof",
"(",
"LCD_data",
")",
")",
";",
"graphInit",
"(",
"BTMESH_WSTK_LCD_GRAPH_INIT_TEXT",
")",
";",
"return",
"sl_btmesh_LCD_write",
"(",
"BTMESH_WSTK_LCD_INIT_TEXT",
",",
"BTMESH_WSTK_LCD_ROW_STATUS",
")",
";",
"}"
] | LCD initialization, called once at startup. | [
"LCD",
"initialization",
"called",
"once",
"at",
"startup",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6d864022a53cff7b98ff67b6c0ffd42284f02fec | SiliconLabs/Gecko_SDK | app/bluetooth/common/btmesh_wstk_lcd/sl_btmesh_wstk_lcd.c | [
"Zlib"
] | C | sl_btmesh_LCD_write | sl_status_t | sl_status_t sl_btmesh_LCD_write(char *str, uint8_t row)
{
char LCD_message[LCD_ROW_MAX * LCD_ROW_LEN];
char *pRow;
int i;
if (row > LCD_ROW_MAX) {
return SL_STATUS_INVALID_PARAMETER;
}
pRow = &(LCD_data[row - 1][0]);
strcpy(pRow, str);
LCD_message[0] = 0;
for (i = 0; i < LCD_ROW_MAX; i++) {
pRow = &(LCD_data[i][0]);
strcat(LCD_message, pRow);
strcat(LCD_message, "\n"); // add newline at end of reach row
}
sl_status_t status = graphWriteString(LCD_message);
return status;
} | /*******************************************************************************
* This function is used to write one line in the LCD.
*
* @param[in] str Pointer to string which is displayed in the specified row.
* @param[in] row Selects which line of LCD display is written,
* possible values are defined as LCD_ROW_xxx.
* @returns Status of the write command.
* @retval SL_STATUS_OK if successful
* @retval SL_STATUS_FAIL otherwise
******************************************************************************/ | This function is used to write one line in the LCD.
@param[in] str Pointer to string which is displayed in the specified row.
@param[in] row Selects which line of LCD display is written,
possible values are defined as LCD_ROW_xxx.
@returns Status of the write command.
@retval SL_STATUS_OK if successful
@retval SL_STATUS_FAIL otherwise | [
"This",
"function",
"is",
"used",
"to",
"write",
"one",
"line",
"in",
"the",
"LCD",
".",
"@param",
"[",
"in",
"]",
"str",
"Pointer",
"to",
"string",
"which",
"is",
"displayed",
"in",
"the",
"specified",
"row",
".",
"@param",
"[",
"in",
"]",
"row",
"Selects",
"which",
"line",
"of",
"LCD",
"display",
"is",
"written",
"possible",
"values",
"are",
"defined",
"as",
"LCD_ROW_xxx",
".",
"@returns",
"Status",
"of",
"the",
"write",
"command",
".",
"@retval",
"SL_STATUS_OK",
"if",
"successful",
"@retval",
"SL_STATUS_FAIL",
"otherwise"
] | sl_status_t sl_btmesh_LCD_write(char *str, uint8_t row)
{
char LCD_message[LCD_ROW_MAX * LCD_ROW_LEN];
char *pRow;
int i;
if (row > LCD_ROW_MAX) {
return SL_STATUS_INVALID_PARAMETER;
}
pRow = &(LCD_data[row - 1][0]);
strcpy(pRow, str);
LCD_message[0] = 0;
for (i = 0; i < LCD_ROW_MAX; i++) {
pRow = &(LCD_data[i][0]);
strcat(LCD_message, pRow);
strcat(LCD_message, "\n");
}
sl_status_t status = graphWriteString(LCD_message);
return status;
} | [
"sl_status_t",
"sl_btmesh_LCD_write",
"(",
"char",
"*",
"str",
",",
"uint8_t",
"row",
")",
"{",
"char",
"LCD_message",
"[",
"LCD_ROW_MAX",
"*",
"LCD_ROW_LEN",
"]",
";",
"char",
"*",
"pRow",
";",
"int",
"i",
";",
"if",
"(",
"row",
">",
"LCD_ROW_MAX",
")",
"{",
"return",
"SL_STATUS_INVALID_PARAMETER",
";",
"}",
"pRow",
"=",
"&",
"(",
"LCD_data",
"[",
"row",
"-",
"1",
"]",
"[",
"0",
"]",
")",
";",
"strcpy",
"(",
"pRow",
",",
"str",
")",
";",
"LCD_message",
"[",
"0",
"]",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"LCD_ROW_MAX",
";",
"i",
"++",
")",
"{",
"pRow",
"=",
"&",
"(",
"LCD_data",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"strcat",
"(",
"LCD_message",
",",
"pRow",
")",
";",
"strcat",
"(",
"LCD_message",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"sl_status_t",
"status",
"=",
"graphWriteString",
"(",
"LCD_message",
")",
";",
"return",
"status",
";",
"}"
] | This function is used to write one line in the LCD. | [
"This",
"function",
"is",
"used",
"to",
"write",
"one",
"line",
"in",
"the",
"LCD",
"."
] | [
"// add newline at end of reach row"
] | [
{
"param": "str",
"type": "char"
},
{
"param": "row",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "str",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "row",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0490909b65ff41f11bc5fd497326412888e88841 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_throughput/app.c | [
"Zlib"
] | C | app_check_buttons | uint8_t | uint8_t app_check_buttons()
{
uint8_t ret = 0;
if (sl_button_get_state(PB0) == SL_SIMPLE_BUTTON_PRESSED) {
ret |= PB0_VALUE;
}
if (sl_button_get_state(PB1) == SL_SIMPLE_BUTTON_PRESSED) {
ret |= PB1_VALUE;
}
return ret;
} | /**************************************************************************/
/**
* Checks buttons on start.
* @return the button code that is pressed
*****************************************************************************/ | Checks buttons on start.
@return the button code that is pressed | [
"Checks",
"buttons",
"on",
"start",
".",
"@return",
"the",
"button",
"code",
"that",
"is",
"pressed"
] | uint8_t app_check_buttons()
{
uint8_t ret = 0;
if (sl_button_get_state(PB0) == SL_SIMPLE_BUTTON_PRESSED) {
ret |= PB0_VALUE;
}
if (sl_button_get_state(PB1) == SL_SIMPLE_BUTTON_PRESSED) {
ret |= PB1_VALUE;
}
return ret;
} | [
"uint8_t",
"app_check_buttons",
"(",
")",
"{",
"uint8_t",
"ret",
"=",
"0",
";",
"if",
"(",
"sl_button_get_state",
"(",
"PB0",
")",
"==",
"SL_SIMPLE_BUTTON_PRESSED",
")",
"{",
"ret",
"|=",
"PB0_VALUE",
";",
"}",
"if",
"(",
"sl_button_get_state",
"(",
"PB1",
")",
"==",
"SL_SIMPLE_BUTTON_PRESSED",
")",
"{",
"ret",
"|=",
"PB1_VALUE",
";",
"}",
"return",
"ret",
";",
"}"
] | Checks buttons on start. | [
"Checks",
"buttons",
"on",
"start",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0490909b65ff41f11bc5fd497326412888e88841 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_throughput/app.c | [
"Zlib"
] | C | sl_button_on_change | void | void sl_button_on_change(const sl_button_t *handle)
{
(void) handle;
// Check states
button_current = app_check_buttons();
// Mask first button release
if (mask_release && button_change && !button_current) {
button_change = 0;
mask_release = false;
}
// Identify button change
button_change = (button_current ^ button_previous);
// There is a button change
if (button_change) {
// Handle button press during operation
app_handle_button_press();
}
// Save current button states
button_previous = button_current;
} | /**************************************************************************/
/**
* Checks buttons
* @param[in] handle the button handle
*****************************************************************************/ | Checks buttons
@param[in] handle the button handle | [
"Checks",
"buttons",
"@param",
"[",
"in",
"]",
"handle",
"the",
"button",
"handle"
] | void sl_button_on_change(const sl_button_t *handle)
{
(void) handle;
button_current = app_check_buttons();
if (mask_release && button_change && !button_current) {
button_change = 0;
mask_release = false;
}
button_change = (button_current ^ button_previous);
if (button_change) {
app_handle_button_press();
}
button_previous = button_current;
} | [
"void",
"sl_button_on_change",
"(",
"const",
"sl_button_t",
"*",
"handle",
")",
"{",
"(",
"void",
")",
"handle",
";",
"button_current",
"=",
"app_check_buttons",
"(",
")",
";",
"if",
"(",
"mask_release",
"&&",
"button_change",
"&&",
"!",
"button_current",
")",
"{",
"button_change",
"=",
"0",
";",
"mask_release",
"=",
"false",
";",
"}",
"button_change",
"=",
"(",
"button_current",
"^",
"button_previous",
")",
";",
"if",
"(",
"button_change",
")",
"{",
"app_handle_button_press",
"(",
")",
";",
"}",
"button_previous",
"=",
"button_current",
";",
"}"
] | Checks buttons
@param[in] handle the button handle | [
"Checks",
"buttons",
"@param",
"[",
"in",
"]",
"handle",
"the",
"button",
"handle"
] | [
"// Check states",
"// Mask first button release",
"// Identify button change",
"// There is a button change",
"// Handle button press during operation",
"// Save current button states"
] | [
{
"param": "handle",
"type": "sl_button_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": "sl_button_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0490909b65ff41f11bc5fd497326412888e88841 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_throughput/app.c | [
"Zlib"
] | C | throughput_peripheral_on_start | void | void throughput_peripheral_on_start(void)
{
app_log_info("Throughput test started");
app_log_nl();
} | /**************************************************************************/
/**
* Callback to handle transmission start event.
*****************************************************************************/ | Callback to handle transmission start event. | [
"Callback",
"to",
"handle",
"transmission",
"start",
"event",
"."
] | void throughput_peripheral_on_start(void)
{
app_log_info("Throughput test started");
app_log_nl();
} | [
"void",
"throughput_peripheral_on_start",
"(",
"void",
")",
"{",
"app_log_info",
"(",
"\"",
"\"",
")",
";",
"app_log_nl",
"(",
")",
";",
"}"
] | Callback to handle transmission start event. | [
"Callback",
"to",
"handle",
"transmission",
"start",
"event",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0490909b65ff41f11bc5fd497326412888e88841 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_throughput/app.c | [
"Zlib"
] | C | throughput_peripheral_on_finish | void | void throughput_peripheral_on_finish(throughput_value_t throughput,
throughput_count_t count)
{
app_log_info("Throughput test finished: %d bps, %u packets",
throughput,
count);
app_log_nl();
throughput_ui_set_throughput(throughput);
throughput_ui_set_count(count);
throughput_ui_update();
} | /**************************************************************************/
/**
* Callback to handle transmission finished event.
* @param[in] throughput throughput value in bits/second (bps)
* @param[in] count data volume transmitted, in bytes
*****************************************************************************/ | Callback to handle transmission finished event.
@param[in] throughput throughput value in bits/second (bps)
@param[in] count data volume transmitted, in bytes | [
"Callback",
"to",
"handle",
"transmission",
"finished",
"event",
".",
"@param",
"[",
"in",
"]",
"throughput",
"throughput",
"value",
"in",
"bits",
"/",
"second",
"(",
"bps",
")",
"@param",
"[",
"in",
"]",
"count",
"data",
"volume",
"transmitted",
"in",
"bytes"
] | void throughput_peripheral_on_finish(throughput_value_t throughput,
throughput_count_t count)
{
app_log_info("Throughput test finished: %d bps, %u packets",
throughput,
count);
app_log_nl();
throughput_ui_set_throughput(throughput);
throughput_ui_set_count(count);
throughput_ui_update();
} | [
"void",
"throughput_peripheral_on_finish",
"(",
"throughput_value_t",
"throughput",
",",
"throughput_count_t",
"count",
")",
"{",
"app_log_info",
"(",
"\"",
"\"",
",",
"throughput",
",",
"count",
")",
";",
"app_log_nl",
"(",
")",
";",
"throughput_ui_set_throughput",
"(",
"throughput",
")",
";",
"throughput_ui_set_count",
"(",
"count",
")",
";",
"throughput_ui_update",
"(",
")",
";",
"}"
] | Callback to handle transmission finished event. | [
"Callback",
"to",
"handle",
"transmission",
"finished",
"event",
"."
] | [] | [
{
"param": "throughput",
"type": "throughput_value_t"
},
{
"param": "count",
"type": "throughput_count_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "throughput",
"type": "throughput_value_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "throughput_count_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0490909b65ff41f11bc5fd497326412888e88841 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_throughput/app.c | [
"Zlib"
] | C | throughput_central_on_start | void | void throughput_central_on_start(void)
{
app_log_info("Throughput test: reception started");
app_log_nl();
} | /**************************************************************************/
/**
* Callback to handle transmission start event.
*****************************************************************************/ | Callback to handle transmission start event. | [
"Callback",
"to",
"handle",
"transmission",
"start",
"event",
"."
] | void throughput_central_on_start(void)
{
app_log_info("Throughput test: reception started");
app_log_nl();
} | [
"void",
"throughput_central_on_start",
"(",
"void",
")",
"{",
"app_log_info",
"(",
"\"",
"\"",
")",
";",
"app_log_nl",
"(",
")",
";",
"}"
] | Callback to handle transmission start event. | [
"Callback",
"to",
"handle",
"transmission",
"start",
"event",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
951412fef2de1be457bf11a76ce5e2a4dc18bb27 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_light_rail_dmp/freertos/app_proprietary.c | [
"Zlib"
] | C | proprietary_timer_callback | void | static void proprietary_timer_callback(TimerHandle_t xTimer)
{
(void)xTimer;
proprietary_queue_post(PROP_TIMER_EXPIRED);
} | /**************************************************************************/
/**
* Proprietary timer callback.
*
* @param p_tmr is pointer to the user-allocated timer.
* @param p_arg is argument passed when creating the timer.
*
* Called when timer expires
*****************************************************************************/ | Proprietary timer callback.
@param p_tmr is pointer to the user-allocated timer.
@param p_arg is argument passed when creating the timer.
Called when timer expires | [
"Proprietary",
"timer",
"callback",
".",
"@param",
"p_tmr",
"is",
"pointer",
"to",
"the",
"user",
"-",
"allocated",
"timer",
".",
"@param",
"p_arg",
"is",
"argument",
"passed",
"when",
"creating",
"the",
"timer",
".",
"Called",
"when",
"timer",
"expires"
] | static void proprietary_timer_callback(TimerHandle_t xTimer)
{
(void)xTimer;
proprietary_queue_post(PROP_TIMER_EXPIRED);
} | [
"static",
"void",
"proprietary_timer_callback",
"(",
"TimerHandle_t",
"xTimer",
")",
"{",
"(",
"void",
")",
"xTimer",
";",
"proprietary_queue_post",
"(",
"PROP_TIMER_EXPIRED",
")",
";",
"}"
] | Proprietary timer callback. | [
"Proprietary",
"timer",
"callback",
"."
] | [] | [
{
"param": "xTimer",
"type": "TimerHandle_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xTimer",
"type": "TimerHandle_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
951412fef2de1be457bf11a76ce5e2a4dc18bb27 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_light_rail_dmp/freertos/app_proprietary.c | [
"Zlib"
] | C | proprietaryTxPacket | void | static void proprietaryTxPacket(prop_pkt pktType)
{
RAIL_SchedulerInfo_t schedulerInfo;
RAIL_Status_t res;
RAIL_Handle_t rail_handle =
sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0);
// This assumes the Tx time is around 200us
schedulerInfo = (RAIL_SchedulerInfo_t){ .priority = 100,
.slipTime = 100000,
.transactionTime = 200 };
// address of light
memcpy((void *)&data_packet[PACKET_HEADER_LEN],
(void *)demo.own_addr.addr,
sizeof(demo.own_addr.addr));
// light role
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
(DEMO_CONTROL_ROLE_LIGHT << DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT_SHIFT)
& DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT;
// advertisement packet
if (PROP_PKT_ADVERTISE == pktType) {
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
((uint8_t)DEMO_CONTROL_CMD_ADVERTISE
<< DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT)
& DEMO_CONTROL_PAYLOAD_CMD_MASK;
// status packet
} else if (PROP_PKT_STATUS == pktType) {
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
((uint8_t)DEMO_CONTROL_CMD_LIGHT_STATE_REPORT
<< DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT)
& DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~0x01;
data_packet[LIGHT_CONTROL_DATA_BYTE] |= (uint8_t)demo.light;
} else {
}
RAIL_WriteTxFifo((RAIL_Handle_t)rail_handle,
data_packet,
sizeof(data_packet),
true);
res = RAIL_StartTx((RAIL_Handle_t)rail_handle,
0,
RAIL_TX_OPTIONS_DEFAULT,
&schedulerInfo);
if (res != RAIL_STATUS_NO_ERROR) {
// Try once to resend the packet 100ms later in case of error
RAIL_ScheduleTxConfig_t scheduledTxConfig =
{ .when = RAIL_GetTime() + 100000,
.mode = RAIL_TIME_ABSOLUTE };
// Transmit this packet at the specified time or up to 50 ms late
res = RAIL_StartScheduledTx((RAIL_Handle_t)sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0),
0,
RAIL_TX_OPTIONS_DEFAULT,
&scheduledTxConfig,
&schedulerInfo);
}
} | /**************************************************************************/
/**
* Proprietary packet send.
*
* @param pktType Packet type
*
* Sends a packet using RAIL. The data shall be in data_packet
*****************************************************************************/ | Proprietary packet send.
@param pktType Packet type
Sends a packet using RAIL. The data shall be in data_packet | [
"Proprietary",
"packet",
"send",
".",
"@param",
"pktType",
"Packet",
"type",
"Sends",
"a",
"packet",
"using",
"RAIL",
".",
"The",
"data",
"shall",
"be",
"in",
"data_packet"
] | static void proprietaryTxPacket(prop_pkt pktType)
{
RAIL_SchedulerInfo_t schedulerInfo;
RAIL_Status_t res;
RAIL_Handle_t rail_handle =
sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0);
schedulerInfo = (RAIL_SchedulerInfo_t){ .priority = 100,
.slipTime = 100000,
.transactionTime = 200 };
memcpy((void *)&data_packet[PACKET_HEADER_LEN],
(void *)demo.own_addr.addr,
sizeof(demo.own_addr.addr));
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
(DEMO_CONTROL_ROLE_LIGHT << DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT_SHIFT)
& DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT;
if (PROP_PKT_ADVERTISE == pktType) {
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
((uint8_t)DEMO_CONTROL_CMD_ADVERTISE
<< DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT)
& DEMO_CONTROL_PAYLOAD_CMD_MASK;
} else if (PROP_PKT_STATUS == pktType) {
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] |=
((uint8_t)DEMO_CONTROL_CMD_LIGHT_STATE_REPORT
<< DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT)
& DEMO_CONTROL_PAYLOAD_CMD_MASK;
data_packet[LIGHT_CONTROL_DATA_BYTE] &= ~0x01;
data_packet[LIGHT_CONTROL_DATA_BYTE] |= (uint8_t)demo.light;
} else {
}
RAIL_WriteTxFifo((RAIL_Handle_t)rail_handle,
data_packet,
sizeof(data_packet),
true);
res = RAIL_StartTx((RAIL_Handle_t)rail_handle,
0,
RAIL_TX_OPTIONS_DEFAULT,
&schedulerInfo);
if (res != RAIL_STATUS_NO_ERROR) {
RAIL_ScheduleTxConfig_t scheduledTxConfig =
{ .when = RAIL_GetTime() + 100000,
.mode = RAIL_TIME_ABSOLUTE };
res = RAIL_StartScheduledTx((RAIL_Handle_t)sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0),
0,
RAIL_TX_OPTIONS_DEFAULT,
&scheduledTxConfig,
&schedulerInfo);
}
} | [
"static",
"void",
"proprietaryTxPacket",
"(",
"prop_pkt",
"pktType",
")",
"{",
"RAIL_SchedulerInfo_t",
"schedulerInfo",
";",
"RAIL_Status_t",
"res",
";",
"RAIL_Handle_t",
"rail_handle",
"=",
"sl_rail_util_get_handle",
"(",
"SL_RAIL_UTIL_HANDLE_INST0",
")",
";",
"schedulerInfo",
"=",
"(",
"RAIL_SchedulerInfo_t",
")",
"{",
".",
"priority",
"=",
"100",
",",
".",
"slipTime",
"=",
"100000",
",",
".",
"transactionTime",
"=",
"200",
"}",
";",
"memcpy",
"(",
"(",
"void",
"*",
")",
"&",
"data_packet",
"[",
"PACKET_HEADER_LEN",
"]",
",",
"(",
"void",
"*",
")",
"demo",
".",
"own_addr",
".",
"addr",
",",
"sizeof",
"(",
"demo",
".",
"own_addr",
".",
"addr",
")",
")",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"&=",
"~",
"DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"|=",
"(",
"DEMO_CONTROL_ROLE_LIGHT",
"<<",
"DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT_SHIFT",
")",
"&",
"DEMO_CONTROL_PAYLOAD_SRC_ROLE_BIT",
";",
"if",
"(",
"PROP_PKT_ADVERTISE",
"==",
"pktType",
")",
"{",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"&=",
"~",
"DEMO_CONTROL_PAYLOAD_CMD_MASK",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"|=",
"(",
"(",
"uint8_t",
")",
"DEMO_CONTROL_CMD_ADVERTISE",
"<<",
"DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT",
")",
"&",
"DEMO_CONTROL_PAYLOAD_CMD_MASK",
";",
"}",
"else",
"if",
"(",
"PROP_PKT_STATUS",
"==",
"pktType",
")",
"{",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"&=",
"~",
"DEMO_CONTROL_PAYLOAD_CMD_MASK",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"|=",
"(",
"(",
"uint8_t",
")",
"DEMO_CONTROL_CMD_LIGHT_STATE_REPORT",
"<<",
"DEMO_CONTROL_PAYLOAD_CMD_MASK_SHIFT",
")",
"&",
"DEMO_CONTROL_PAYLOAD_CMD_MASK",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"&=",
"~",
"0x01",
";",
"data_packet",
"[",
"LIGHT_CONTROL_DATA_BYTE",
"]",
"|=",
"(",
"uint8_t",
")",
"demo",
".",
"light",
";",
"}",
"else",
"{",
"}",
"RAIL_WriteTxFifo",
"(",
"(",
"RAIL_Handle_t",
")",
"rail_handle",
",",
"data_packet",
",",
"sizeof",
"(",
"data_packet",
")",
",",
"true",
")",
";",
"res",
"=",
"RAIL_StartTx",
"(",
"(",
"RAIL_Handle_t",
")",
"rail_handle",
",",
"0",
",",
"RAIL_TX_OPTIONS_DEFAULT",
",",
"&",
"schedulerInfo",
")",
";",
"if",
"(",
"res",
"!=",
"RAIL_STATUS_NO_ERROR",
")",
"{",
"RAIL_ScheduleTxConfig_t",
"scheduledTxConfig",
"=",
"{",
".",
"when",
"=",
"RAIL_GetTime",
"(",
")",
"+",
"100000",
",",
".",
"mode",
"=",
"RAIL_TIME_ABSOLUTE",
"}",
";",
"res",
"=",
"RAIL_StartScheduledTx",
"(",
"(",
"RAIL_Handle_t",
")",
"sl_rail_util_get_handle",
"(",
"SL_RAIL_UTIL_HANDLE_INST0",
")",
",",
"0",
",",
"RAIL_TX_OPTIONS_DEFAULT",
",",
"&",
"scheduledTxConfig",
",",
"&",
"schedulerInfo",
")",
";",
"}",
"}"
] | Proprietary packet send. | [
"Proprietary",
"packet",
"send",
"."
] | [
"// This assumes the Tx time is around 200us",
"// address of light",
"// light role",
"// advertisement packet",
"// status packet",
"// Try once to resend the packet 100ms later in case of error",
"// Transmit this packet at the specified time or up to 50 ms late"
] | [
{
"param": "pktType",
"type": "prop_pkt"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pktType",
"type": "prop_pkt",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
951412fef2de1be457bf11a76ce5e2a4dc18bb27 | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_light_rail_dmp/freertos/app_proprietary.c | [
"Zlib"
] | C | RAILCb_SetupRxFifo | RAIL_Status_t | RAIL_Status_t RAILCb_SetupRxFifo(RAIL_Handle_t railHandle)
{
uint16_t rxFifoSize = RAIL_FIFO_SIZE;
RAIL_Status_t status = RAIL_SetRxFifo(railHandle, &rx_fifo[0], &rxFifoSize);
if (rxFifoSize != RAIL_FIFO_SIZE) {
// We set up an incorrect FIFO size
return RAIL_STATUS_INVALID_PARAMETER;
}
if (status == RAIL_STATUS_INVALID_STATE) {
// Allow failures due to multiprotocol
return RAIL_STATUS_NO_ERROR;
}
return status;
} | /******************************************************************************
* RAIL callback, called while the RAIL is initializing.
*****************************************************************************/ | RAIL callback, called while the RAIL is initializing. | [
"RAIL",
"callback",
"called",
"while",
"the",
"RAIL",
"is",
"initializing",
"."
] | RAIL_Status_t RAILCb_SetupRxFifo(RAIL_Handle_t railHandle)
{
uint16_t rxFifoSize = RAIL_FIFO_SIZE;
RAIL_Status_t status = RAIL_SetRxFifo(railHandle, &rx_fifo[0], &rxFifoSize);
if (rxFifoSize != RAIL_FIFO_SIZE) {
return RAIL_STATUS_INVALID_PARAMETER;
}
if (status == RAIL_STATUS_INVALID_STATE) {
return RAIL_STATUS_NO_ERROR;
}
return status;
} | [
"RAIL_Status_t",
"RAILCb_SetupRxFifo",
"(",
"RAIL_Handle_t",
"railHandle",
")",
"{",
"uint16_t",
"rxFifoSize",
"=",
"RAIL_FIFO_SIZE",
";",
"RAIL_Status_t",
"status",
"=",
"RAIL_SetRxFifo",
"(",
"railHandle",
",",
"&",
"rx_fifo",
"[",
"0",
"]",
",",
"&",
"rxFifoSize",
")",
";",
"if",
"(",
"rxFifoSize",
"!=",
"RAIL_FIFO_SIZE",
")",
"{",
"return",
"RAIL_STATUS_INVALID_PARAMETER",
";",
"}",
"if",
"(",
"status",
"==",
"RAIL_STATUS_INVALID_STATE",
")",
"{",
"return",
"RAIL_STATUS_NO_ERROR",
";",
"}",
"return",
"status",
";",
"}"
] | RAIL callback, called while the RAIL is initializing. | [
"RAIL",
"callback",
"called",
"while",
"the",
"RAIL",
"is",
"initializing",
"."
] | [
"// We set up an incorrect FIFO size",
"// Allow failures due to multiprotocol"
] | [
{
"param": "railHandle",
"type": "RAIL_Handle_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "railHandle",
"type": "RAIL_Handle_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4010bc8ca74ff408bf8e3bc82dcd27f42c26bc3d | SiliconLabs/Gecko_SDK | app/bluetooth/example/soc_btmesh_light/app_led_rgb.c | [
"Zlib"
] | C | app_led_set_color | void | void app_led_set_color(uint16_t color)
{
light_color = color;
rgb_led_set(RGB_LED_MASK, light_level, light_color);
} | /*******************************************************************************
* Sets the color temperature of the LED if present.
*
* @param[in] color Color temperature in Kelvins.
*
******************************************************************************/ | Sets the color temperature of the LED if present.
@param[in] color Color temperature in Kelvins. | [
"Sets",
"the",
"color",
"temperature",
"of",
"the",
"LED",
"if",
"present",
".",
"@param",
"[",
"in",
"]",
"color",
"Color",
"temperature",
"in",
"Kelvins",
"."
] | void app_led_set_color(uint16_t color)
{
light_color = color;
rgb_led_set(RGB_LED_MASK, light_level, light_color);
} | [
"void",
"app_led_set_color",
"(",
"uint16_t",
"color",
")",
"{",
"light_color",
"=",
"color",
";",
"rgb_led_set",
"(",
"RGB_LED_MASK",
",",
"light_level",
",",
"light_color",
")",
";",
"}"
] | Sets the color temperature of the LED if present. | [
"Sets",
"the",
"color",
"temperature",
"of",
"the",
"LED",
"if",
"present",
"."
] | [] | [
{
"param": "color",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "color",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | sli_cpc_drv_is_transmit_ready | bool | bool sli_cpc_drv_is_transmit_ready(void)
{
sl_slist_node_t *head;
bool flag;
sl_atomic_load(flag, tx_ready);
sl_atomic_load(head, tx_free_list_head);
return (head != NULL
&& flag);
} | /***************************************************************************/
/**
* Checks if driver is ready to transmit.
******************************************************************************/ | Checks if driver is ready to transmit. | [
"Checks",
"if",
"driver",
"is",
"ready",
"to",
"transmit",
"."
] | bool sli_cpc_drv_is_transmit_ready(void)
{
sl_slist_node_t *head;
bool flag;
sl_atomic_load(flag, tx_ready);
sl_atomic_load(head, tx_free_list_head);
return (head != NULL
&& flag);
} | [
"bool",
"sli_cpc_drv_is_transmit_ready",
"(",
"void",
")",
"{",
"sl_slist_node_t",
"*",
"head",
";",
"bool",
"flag",
";",
"sl_atomic_load",
"(",
"flag",
",",
"tx_ready",
")",
";",
"sl_atomic_load",
"(",
"head",
",",
"tx_free_list_head",
")",
";",
"return",
"(",
"head",
"!=",
"NULL",
"&&",
"flag",
")",
";",
"}"
] | Checks if driver is ready to transmit. | [
"Checks",
"if",
"driver",
"is",
"ready",
"to",
"transmit",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | prepare_next_tx | sl_status_t | static sl_status_t prepare_next_tx(void)
{
Ecode_t code;
sli_buf_entry_t *entry;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
entry = (sli_buf_entry_t *)tx_submitted_list_head;
if (entry == NULL) {
CORE_EXIT_ATOMIC();
return SL_STATUS_EMPTY;
}
if (entry->payload_len <= DMADRV_MAX_XFER_COUNT && entry->payload_len != 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE, 1);
tx_descriptor[1u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->data, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), entry->payload_len, 1u);
tx_descriptor[2u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->fcs, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), 2u);
tx_descriptor[0u].xfer.doneIfs = 0u;
tx_descriptor[1u].xfer.doneIfs = 0u;
tx_descriptor[2u].xfer.doneIfs = 1u;
} else if (entry->payload_len <= (DMADRV_MAX_XFER_COUNT * 2) && entry->payload_len > 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE, 1);
tx_descriptor[1u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->data, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), DMADRV_MAX_XFER_COUNT, 1u);
tx_descriptor[2u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(&((uint8_t *)entry->handle->data)[DMADRV_MAX_XFER_COUNT], &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), (entry->payload_len - DMADRV_MAX_XFER_COUNT), 1u);
tx_descriptor[3u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->fcs, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), 2u);
tx_descriptor[0u].xfer.doneIfs = 0u;
tx_descriptor[1u].xfer.doneIfs = 0u;
tx_descriptor[2u].xfer.doneIfs = 0u;
tx_descriptor[3u].xfer.doneIfs = 1u;
} else if (entry->payload_len == 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE);
tx_descriptor[0u].xfer.doneIfs = 1u;
} else {
CORE_EXIT_ATOMIC();
return SL_STATUS_INVALID_PARAMETER;
}
tx_ready = false;
code = DMADRV_LdmaStartTransfer(write_channel,
&tx_config,
tx_descriptor,
NULL,
NULL);
EFM_ASSERT(code == ECODE_OK);
CORE_EXIT_ATOMIC();
return SL_STATUS_OK;
} | /***************************************************************************/
/**
* Prepare for transmission of next buffer.
******************************************************************************/ | Prepare for transmission of next buffer. | [
"Prepare",
"for",
"transmission",
"of",
"next",
"buffer",
"."
] | static sl_status_t prepare_next_tx(void)
{
Ecode_t code;
sli_buf_entry_t *entry;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
entry = (sli_buf_entry_t *)tx_submitted_list_head;
if (entry == NULL) {
CORE_EXIT_ATOMIC();
return SL_STATUS_EMPTY;
}
if (entry->payload_len <= DMADRV_MAX_XFER_COUNT && entry->payload_len != 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE, 1);
tx_descriptor[1u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->data, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), entry->payload_len, 1u);
tx_descriptor[2u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->fcs, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), 2u);
tx_descriptor[0u].xfer.doneIfs = 0u;
tx_descriptor[1u].xfer.doneIfs = 0u;
tx_descriptor[2u].xfer.doneIfs = 1u;
} else if (entry->payload_len <= (DMADRV_MAX_XFER_COUNT * 2) && entry->payload_len > 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE, 1);
tx_descriptor[1u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(entry->handle->data, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), DMADRV_MAX_XFER_COUNT, 1u);
tx_descriptor[2u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_LINKREL_M2P_BYTE(&((uint8_t *)entry->handle->data)[DMADRV_MAX_XFER_COUNT], &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), (entry->payload_len - DMADRV_MAX_XFER_COUNT), 1u);
tx_descriptor[3u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->fcs, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), 2u);
tx_descriptor[0u].xfer.doneIfs = 0u;
tx_descriptor[1u].xfer.doneIfs = 0u;
tx_descriptor[2u].xfer.doneIfs = 0u;
tx_descriptor[3u].xfer.doneIfs = 1u;
} else if (entry->payload_len == 0u) {
tx_descriptor[0u] = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(entry->handle->hdlc_header, &(SL_CPC_DRV_UART_PERIPHERAL->TXDATA), SLI_CPC_HDLC_HEADER_RAW_SIZE);
tx_descriptor[0u].xfer.doneIfs = 1u;
} else {
CORE_EXIT_ATOMIC();
return SL_STATUS_INVALID_PARAMETER;
}
tx_ready = false;
code = DMADRV_LdmaStartTransfer(write_channel,
&tx_config,
tx_descriptor,
NULL,
NULL);
EFM_ASSERT(code == ECODE_OK);
CORE_EXIT_ATOMIC();
return SL_STATUS_OK;
} | [
"static",
"sl_status_t",
"prepare_next_tx",
"(",
"void",
")",
"{",
"Ecode_t",
"code",
";",
"sli_buf_entry_t",
"*",
"entry",
";",
"CORE_DECLARE_IRQ_STATE",
";",
"CORE_ENTER_ATOMIC",
"(",
")",
";",
"entry",
"=",
"(",
"sli_buf_entry_t",
"*",
")",
"tx_submitted_list_head",
";",
"if",
"(",
"entry",
"==",
"NULL",
")",
"{",
"CORE_EXIT_ATOMIC",
"(",
")",
";",
"return",
"SL_STATUS_EMPTY",
";",
"}",
"if",
"(",
"entry",
"->",
"payload_len",
"<=",
"DMADRV_MAX_XFER_COUNT",
"&&",
"entry",
"->",
"payload_len",
"!=",
"0u",
")",
"{",
"tx_descriptor",
"[",
"0u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_LINKREL_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"hdlc_header",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
",",
"1",
")",
";",
"tx_descriptor",
"[",
"1u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_LINKREL_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"data",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"entry",
"->",
"payload_len",
",",
"1u",
")",
";",
"tx_descriptor",
"[",
"2u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_SINGLE_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"fcs",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"2u",
")",
";",
"tx_descriptor",
"[",
"0u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"tx_descriptor",
"[",
"1u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"tx_descriptor",
"[",
"2u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"1u",
";",
"}",
"else",
"if",
"(",
"entry",
"->",
"payload_len",
"<=",
"(",
"DMADRV_MAX_XFER_COUNT",
"*",
"2",
")",
"&&",
"entry",
"->",
"payload_len",
">",
"0u",
")",
"{",
"tx_descriptor",
"[",
"0u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_LINKREL_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"hdlc_header",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
",",
"1",
")",
";",
"tx_descriptor",
"[",
"1u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_LINKREL_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"data",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"DMADRV_MAX_XFER_COUNT",
",",
"1u",
")",
";",
"tx_descriptor",
"[",
"2u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_LINKREL_M2P_BYTE",
"(",
"&",
"(",
"(",
"uint8_t",
"*",
")",
"entry",
"->",
"handle",
"->",
"data",
")",
"[",
"DMADRV_MAX_XFER_COUNT",
"]",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"(",
"entry",
"->",
"payload_len",
"-",
"DMADRV_MAX_XFER_COUNT",
")",
",",
"1u",
")",
";",
"tx_descriptor",
"[",
"3u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_SINGLE_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"fcs",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"2u",
")",
";",
"tx_descriptor",
"[",
"0u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"tx_descriptor",
"[",
"1u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"tx_descriptor",
"[",
"2u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"tx_descriptor",
"[",
"3u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"1u",
";",
"}",
"else",
"if",
"(",
"entry",
"->",
"payload_len",
"==",
"0u",
")",
"{",
"tx_descriptor",
"[",
"0u",
"]",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_SINGLE_M2P_BYTE",
"(",
"entry",
"->",
"handle",
"->",
"hdlc_header",
",",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"TXDATA",
")",
",",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
")",
";",
"tx_descriptor",
"[",
"0u",
"]",
".",
"xfer",
".",
"doneIfs",
"=",
"1u",
";",
"}",
"else",
"{",
"CORE_EXIT_ATOMIC",
"(",
")",
";",
"return",
"SL_STATUS_INVALID_PARAMETER",
";",
"}",
"tx_ready",
"=",
"false",
";",
"code",
"=",
"DMADRV_LdmaStartTransfer",
"(",
"write_channel",
",",
"&",
"tx_config",
",",
"tx_descriptor",
",",
"NULL",
",",
"NULL",
")",
";",
"EFM_ASSERT",
"(",
"code",
"==",
"ECODE_OK",
")",
";",
"CORE_EXIT_ATOMIC",
"(",
")",
";",
"return",
"SL_STATUS_OK",
";",
"}"
] | Prepare for transmission of next buffer. | [
"Prepare",
"for",
"transmission",
"of",
"next",
"buffer",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | sli_cpc_memory_on_rx_buffer_free | void | void sli_cpc_memory_on_rx_buffer_free(void)
{
sl_status_t status;
bool resource_allocation_flag = false;
void *buffer_ptr = NULL;
LDMA_Descriptor_t *current_desc = NULL;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
do {
if (rx_free_no_buf_list_head == NULL) {
break;
}
sli_buf_entry_t *entry = (sli_buf_entry_t *)rx_free_no_buf_list_head;
status = sli_cpc_get_rx_buffer(&entry->handle);
if (status == SL_STATUS_OK) {
(void)sl_slist_pop(&rx_free_no_buf_list_head);
sli_cpc_push_buffer_handle(&rx_free_list_head, &entry->node, entry->handle);
}
} while (status == SL_STATUS_OK && rx_free_no_buf_list_head != NULL);
do {
current_desc = (LDMA_Descriptor_t *)sli_mem_pool_alloc(&mempool_rx_dma_desc);
if (current_desc == NULL) {
break;
}
status = sli_cpc_get_raw_rx_buffer(&buffer_ptr);
if (status != SL_STATUS_OK) {
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)current_desc);
break;
}
resource_allocation_flag = true;
push_back_new_rx_dma_desc(current_desc, buffer_ptr);
} while (true);
// Start re-synch, if we ran out of DMA descriptor earlier,
// a descriptor is available to be used and the DMA has been stopped.
if (rx_need_desc
&& (LDMA->CHEN & (1 << read_channel)) == 0
&& resource_allocation_flag) {
rx_need_desc = false;
USART_IntEnable(SL_CPC_DRV_UART_PERIPHERAL, USART_IF_RXDATAV);
}
CORE_EXIT_ATOMIC();
} | /***************************************************************************/
/**
* Notification when RX buffer becomes free.
******************************************************************************/ | Notification when RX buffer becomes free. | [
"Notification",
"when",
"RX",
"buffer",
"becomes",
"free",
"."
] | void sli_cpc_memory_on_rx_buffer_free(void)
{
sl_status_t status;
bool resource_allocation_flag = false;
void *buffer_ptr = NULL;
LDMA_Descriptor_t *current_desc = NULL;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_ATOMIC();
do {
if (rx_free_no_buf_list_head == NULL) {
break;
}
sli_buf_entry_t *entry = (sli_buf_entry_t *)rx_free_no_buf_list_head;
status = sli_cpc_get_rx_buffer(&entry->handle);
if (status == SL_STATUS_OK) {
(void)sl_slist_pop(&rx_free_no_buf_list_head);
sli_cpc_push_buffer_handle(&rx_free_list_head, &entry->node, entry->handle);
}
} while (status == SL_STATUS_OK && rx_free_no_buf_list_head != NULL);
do {
current_desc = (LDMA_Descriptor_t *)sli_mem_pool_alloc(&mempool_rx_dma_desc);
if (current_desc == NULL) {
break;
}
status = sli_cpc_get_raw_rx_buffer(&buffer_ptr);
if (status != SL_STATUS_OK) {
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)current_desc);
break;
}
resource_allocation_flag = true;
push_back_new_rx_dma_desc(current_desc, buffer_ptr);
} while (true);
if (rx_need_desc
&& (LDMA->CHEN & (1 << read_channel)) == 0
&& resource_allocation_flag) {
rx_need_desc = false;
USART_IntEnable(SL_CPC_DRV_UART_PERIPHERAL, USART_IF_RXDATAV);
}
CORE_EXIT_ATOMIC();
} | [
"void",
"sli_cpc_memory_on_rx_buffer_free",
"(",
"void",
")",
"{",
"sl_status_t",
"status",
";",
"bool",
"resource_allocation_flag",
"=",
"false",
";",
"void",
"*",
"buffer_ptr",
"=",
"NULL",
";",
"LDMA_Descriptor_t",
"*",
"current_desc",
"=",
"NULL",
";",
"CORE_DECLARE_IRQ_STATE",
";",
"CORE_ENTER_ATOMIC",
"(",
")",
";",
"do",
"{",
"if",
"(",
"rx_free_no_buf_list_head",
"==",
"NULL",
")",
"{",
"break",
";",
"}",
"sli_buf_entry_t",
"*",
"entry",
"=",
"(",
"sli_buf_entry_t",
"*",
")",
"rx_free_no_buf_list_head",
";",
"status",
"=",
"sli_cpc_get_rx_buffer",
"(",
"&",
"entry",
"->",
"handle",
")",
";",
"if",
"(",
"status",
"==",
"SL_STATUS_OK",
")",
"{",
"(",
"void",
")",
"sl_slist_pop",
"(",
"&",
"rx_free_no_buf_list_head",
")",
";",
"sli_cpc_push_buffer_handle",
"(",
"&",
"rx_free_list_head",
",",
"&",
"entry",
"->",
"node",
",",
"entry",
"->",
"handle",
")",
";",
"}",
"}",
"while",
"(",
"status",
"==",
"SL_STATUS_OK",
"&&",
"rx_free_no_buf_list_head",
"!=",
"NULL",
")",
";",
"do",
"{",
"current_desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"sli_mem_pool_alloc",
"(",
"&",
"mempool_rx_dma_desc",
")",
";",
"if",
"(",
"current_desc",
"==",
"NULL",
")",
"{",
"break",
";",
"}",
"status",
"=",
"sli_cpc_get_raw_rx_buffer",
"(",
"&",
"buffer_ptr",
")",
";",
"if",
"(",
"status",
"!=",
"SL_STATUS_OK",
")",
"{",
"sli_mem_pool_free",
"(",
"&",
"mempool_rx_dma_desc",
",",
"(",
"void",
"*",
")",
"current_desc",
")",
";",
"break",
";",
"}",
"resource_allocation_flag",
"=",
"true",
";",
"push_back_new_rx_dma_desc",
"(",
"current_desc",
",",
"buffer_ptr",
")",
";",
"}",
"while",
"(",
"true",
")",
";",
"if",
"(",
"rx_need_desc",
"&&",
"(",
"LDMA",
"->",
"CHEN",
"&",
"(",
"1",
"<<",
"read_channel",
")",
")",
"==",
"0",
"&&",
"resource_allocation_flag",
")",
"{",
"rx_need_desc",
"=",
"false",
";",
"USART_IntEnable",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
",",
"USART_IF_RXDATAV",
")",
";",
"}",
"CORE_EXIT_ATOMIC",
"(",
")",
";",
"}"
] | Notification when RX buffer becomes free. | [
"Notification",
"when",
"RX",
"buffer",
"becomes",
"free",
"."
] | [
"// Start re-synch, if we ran out of DMA descriptor earlier,",
"// a descriptor is available to be used and the DMA has been stopped."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | rx_dma_complete | bool | static bool rx_dma_complete(unsigned int channel,
unsigned int sequenceNo,
void *userParam)
{
LDMA_Descriptor_t *completed_desc = rx_descriptor_head;
uint8_t *rx_buffer = (uint8_t *)(completed_desc->xfer.dstAddr);
uint16_t current_rx_buffer_offset = 0;
uint16_t current_rx_buf_tot_len = next_rx_buf_tot_len;
bool rx_buf_free = true;
(void)channel;
(void)sequenceNo;
(void)userParam;
rx_descriptor_head = (LDMA_Descriptor_t *)(uint32_t)(rx_descriptor_head->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
if (rx_descriptor_head == NULL) {
rx_need_desc = true;
rx_descriptor_tail = NULL;
}
while (current_rx_buf_tot_len > 0) {
uint8_t *current_rx_buffer = &rx_buffer[current_rx_buffer_offset];
if (header_expected_next) {
uint16_t hcs;
current_rx_buf_tot_len -= SLI_CPC_HDLC_HEADER_RAW_SIZE;
current_rx_entry = (sli_buf_entry_t *)SLI_CPC_POP_BUFFER_HANDLE_LIST(&rx_free_list_head, sli_buf_entry_t);
if (current_rx_entry == NULL) {
rx_need_rx_entry = true;
DMADRV_StopTransfer(read_channel);
return false;
}
// Validate HCS
hcs = sli_cpc_hdlc_get_hcs(current_rx_buffer);
if (!sli_cpc_validate_crc_sw(current_rx_buffer, SLI_CPC_HDLC_HEADER_SIZE, hcs)) {
start_re_synch();
return false;
}
next_rx_payload_len = sli_cpc_hdlc_get_length(current_rx_buffer);
if (rx_need_desc
&& next_rx_payload_len > 0) {
DMADRV_StopTransfer(read_channel);
rx_descriptor_head = completed_desc;
rx_descriptor_tail = completed_desc;
// Rewind rx buffer to re-use it
uint32_t dest = LDMA->CH[read_channel].DST;
LDMA->CH[read_channel].DST = (dest - SLI_CPC_HDLC_HEADER_RAW_SIZE);
USART_IntEnable(SL_CPC_DRV_UART_PERIPHERAL, USART_IF_RXDATAV);
return false;
}
if (current_rx_buf_tot_len == 0) {
bool update_success = false;
if ((next_rx_payload_len > 0)
&& (next_rx_payload_len <= DMA_MAX_XFER_LEN)) {
update_success = update_current_rx_dma_length(next_rx_payload_len);
if (!update_success) {
// If we fall here, it's because we received more than the expected payload.
// In that case, we need to re-synch on the next valid header.
update_success = update_current_rx_dma_length(next_rx_payload_len + SLI_CPC_HDLC_HEADER_RAW_SIZE);
}
} else if ((next_rx_payload_len > 0)
&& (next_rx_payload_len > DMA_MAX_XFER_LEN)
&& (next_rx_payload_len <= SLI_CPC_RX_DATA_MAX_LENGTH)) {
update_success = update_current_rx_dma_large_payload_length(next_rx_payload_len);
} else if (!rx_need_desc) {
update_success = update_current_rx_dma_length(SLI_CPC_HDLC_HEADER_RAW_SIZE);
}
if (!update_success) {
start_re_synch();
return false;
}
}
// Copy useful fields of header. Unfortunately with this method the header must always be copied
// Copy only useful bytes
((uint8_t *)current_rx_entry->handle->hdlc_header)[1] = current_rx_buffer[1];
((uint8_t *)current_rx_entry->handle->hdlc_header)[2] = current_rx_buffer[2];
((uint8_t *)current_rx_entry->handle->hdlc_header)[3] = current_rx_buffer[3];
((uint8_t *)current_rx_entry->handle->hdlc_header)[4] = current_rx_buffer[4];
current_rx_entry->handle->data_length = next_rx_payload_len;
if (next_rx_payload_len > SLI_CPC_RX_DATA_MAX_LENGTH) {
notify_core_error(SL_CPC_REJECT_ERROR);
current_rx_entry = NULL;
} else if (next_rx_payload_len == 0) { // A header is expected next
// Push rx_entry to pending list
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
// Notify core
sli_cpc_drv_notify_rx_data();
current_rx_entry = NULL;
} else { // A payload is expected next
header_expected_next = false;
}
current_rx_buffer_offset += SLI_CPC_HDLC_HEADER_RAW_SIZE;
} else {
current_rx_buf_tot_len -= next_rx_payload_len;
if (current_rx_buf_tot_len == 0
&& !rx_need_desc) {
bool update_success;
update_success = update_current_rx_dma_length(SLI_CPC_HDLC_HEADER_RAW_SIZE);
if (!update_success) {
start_re_synch();
return false;
}
}
// Add to current rx handle
EFM_ASSERT(current_rx_entry != NULL);
if (current_rx_buffer_offset) {
// With the current implementation limitations, we should never get here.
memmove(rx_buffer, current_rx_buffer, next_rx_payload_len);
}
current_rx_entry->handle->data = rx_buffer;
current_rx_entry->handle->data_length = next_rx_payload_len;
// A header is expected next
header_expected_next = true;
// Notify core
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
sli_cpc_drv_notify_rx_data();
current_rx_buffer_offset += next_rx_payload_len;
// If we ended here, it means the rx_buffer was pushed to the app.
rx_buf_free = false;
next_rx_payload_len = 0;
}
}
if (rx_buf_free) {
// We end up in that case when we received a header. Since the buffer has not
// been pushed to the core, we can re-use it right away.
push_back_new_rx_dma_desc(completed_desc, rx_buffer);
} else {
LDMA_Descriptor_t *desc = (LDMA_Descriptor_t *)(completed_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)completed_desc);
for (uint16_t i = 1u; i < nb_desc_free; i++) {
LDMA_Descriptor_t *temp_desc = desc;
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)desc);
desc = (LDMA_Descriptor_t *)(temp_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
rx_descriptor_head = desc;
}
nb_desc_free = 0u;
rx_buffer_free_from_isr();
}
return false;
} | /***************************************************************************/
/**
* Rx DMA xfer completed. Need to determine what was received and update the
* XferCnt of the current DMA xfer ASAP.
******************************************************************************/ | Rx DMA xfer completed. Need to determine what was received and update the
XferCnt of the current DMA xfer ASAP. | [
"Rx",
"DMA",
"xfer",
"completed",
".",
"Need",
"to",
"determine",
"what",
"was",
"received",
"and",
"update",
"the",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"ASAP",
"."
] | static bool rx_dma_complete(unsigned int channel,
unsigned int sequenceNo,
void *userParam)
{
LDMA_Descriptor_t *completed_desc = rx_descriptor_head;
uint8_t *rx_buffer = (uint8_t *)(completed_desc->xfer.dstAddr);
uint16_t current_rx_buffer_offset = 0;
uint16_t current_rx_buf_tot_len = next_rx_buf_tot_len;
bool rx_buf_free = true;
(void)channel;
(void)sequenceNo;
(void)userParam;
rx_descriptor_head = (LDMA_Descriptor_t *)(uint32_t)(rx_descriptor_head->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
if (rx_descriptor_head == NULL) {
rx_need_desc = true;
rx_descriptor_tail = NULL;
}
while (current_rx_buf_tot_len > 0) {
uint8_t *current_rx_buffer = &rx_buffer[current_rx_buffer_offset];
if (header_expected_next) {
uint16_t hcs;
current_rx_buf_tot_len -= SLI_CPC_HDLC_HEADER_RAW_SIZE;
current_rx_entry = (sli_buf_entry_t *)SLI_CPC_POP_BUFFER_HANDLE_LIST(&rx_free_list_head, sli_buf_entry_t);
if (current_rx_entry == NULL) {
rx_need_rx_entry = true;
DMADRV_StopTransfer(read_channel);
return false;
}
hcs = sli_cpc_hdlc_get_hcs(current_rx_buffer);
if (!sli_cpc_validate_crc_sw(current_rx_buffer, SLI_CPC_HDLC_HEADER_SIZE, hcs)) {
start_re_synch();
return false;
}
next_rx_payload_len = sli_cpc_hdlc_get_length(current_rx_buffer);
if (rx_need_desc
&& next_rx_payload_len > 0) {
DMADRV_StopTransfer(read_channel);
rx_descriptor_head = completed_desc;
rx_descriptor_tail = completed_desc;
uint32_t dest = LDMA->CH[read_channel].DST;
LDMA->CH[read_channel].DST = (dest - SLI_CPC_HDLC_HEADER_RAW_SIZE);
USART_IntEnable(SL_CPC_DRV_UART_PERIPHERAL, USART_IF_RXDATAV);
return false;
}
if (current_rx_buf_tot_len == 0) {
bool update_success = false;
if ((next_rx_payload_len > 0)
&& (next_rx_payload_len <= DMA_MAX_XFER_LEN)) {
update_success = update_current_rx_dma_length(next_rx_payload_len);
if (!update_success) {
update_success = update_current_rx_dma_length(next_rx_payload_len + SLI_CPC_HDLC_HEADER_RAW_SIZE);
}
} else if ((next_rx_payload_len > 0)
&& (next_rx_payload_len > DMA_MAX_XFER_LEN)
&& (next_rx_payload_len <= SLI_CPC_RX_DATA_MAX_LENGTH)) {
update_success = update_current_rx_dma_large_payload_length(next_rx_payload_len);
} else if (!rx_need_desc) {
update_success = update_current_rx_dma_length(SLI_CPC_HDLC_HEADER_RAW_SIZE);
}
if (!update_success) {
start_re_synch();
return false;
}
}
((uint8_t *)current_rx_entry->handle->hdlc_header)[1] = current_rx_buffer[1];
((uint8_t *)current_rx_entry->handle->hdlc_header)[2] = current_rx_buffer[2];
((uint8_t *)current_rx_entry->handle->hdlc_header)[3] = current_rx_buffer[3];
((uint8_t *)current_rx_entry->handle->hdlc_header)[4] = current_rx_buffer[4];
current_rx_entry->handle->data_length = next_rx_payload_len;
if (next_rx_payload_len > SLI_CPC_RX_DATA_MAX_LENGTH) {
notify_core_error(SL_CPC_REJECT_ERROR);
current_rx_entry = NULL;
} else if (next_rx_payload_len == 0) {
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
sli_cpc_drv_notify_rx_data();
current_rx_entry = NULL;
} else {
header_expected_next = false;
}
current_rx_buffer_offset += SLI_CPC_HDLC_HEADER_RAW_SIZE;
} else {
current_rx_buf_tot_len -= next_rx_payload_len;
if (current_rx_buf_tot_len == 0
&& !rx_need_desc) {
bool update_success;
update_success = update_current_rx_dma_length(SLI_CPC_HDLC_HEADER_RAW_SIZE);
if (!update_success) {
start_re_synch();
return false;
}
}
EFM_ASSERT(current_rx_entry != NULL);
if (current_rx_buffer_offset) {
memmove(rx_buffer, current_rx_buffer, next_rx_payload_len);
}
current_rx_entry->handle->data = rx_buffer;
current_rx_entry->handle->data_length = next_rx_payload_len;
header_expected_next = true;
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
sli_cpc_drv_notify_rx_data();
current_rx_buffer_offset += next_rx_payload_len;
rx_buf_free = false;
next_rx_payload_len = 0;
}
}
if (rx_buf_free) {
push_back_new_rx_dma_desc(completed_desc, rx_buffer);
} else {
LDMA_Descriptor_t *desc = (LDMA_Descriptor_t *)(completed_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)completed_desc);
for (uint16_t i = 1u; i < nb_desc_free; i++) {
LDMA_Descriptor_t *temp_desc = desc;
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)desc);
desc = (LDMA_Descriptor_t *)(temp_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
rx_descriptor_head = desc;
}
nb_desc_free = 0u;
rx_buffer_free_from_isr();
}
return false;
} | [
"static",
"bool",
"rx_dma_complete",
"(",
"unsigned",
"int",
"channel",
",",
"unsigned",
"int",
"sequenceNo",
",",
"void",
"*",
"userParam",
")",
"{",
"LDMA_Descriptor_t",
"*",
"completed_desc",
"=",
"rx_descriptor_head",
";",
"uint8_t",
"*",
"rx_buffer",
"=",
"(",
"uint8_t",
"*",
")",
"(",
"completed_desc",
"->",
"xfer",
".",
"dstAddr",
")",
";",
"uint16_t",
"current_rx_buffer_offset",
"=",
"0",
";",
"uint16_t",
"current_rx_buf_tot_len",
"=",
"next_rx_buf_tot_len",
";",
"bool",
"rx_buf_free",
"=",
"true",
";",
"(",
"void",
")",
"channel",
";",
"(",
"void",
")",
"sequenceNo",
";",
"(",
"void",
")",
"userParam",
";",
"rx_descriptor_head",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"(",
"uint32_t",
")",
"(",
"rx_descriptor_head",
"->",
"xfer",
".",
"linkAddr",
"<<",
"_LDMA_CH_LINK_LINKADDR_SHIFT",
")",
";",
"if",
"(",
"rx_descriptor_head",
"==",
"NULL",
")",
"{",
"rx_need_desc",
"=",
"true",
";",
"rx_descriptor_tail",
"=",
"NULL",
";",
"}",
"while",
"(",
"current_rx_buf_tot_len",
">",
"0",
")",
"{",
"uint8_t",
"*",
"current_rx_buffer",
"=",
"&",
"rx_buffer",
"[",
"current_rx_buffer_offset",
"]",
";",
"if",
"(",
"header_expected_next",
")",
"{",
"uint16_t",
"hcs",
";",
"current_rx_buf_tot_len",
"-=",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
";",
"current_rx_entry",
"=",
"(",
"sli_buf_entry_t",
"*",
")",
"SLI_CPC_POP_BUFFER_HANDLE_LIST",
"(",
"&",
"rx_free_list_head",
",",
"sli_buf_entry_t",
")",
";",
"if",
"(",
"current_rx_entry",
"==",
"NULL",
")",
"{",
"rx_need_rx_entry",
"=",
"true",
";",
"DMADRV_StopTransfer",
"(",
"read_channel",
")",
";",
"return",
"false",
";",
"}",
"hcs",
"=",
"sli_cpc_hdlc_get_hcs",
"(",
"current_rx_buffer",
")",
";",
"if",
"(",
"!",
"sli_cpc_validate_crc_sw",
"(",
"current_rx_buffer",
",",
"SLI_CPC_HDLC_HEADER_SIZE",
",",
"hcs",
")",
")",
"{",
"start_re_synch",
"(",
")",
";",
"return",
"false",
";",
"}",
"next_rx_payload_len",
"=",
"sli_cpc_hdlc_get_length",
"(",
"current_rx_buffer",
")",
";",
"if",
"(",
"rx_need_desc",
"&&",
"next_rx_payload_len",
">",
"0",
")",
"{",
"DMADRV_StopTransfer",
"(",
"read_channel",
")",
";",
"rx_descriptor_head",
"=",
"completed_desc",
";",
"rx_descriptor_tail",
"=",
"completed_desc",
";",
"uint32_t",
"dest",
"=",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"DST",
";",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"DST",
"=",
"(",
"dest",
"-",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
")",
";",
"USART_IntEnable",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
",",
"USART_IF_RXDATAV",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"current_rx_buf_tot_len",
"==",
"0",
")",
"{",
"bool",
"update_success",
"=",
"false",
";",
"if",
"(",
"(",
"next_rx_payload_len",
">",
"0",
")",
"&&",
"(",
"next_rx_payload_len",
"<=",
"DMA_MAX_XFER_LEN",
")",
")",
"{",
"update_success",
"=",
"update_current_rx_dma_length",
"(",
"next_rx_payload_len",
")",
";",
"if",
"(",
"!",
"update_success",
")",
"{",
"update_success",
"=",
"update_current_rx_dma_length",
"(",
"next_rx_payload_len",
"+",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
")",
";",
"}",
"}",
"else",
"if",
"(",
"(",
"next_rx_payload_len",
">",
"0",
")",
"&&",
"(",
"next_rx_payload_len",
">",
"DMA_MAX_XFER_LEN",
")",
"&&",
"(",
"next_rx_payload_len",
"<=",
"SLI_CPC_RX_DATA_MAX_LENGTH",
")",
")",
"{",
"update_success",
"=",
"update_current_rx_dma_large_payload_length",
"(",
"next_rx_payload_len",
")",
";",
"}",
"else",
"if",
"(",
"!",
"rx_need_desc",
")",
"{",
"update_success",
"=",
"update_current_rx_dma_length",
"(",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
")",
";",
"}",
"if",
"(",
"!",
"update_success",
")",
"{",
"start_re_synch",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"(",
"(",
"uint8_t",
"*",
")",
"current_rx_entry",
"->",
"handle",
"->",
"hdlc_header",
")",
"[",
"1",
"]",
"=",
"current_rx_buffer",
"[",
"1",
"]",
";",
"(",
"(",
"uint8_t",
"*",
")",
"current_rx_entry",
"->",
"handle",
"->",
"hdlc_header",
")",
"[",
"2",
"]",
"=",
"current_rx_buffer",
"[",
"2",
"]",
";",
"(",
"(",
"uint8_t",
"*",
")",
"current_rx_entry",
"->",
"handle",
"->",
"hdlc_header",
")",
"[",
"3",
"]",
"=",
"current_rx_buffer",
"[",
"3",
"]",
";",
"(",
"(",
"uint8_t",
"*",
")",
"current_rx_entry",
"->",
"handle",
"->",
"hdlc_header",
")",
"[",
"4",
"]",
"=",
"current_rx_buffer",
"[",
"4",
"]",
";",
"current_rx_entry",
"->",
"handle",
"->",
"data_length",
"=",
"next_rx_payload_len",
";",
"if",
"(",
"next_rx_payload_len",
">",
"SLI_CPC_RX_DATA_MAX_LENGTH",
")",
"{",
"notify_core_error",
"(",
"SL_CPC_REJECT_ERROR",
")",
";",
"current_rx_entry",
"=",
"NULL",
";",
"}",
"else",
"if",
"(",
"next_rx_payload_len",
"==",
"0",
")",
"{",
"sli_cpc_push_back_buffer_handle",
"(",
"&",
"rx_pending_list_head",
",",
"&",
"current_rx_entry",
"->",
"node",
",",
"current_rx_entry",
"->",
"handle",
")",
";",
"sli_cpc_drv_notify_rx_data",
"(",
")",
";",
"current_rx_entry",
"=",
"NULL",
";",
"}",
"else",
"{",
"header_expected_next",
"=",
"false",
";",
"}",
"current_rx_buffer_offset",
"+=",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
";",
"}",
"else",
"{",
"current_rx_buf_tot_len",
"-=",
"next_rx_payload_len",
";",
"if",
"(",
"current_rx_buf_tot_len",
"==",
"0",
"&&",
"!",
"rx_need_desc",
")",
"{",
"bool",
"update_success",
";",
"update_success",
"=",
"update_current_rx_dma_length",
"(",
"SLI_CPC_HDLC_HEADER_RAW_SIZE",
")",
";",
"if",
"(",
"!",
"update_success",
")",
"{",
"start_re_synch",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"EFM_ASSERT",
"(",
"current_rx_entry",
"!=",
"NULL",
")",
";",
"if",
"(",
"current_rx_buffer_offset",
")",
"{",
"memmove",
"(",
"rx_buffer",
",",
"current_rx_buffer",
",",
"next_rx_payload_len",
")",
";",
"}",
"current_rx_entry",
"->",
"handle",
"->",
"data",
"=",
"rx_buffer",
";",
"current_rx_entry",
"->",
"handle",
"->",
"data_length",
"=",
"next_rx_payload_len",
";",
"header_expected_next",
"=",
"true",
";",
"sli_cpc_push_back_buffer_handle",
"(",
"&",
"rx_pending_list_head",
",",
"&",
"current_rx_entry",
"->",
"node",
",",
"current_rx_entry",
"->",
"handle",
")",
";",
"sli_cpc_drv_notify_rx_data",
"(",
")",
";",
"current_rx_buffer_offset",
"+=",
"next_rx_payload_len",
";",
"rx_buf_free",
"=",
"false",
";",
"next_rx_payload_len",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"rx_buf_free",
")",
"{",
"push_back_new_rx_dma_desc",
"(",
"completed_desc",
",",
"rx_buffer",
")",
";",
"}",
"else",
"{",
"LDMA_Descriptor_t",
"*",
"desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"(",
"completed_desc",
"->",
"xfer",
".",
"linkAddr",
"<<",
"_LDMA_CH_LINK_LINKADDR_SHIFT",
")",
";",
"sli_mem_pool_free",
"(",
"&",
"mempool_rx_dma_desc",
",",
"(",
"void",
"*",
")",
"completed_desc",
")",
";",
"for",
"(",
"uint16_t",
"i",
"=",
"1u",
";",
"i",
"<",
"nb_desc_free",
";",
"i",
"++",
")",
"{",
"LDMA_Descriptor_t",
"*",
"temp_desc",
"=",
"desc",
";",
"sli_mem_pool_free",
"(",
"&",
"mempool_rx_dma_desc",
",",
"(",
"void",
"*",
")",
"desc",
")",
";",
"desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"(",
"temp_desc",
"->",
"xfer",
".",
"linkAddr",
"<<",
"_LDMA_CH_LINK_LINKADDR_SHIFT",
")",
";",
"rx_descriptor_head",
"=",
"desc",
";",
"}",
"nb_desc_free",
"=",
"0u",
";",
"rx_buffer_free_from_isr",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Rx DMA xfer completed. | [
"Rx",
"DMA",
"xfer",
"completed",
"."
] | [
"// Validate HCS",
"// Rewind rx buffer to re-use it",
"// If we fall here, it's because we received more than the expected payload.",
"// In that case, we need to re-synch on the next valid header.",
"// Copy useful fields of header. Unfortunately with this method the header must always be copied",
"// Copy only useful bytes",
"// A header is expected next",
"// Push rx_entry to pending list",
"// Notify core",
"// A payload is expected next",
"// Add to current rx handle",
"// With the current implementation limitations, we should never get here.",
"// A header is expected next",
"// Notify core",
"// If we ended here, it means the rx_buffer was pushed to the app.",
"// We end up in that case when we received a header. Since the buffer has not",
"// been pushed to the core, we can re-use it right away."
] | [
{
"param": "channel",
"type": "unsigned int"
},
{
"param": "sequenceNo",
"type": "unsigned int"
},
{
"param": "userParam",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "channel",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sequenceNo",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "userParam",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | force_current_rx_dma_length | void | static void force_current_rx_dma_length(uint16_t new_length)
{
uint32_t ctrl;
uint32_t dest;
uint16_t already_recvd_cnt;
ctrl = LDMA->CH[read_channel].CTRL;
// Rewind the DMA destination to discard previously received bytes
dest = LDMA->CH[read_channel].DST;
already_recvd_cnt = (((SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN) - 1) - ((ctrl & _LDMA_CH_CTRL_XFERCNT_MASK) >> _LDMA_CH_CTRL_XFERCNT_SHIFT);
LDMA->CH[read_channel].DST = (dest - already_recvd_cnt);
ctrl &= ~_LDMA_CH_CTRL_XFERCNT_MASK;
ctrl |= ((new_length - 1) << _LDMA_CH_CTRL_XFERCNT_SHIFT) & _LDMA_CH_CTRL_XFERCNT_MASK;
LDMA->CH[read_channel].CTRL = ctrl;
#if defined(_LDMA_CHDIS_MASK)
LDMA->CHDIS |= (1 << read_channel);
#else
LDMA->IEN |= (1 << read_channel);
#endif
LDMA->CHEN |= (1 << read_channel);
next_rx_buf_tot_len = new_length;
} | /***************************************************************************/
/**
* Force a new XferCnt of the current DMA xfer with the length passed as argument.
* This function also restart the DMA transfer.
*
* @param new_length Total length of next transfer.
*
* @return true if new length successfully applied.
* false if the DMA already transferred more than requested.
******************************************************************************/ | Force a new XferCnt of the current DMA xfer with the length passed as argument.
This function also restart the DMA transfer.
@param new_length Total length of next transfer.
@return true if new length successfully applied.
false if the DMA already transferred more than requested. | [
"Force",
"a",
"new",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
".",
"This",
"function",
"also",
"restart",
"the",
"DMA",
"transfer",
".",
"@param",
"new_length",
"Total",
"length",
"of",
"next",
"transfer",
".",
"@return",
"true",
"if",
"new",
"length",
"successfully",
"applied",
".",
"false",
"if",
"the",
"DMA",
"already",
"transferred",
"more",
"than",
"requested",
"."
] | static void force_current_rx_dma_length(uint16_t new_length)
{
uint32_t ctrl;
uint32_t dest;
uint16_t already_recvd_cnt;
ctrl = LDMA->CH[read_channel].CTRL;
dest = LDMA->CH[read_channel].DST;
already_recvd_cnt = (((SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN) - 1) - ((ctrl & _LDMA_CH_CTRL_XFERCNT_MASK) >> _LDMA_CH_CTRL_XFERCNT_SHIFT);
LDMA->CH[read_channel].DST = (dest - already_recvd_cnt);
ctrl &= ~_LDMA_CH_CTRL_XFERCNT_MASK;
ctrl |= ((new_length - 1) << _LDMA_CH_CTRL_XFERCNT_SHIFT) & _LDMA_CH_CTRL_XFERCNT_MASK;
LDMA->CH[read_channel].CTRL = ctrl;
#if defined(_LDMA_CHDIS_MASK)
LDMA->CHDIS |= (1 << read_channel);
#else
LDMA->IEN |= (1 << read_channel);
#endif
LDMA->CHEN |= (1 << read_channel);
next_rx_buf_tot_len = new_length;
} | [
"static",
"void",
"force_current_rx_dma_length",
"(",
"uint16_t",
"new_length",
")",
"{",
"uint32_t",
"ctrl",
";",
"uint32_t",
"dest",
";",
"uint16_t",
"already_recvd_cnt",
";",
"ctrl",
"=",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
";",
"dest",
"=",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"DST",
";",
"already_recvd_cnt",
"=",
"(",
"(",
"(",
"SLI_CPC_RX_DATA_MAX_LENGTH",
"<",
"DMA_MAX_XFER_LEN",
")",
"?",
"SLI_CPC_RX_DATA_MAX_LENGTH",
":",
"DMA_MAX_XFER_LEN",
")",
"-",
"1",
")",
"-",
"(",
"(",
"ctrl",
"&",
"_LDMA_CH_CTRL_XFERCNT_MASK",
")",
">>",
"_LDMA_CH_CTRL_XFERCNT_SHIFT",
")",
";",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"DST",
"=",
"(",
"dest",
"-",
"already_recvd_cnt",
")",
";",
"ctrl",
"&=",
"~",
"_LDMA_CH_CTRL_XFERCNT_MASK",
";",
"ctrl",
"|=",
"(",
"(",
"new_length",
"-",
"1",
")",
"<<",
"_LDMA_CH_CTRL_XFERCNT_SHIFT",
")",
"&",
"_LDMA_CH_CTRL_XFERCNT_MASK",
";",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
"=",
"ctrl",
";",
"#if",
"defined",
"(",
"_LDMA_CHDIS_MASK",
")",
"\n",
"LDMA",
"->",
"CHDIS",
"|=",
"(",
"1",
"<<",
"read_channel",
")",
";",
"#else",
"LDMA",
"->",
"IEN",
"|=",
"(",
"1",
"<<",
"read_channel",
")",
";",
"#endif",
"LDMA",
"->",
"CHEN",
"|=",
"(",
"1",
"<<",
"read_channel",
")",
";",
"next_rx_buf_tot_len",
"=",
"new_length",
";",
"}"
] | Force a new XferCnt of the current DMA xfer with the length passed as argument. | [
"Force",
"a",
"new",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
"."
] | [
"// Rewind the DMA destination to discard previously received bytes"
] | [
{
"param": "new_length",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_length",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | update_current_rx_dma_length | bool | static bool update_current_rx_dma_length(uint16_t new_length)
{
uint32_t ctrl;
uint16_t already_recvd_cnt;
uint16_t remaining;
// Adjust current dma xfer with new_length
// Note this proof of concept does not support large buffers (buffer larger than the maximum supported by the LDMA)
// For safety we momentarily pause the DMA. If we are afraid of suspending
// it for too long and loosing bytes, we could use a critical section to make
// sure there are not higher priority interrupt until we resume it.
DMADRV_PauseTransfer(read_channel);
ctrl = LDMA->CH[read_channel].CTRL;
already_recvd_cnt = (((SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN) - 1) - ((ctrl & _LDMA_CH_CTRL_XFERCNT_MASK) >> _LDMA_CH_CTRL_XFERCNT_SHIFT);
// For analysis purposes
if (already_recvd_cnt > already_recvd_cnt_worst) {
already_recvd_cnt_worst = already_recvd_cnt;
}
if (already_recvd_cnt >= new_length) {
// Here we failed to update current DMA xfer on time.
DMADRV_ResumeTransfer(read_channel);
return false;
}
remaining = new_length - already_recvd_cnt;
ctrl &= ~_LDMA_CH_CTRL_XFERCNT_MASK;
ctrl |= ((remaining - 1) << _LDMA_CH_CTRL_XFERCNT_SHIFT) & _LDMA_CH_CTRL_XFERCNT_MASK;
LDMA->CH[read_channel].CTRL = ctrl;
DMADRV_ResumeTransfer(read_channel);
next_rx_buf_tot_len = new_length;
return true;
} | /***************************************************************************/
/**
* Update XferCnt of the current DMA xfer with the length passed as argument.
*
* @param new_length Total length of next transfer.
*
* @return true if new length successfully applied.
* false if the DMA already transferred more than requested.
******************************************************************************/ | Update XferCnt of the current DMA xfer with the length passed as argument.
@param new_length Total length of next transfer.
@return true if new length successfully applied.
false if the DMA already transferred more than requested. | [
"Update",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
".",
"@param",
"new_length",
"Total",
"length",
"of",
"next",
"transfer",
".",
"@return",
"true",
"if",
"new",
"length",
"successfully",
"applied",
".",
"false",
"if",
"the",
"DMA",
"already",
"transferred",
"more",
"than",
"requested",
"."
] | static bool update_current_rx_dma_length(uint16_t new_length)
{
uint32_t ctrl;
uint16_t already_recvd_cnt;
uint16_t remaining;
DMADRV_PauseTransfer(read_channel);
ctrl = LDMA->CH[read_channel].CTRL;
already_recvd_cnt = (((SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN) - 1) - ((ctrl & _LDMA_CH_CTRL_XFERCNT_MASK) >> _LDMA_CH_CTRL_XFERCNT_SHIFT);
if (already_recvd_cnt > already_recvd_cnt_worst) {
already_recvd_cnt_worst = already_recvd_cnt;
}
if (already_recvd_cnt >= new_length) {
DMADRV_ResumeTransfer(read_channel);
return false;
}
remaining = new_length - already_recvd_cnt;
ctrl &= ~_LDMA_CH_CTRL_XFERCNT_MASK;
ctrl |= ((remaining - 1) << _LDMA_CH_CTRL_XFERCNT_SHIFT) & _LDMA_CH_CTRL_XFERCNT_MASK;
LDMA->CH[read_channel].CTRL = ctrl;
DMADRV_ResumeTransfer(read_channel);
next_rx_buf_tot_len = new_length;
return true;
} | [
"static",
"bool",
"update_current_rx_dma_length",
"(",
"uint16_t",
"new_length",
")",
"{",
"uint32_t",
"ctrl",
";",
"uint16_t",
"already_recvd_cnt",
";",
"uint16_t",
"remaining",
";",
"DMADRV_PauseTransfer",
"(",
"read_channel",
")",
";",
"ctrl",
"=",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
";",
"already_recvd_cnt",
"=",
"(",
"(",
"(",
"SLI_CPC_RX_DATA_MAX_LENGTH",
"<",
"DMA_MAX_XFER_LEN",
")",
"?",
"SLI_CPC_RX_DATA_MAX_LENGTH",
":",
"DMA_MAX_XFER_LEN",
")",
"-",
"1",
")",
"-",
"(",
"(",
"ctrl",
"&",
"_LDMA_CH_CTRL_XFERCNT_MASK",
")",
">>",
"_LDMA_CH_CTRL_XFERCNT_SHIFT",
")",
";",
"if",
"(",
"already_recvd_cnt",
">",
"already_recvd_cnt_worst",
")",
"{",
"already_recvd_cnt_worst",
"=",
"already_recvd_cnt",
";",
"}",
"if",
"(",
"already_recvd_cnt",
">=",
"new_length",
")",
"{",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"return",
"false",
";",
"}",
"remaining",
"=",
"new_length",
"-",
"already_recvd_cnt",
";",
"ctrl",
"&=",
"~",
"_LDMA_CH_CTRL_XFERCNT_MASK",
";",
"ctrl",
"|=",
"(",
"(",
"remaining",
"-",
"1",
")",
"<<",
"_LDMA_CH_CTRL_XFERCNT_SHIFT",
")",
"&",
"_LDMA_CH_CTRL_XFERCNT_MASK",
";",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
"=",
"ctrl",
";",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"next_rx_buf_tot_len",
"=",
"new_length",
";",
"return",
"true",
";",
"}"
] | Update XferCnt of the current DMA xfer with the length passed as argument. | [
"Update",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
"."
] | [
"// Adjust current dma xfer with new_length",
"// Note this proof of concept does not support large buffers (buffer larger than the maximum supported by the LDMA)",
"// For safety we momentarily pause the DMA. If we are afraid of suspending",
"// it for too long and loosing bytes, we could use a critical section to make",
"// sure there are not higher priority interrupt until we resume it.",
"// For analysis purposes",
"// Here we failed to update current DMA xfer on time."
] | [
{
"param": "new_length",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_length",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | update_current_rx_dma_large_payload_length | bool | static bool update_current_rx_dma_large_payload_length(uint16_t new_length)
{
LDMA_Descriptor_t *desc;
LDMA_Descriptor_t *temp_desc;
// Adjust current dma xfer with new_length
// For safety we momentarily pause the DMA. If we are afraid of suspending
// it for too long and loosing bytes, we could use a critical section to make
// sure there are not higher priority interrupt until we resume it.
DMADRV_PauseTransfer(read_channel);
uint32_t *dst_addr;
uint8_t desc_cnt = 0u;
uint8_t nb_desc = new_length / DMA_MAX_XFER_LEN;
desc = rx_descriptor_head;
temp_desc = rx_descriptor_head;
dst_addr = (uint32_t *)LDMA->CH[read_channel].DST;
#ifdef _LDMA_CH_CTRL_DONEIFSEN_MASK
LDMA->CH[read_channel].CTRL &= ~_LDMA_CH_CTRL_DONEIFSEN_MASK;
#else
LDMA->CH[read_channel].CTRL &= ~_LDMA_CH_CTRL_DONEIEN_MASK;
#endif
// Check if there enough RX descriptor available
for (desc_cnt = 0; temp_desc != NULL; desc_cnt++) {
if (desc_cnt == nb_desc) {
break;
}
temp_desc = (LDMA_Descriptor_t *)(temp_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
}
if (desc_cnt < nb_desc) {
DMADRV_ResumeTransfer(read_channel);
return false;
}
desc_cnt = 0u;
while (desc_cnt < nb_desc) {
desc->xfer.doneIfs = 0u;
desc->xfer.xferCnt = (DMA_MAX_XFER_LEN - 1u);
if (desc_cnt >= 1u) {
sl_cpc_free_rx_buffer((void *)desc->xfer.dstAddr);
}
desc->xfer.dstAddr = ((uint32_t)&dst_addr[(desc_cnt * DMA_MAX_XFER_LEN) / 4u]);
desc = (LDMA_Descriptor_t *)(desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
desc_cnt++;
}
if (desc == NULL) {
DMADRV_ResumeTransfer(read_channel);
return false;
}
sl_cpc_free_rx_buffer((void *)desc->xfer.dstAddr);
desc->xfer.doneIfs = 1u;
desc->xfer.xferCnt = (new_length % DMA_MAX_XFER_LEN) - 1u;
desc->xfer.dstAddr = ((uint32_t)&dst_addr[(desc_cnt * DMA_MAX_XFER_LEN) / 4u]);
if ((new_length % DMA_MAX_XFER_LEN) != 0u) {
nb_desc_free = nb_desc + 1u;
} else {
nb_desc_free = nb_desc;
}
DMADRV_ResumeTransfer(read_channel);
next_rx_buf_tot_len = new_length;
return true;
} | /***************************************************************************/
/**
* Update XferCnt of the current DMA xfer with the length passed as argument.
*
* @param new_length Total length of next transfer.
*
* @return true if new length successfully applied.
* false if the DMA already transferred more than requested.
******************************************************************************/ | Update XferCnt of the current DMA xfer with the length passed as argument.
@param new_length Total length of next transfer.
@return true if new length successfully applied.
false if the DMA already transferred more than requested. | [
"Update",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
".",
"@param",
"new_length",
"Total",
"length",
"of",
"next",
"transfer",
".",
"@return",
"true",
"if",
"new",
"length",
"successfully",
"applied",
".",
"false",
"if",
"the",
"DMA",
"already",
"transferred",
"more",
"than",
"requested",
"."
] | static bool update_current_rx_dma_large_payload_length(uint16_t new_length)
{
LDMA_Descriptor_t *desc;
LDMA_Descriptor_t *temp_desc;
DMADRV_PauseTransfer(read_channel);
uint32_t *dst_addr;
uint8_t desc_cnt = 0u;
uint8_t nb_desc = new_length / DMA_MAX_XFER_LEN;
desc = rx_descriptor_head;
temp_desc = rx_descriptor_head;
dst_addr = (uint32_t *)LDMA->CH[read_channel].DST;
#ifdef _LDMA_CH_CTRL_DONEIFSEN_MASK
LDMA->CH[read_channel].CTRL &= ~_LDMA_CH_CTRL_DONEIFSEN_MASK;
#else
LDMA->CH[read_channel].CTRL &= ~_LDMA_CH_CTRL_DONEIEN_MASK;
#endif
for (desc_cnt = 0; temp_desc != NULL; desc_cnt++) {
if (desc_cnt == nb_desc) {
break;
}
temp_desc = (LDMA_Descriptor_t *)(temp_desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
}
if (desc_cnt < nb_desc) {
DMADRV_ResumeTransfer(read_channel);
return false;
}
desc_cnt = 0u;
while (desc_cnt < nb_desc) {
desc->xfer.doneIfs = 0u;
desc->xfer.xferCnt = (DMA_MAX_XFER_LEN - 1u);
if (desc_cnt >= 1u) {
sl_cpc_free_rx_buffer((void *)desc->xfer.dstAddr);
}
desc->xfer.dstAddr = ((uint32_t)&dst_addr[(desc_cnt * DMA_MAX_XFER_LEN) / 4u]);
desc = (LDMA_Descriptor_t *)(desc->xfer.linkAddr << _LDMA_CH_LINK_LINKADDR_SHIFT);
desc_cnt++;
}
if (desc == NULL) {
DMADRV_ResumeTransfer(read_channel);
return false;
}
sl_cpc_free_rx_buffer((void *)desc->xfer.dstAddr);
desc->xfer.doneIfs = 1u;
desc->xfer.xferCnt = (new_length % DMA_MAX_XFER_LEN) - 1u;
desc->xfer.dstAddr = ((uint32_t)&dst_addr[(desc_cnt * DMA_MAX_XFER_LEN) / 4u]);
if ((new_length % DMA_MAX_XFER_LEN) != 0u) {
nb_desc_free = nb_desc + 1u;
} else {
nb_desc_free = nb_desc;
}
DMADRV_ResumeTransfer(read_channel);
next_rx_buf_tot_len = new_length;
return true;
} | [
"static",
"bool",
"update_current_rx_dma_large_payload_length",
"(",
"uint16_t",
"new_length",
")",
"{",
"LDMA_Descriptor_t",
"*",
"desc",
";",
"LDMA_Descriptor_t",
"*",
"temp_desc",
";",
"DMADRV_PauseTransfer",
"(",
"read_channel",
")",
";",
"uint32_t",
"*",
"dst_addr",
";",
"uint8_t",
"desc_cnt",
"=",
"0u",
";",
"uint8_t",
"nb_desc",
"=",
"new_length",
"/",
"DMA_MAX_XFER_LEN",
";",
"desc",
"=",
"rx_descriptor_head",
";",
"temp_desc",
"=",
"rx_descriptor_head",
";",
"dst_addr",
"=",
"(",
"uint32_t",
"*",
")",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"DST",
";",
"#ifdef",
"_LDMA_CH_CTRL_DONEIFSEN_MASK",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
"&=",
"~",
"_LDMA_CH_CTRL_DONEIFSEN_MASK",
";",
"#else",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"CTRL",
"&=",
"~",
"_LDMA_CH_CTRL_DONEIEN_MASK",
";",
"#endif",
"for",
"(",
"desc_cnt",
"=",
"0",
";",
"temp_desc",
"!=",
"NULL",
";",
"desc_cnt",
"++",
")",
"{",
"if",
"(",
"desc_cnt",
"==",
"nb_desc",
")",
"{",
"break",
";",
"}",
"temp_desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"(",
"temp_desc",
"->",
"xfer",
".",
"linkAddr",
"<<",
"_LDMA_CH_LINK_LINKADDR_SHIFT",
")",
";",
"}",
"if",
"(",
"desc_cnt",
"<",
"nb_desc",
")",
"{",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"return",
"false",
";",
"}",
"desc_cnt",
"=",
"0u",
";",
"while",
"(",
"desc_cnt",
"<",
"nb_desc",
")",
"{",
"desc",
"->",
"xfer",
".",
"doneIfs",
"=",
"0u",
";",
"desc",
"->",
"xfer",
".",
"xferCnt",
"=",
"(",
"DMA_MAX_XFER_LEN",
"-",
"1u",
")",
";",
"if",
"(",
"desc_cnt",
">=",
"1u",
")",
"{",
"sl_cpc_free_rx_buffer",
"(",
"(",
"void",
"*",
")",
"desc",
"->",
"xfer",
".",
"dstAddr",
")",
";",
"}",
"desc",
"->",
"xfer",
".",
"dstAddr",
"=",
"(",
"(",
"uint32_t",
")",
"&",
"dst_addr",
"[",
"(",
"desc_cnt",
"*",
"DMA_MAX_XFER_LEN",
")",
"/",
"4u",
"]",
")",
";",
"desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"(",
"desc",
"->",
"xfer",
".",
"linkAddr",
"<<",
"_LDMA_CH_LINK_LINKADDR_SHIFT",
")",
";",
"desc_cnt",
"++",
";",
"}",
"if",
"(",
"desc",
"==",
"NULL",
")",
"{",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"return",
"false",
";",
"}",
"sl_cpc_free_rx_buffer",
"(",
"(",
"void",
"*",
")",
"desc",
"->",
"xfer",
".",
"dstAddr",
")",
";",
"desc",
"->",
"xfer",
".",
"doneIfs",
"=",
"1u",
";",
"desc",
"->",
"xfer",
".",
"xferCnt",
"=",
"(",
"new_length",
"%",
"DMA_MAX_XFER_LEN",
")",
"-",
"1u",
";",
"desc",
"->",
"xfer",
".",
"dstAddr",
"=",
"(",
"(",
"uint32_t",
")",
"&",
"dst_addr",
"[",
"(",
"desc_cnt",
"*",
"DMA_MAX_XFER_LEN",
")",
"/",
"4u",
"]",
")",
";",
"if",
"(",
"(",
"new_length",
"%",
"DMA_MAX_XFER_LEN",
")",
"!=",
"0u",
")",
"{",
"nb_desc_free",
"=",
"nb_desc",
"+",
"1u",
";",
"}",
"else",
"{",
"nb_desc_free",
"=",
"nb_desc",
";",
"}",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"next_rx_buf_tot_len",
"=",
"new_length",
";",
"return",
"true",
";",
"}"
] | Update XferCnt of the current DMA xfer with the length passed as argument. | [
"Update",
"XferCnt",
"of",
"the",
"current",
"DMA",
"xfer",
"with",
"the",
"length",
"passed",
"as",
"argument",
"."
] | [
"// Adjust current dma xfer with new_length",
"// For safety we momentarily pause the DMA. If we are afraid of suspending",
"// it for too long and loosing bytes, we could use a critical section to make",
"// sure there are not higher priority interrupt until we resume it.",
"// Check if there enough RX descriptor available"
] | [
{
"param": "new_length",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_length",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | update_dma_desc_link_abs | void | static void update_dma_desc_link_abs(LDMA_Descriptor_t *current_dma_desc,
LDMA_Descriptor_t *next_dma_desc)
{
uint32_t link = 0;
uint32_t *current_dma_buffer = (uint32_t *)current_dma_desc;
link = (uint32_t)next_dma_desc;
link |= ldmaLinkModeAbs;
link |= 1 << 1;
current_dma_buffer[3] = link;
} | /***************************************************************************/
/**
* Update dma desccriptor link absolute address.
*
* @param current_dma_desc DMA descriptor to update.
*
* @param next_dma_desc DMA descriptor to link to.
******************************************************************************/ | Update dma desccriptor link absolute address.
@param current_dma_desc DMA descriptor to update.
@param next_dma_desc DMA descriptor to link to. | [
"Update",
"dma",
"desccriptor",
"link",
"absolute",
"address",
".",
"@param",
"current_dma_desc",
"DMA",
"descriptor",
"to",
"update",
".",
"@param",
"next_dma_desc",
"DMA",
"descriptor",
"to",
"link",
"to",
"."
] | static void update_dma_desc_link_abs(LDMA_Descriptor_t *current_dma_desc,
LDMA_Descriptor_t *next_dma_desc)
{
uint32_t link = 0;
uint32_t *current_dma_buffer = (uint32_t *)current_dma_desc;
link = (uint32_t)next_dma_desc;
link |= ldmaLinkModeAbs;
link |= 1 << 1;
current_dma_buffer[3] = link;
} | [
"static",
"void",
"update_dma_desc_link_abs",
"(",
"LDMA_Descriptor_t",
"*",
"current_dma_desc",
",",
"LDMA_Descriptor_t",
"*",
"next_dma_desc",
")",
"{",
"uint32_t",
"link",
"=",
"0",
";",
"uint32_t",
"*",
"current_dma_buffer",
"=",
"(",
"uint32_t",
"*",
")",
"current_dma_desc",
";",
"link",
"=",
"(",
"uint32_t",
")",
"next_dma_desc",
";",
"link",
"|=",
"ldmaLinkModeAbs",
";",
"link",
"|=",
"1",
"<<",
"1",
";",
"current_dma_buffer",
"[",
"3",
"]",
"=",
"link",
";",
"}"
] | Update dma desccriptor link absolute address. | [
"Update",
"dma",
"desccriptor",
"link",
"absolute",
"address",
"."
] | [] | [
{
"param": "current_dma_desc",
"type": "LDMA_Descriptor_t"
},
{
"param": "next_dma_desc",
"type": "LDMA_Descriptor_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_dma_desc",
"type": "LDMA_Descriptor_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "next_dma_desc",
"type": "LDMA_Descriptor_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | push_back_new_rx_dma_desc | void | static void push_back_new_rx_dma_desc(LDMA_Descriptor_t *new_dma_desc,
void *buffer)
{
*new_dma_desc = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_P2M_BYTE(&(SL_CPC_DRV_UART_PERIPHERAL->RXDATA), buffer, (SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN);
new_dma_desc->xfer.doneIfs = 1u;
if (rx_descriptor_tail == NULL) {
rx_descriptor_head = new_dma_desc;
} else {
update_dma_desc_link_abs(rx_descriptor_tail, new_dma_desc);
}
rx_descriptor_tail = new_dma_desc;
if ((LDMA->CHEN & (1 << read_channel)) == 0) {
return;
}
DMADRV_PauseTransfer(read_channel);
if (LDMA->CH[read_channel].LINK == 0) {
LDMA->CH[read_channel].LINK = (uint32_t)new_dma_desc | (1 << 1);
}
DMADRV_ResumeTransfer(read_channel);
} | /***************************************************************************/
/**
* Configure and link a new dma desccriptor to another dma descriptor.
*
* @param new_dma_desc DMA descriptor to configure and link to.
*
* @param buffer Destination buffer for new_dma_desc.
******************************************************************************/ | Configure and link a new dma desccriptor to another dma descriptor.
@param new_dma_desc DMA descriptor to configure and link to.
@param buffer Destination buffer for new_dma_desc. | [
"Configure",
"and",
"link",
"a",
"new",
"dma",
"desccriptor",
"to",
"another",
"dma",
"descriptor",
".",
"@param",
"new_dma_desc",
"DMA",
"descriptor",
"to",
"configure",
"and",
"link",
"to",
".",
"@param",
"buffer",
"Destination",
"buffer",
"for",
"new_dma_desc",
"."
] | static void push_back_new_rx_dma_desc(LDMA_Descriptor_t *new_dma_desc,
void *buffer)
{
*new_dma_desc = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_P2M_BYTE(&(SL_CPC_DRV_UART_PERIPHERAL->RXDATA), buffer, (SLI_CPC_RX_DATA_MAX_LENGTH < DMA_MAX_XFER_LEN) ? SLI_CPC_RX_DATA_MAX_LENGTH : DMA_MAX_XFER_LEN);
new_dma_desc->xfer.doneIfs = 1u;
if (rx_descriptor_tail == NULL) {
rx_descriptor_head = new_dma_desc;
} else {
update_dma_desc_link_abs(rx_descriptor_tail, new_dma_desc);
}
rx_descriptor_tail = new_dma_desc;
if ((LDMA->CHEN & (1 << read_channel)) == 0) {
return;
}
DMADRV_PauseTransfer(read_channel);
if (LDMA->CH[read_channel].LINK == 0) {
LDMA->CH[read_channel].LINK = (uint32_t)new_dma_desc | (1 << 1);
}
DMADRV_ResumeTransfer(read_channel);
} | [
"static",
"void",
"push_back_new_rx_dma_desc",
"(",
"LDMA_Descriptor_t",
"*",
"new_dma_desc",
",",
"void",
"*",
"buffer",
")",
"{",
"*",
"new_dma_desc",
"=",
"(",
"LDMA_Descriptor_t",
")",
"LDMA_DESCRIPTOR_SINGLE_P2M_BYTE",
"(",
"&",
"(",
"SL_CPC_DRV_UART_PERIPHERAL",
"->",
"RXDATA",
")",
",",
"buffer",
",",
"(",
"SLI_CPC_RX_DATA_MAX_LENGTH",
"<",
"DMA_MAX_XFER_LEN",
")",
"?",
"SLI_CPC_RX_DATA_MAX_LENGTH",
":",
"DMA_MAX_XFER_LEN",
")",
";",
"new_dma_desc",
"->",
"xfer",
".",
"doneIfs",
"=",
"1u",
";",
"if",
"(",
"rx_descriptor_tail",
"==",
"NULL",
")",
"{",
"rx_descriptor_head",
"=",
"new_dma_desc",
";",
"}",
"else",
"{",
"update_dma_desc_link_abs",
"(",
"rx_descriptor_tail",
",",
"new_dma_desc",
")",
";",
"}",
"rx_descriptor_tail",
"=",
"new_dma_desc",
";",
"if",
"(",
"(",
"LDMA",
"->",
"CHEN",
"&",
"(",
"1",
"<<",
"read_channel",
")",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"DMADRV_PauseTransfer",
"(",
"read_channel",
")",
";",
"if",
"(",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"LINK",
"==",
"0",
")",
"{",
"LDMA",
"->",
"CH",
"[",
"read_channel",
"]",
".",
"LINK",
"=",
"(",
"uint32_t",
")",
"new_dma_desc",
"|",
"(",
"1",
"<<",
"1",
")",
";",
"}",
"DMADRV_ResumeTransfer",
"(",
"read_channel",
")",
";",
"}"
] | Configure and link a new dma desccriptor to another dma descriptor. | [
"Configure",
"and",
"link",
"a",
"new",
"dma",
"desccriptor",
"to",
"another",
"dma",
"descriptor",
"."
] | [] | [
{
"param": "new_dma_desc",
"type": "LDMA_Descriptor_t"
},
{
"param": "buffer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_dma_desc",
"type": "LDMA_Descriptor_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | rx_buffer_free_from_isr | void | static void rx_buffer_free_from_isr(void)
{
sl_status_t status;
void *buffer_ptr = NULL;
LDMA_Descriptor_t *current_desc = NULL;
do {
current_desc = (LDMA_Descriptor_t *)sli_mem_pool_alloc(&mempool_rx_dma_desc);
if (current_desc == NULL) {
break;
}
status = sli_cpc_get_raw_rx_buffer(&buffer_ptr);
if (status != SL_STATUS_OK) {
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)current_desc);
break;
}
push_back_new_rx_dma_desc(current_desc, buffer_ptr);
} while (true);
} | /***************************************************************************/
/**
* Allocate RX buffer and descriptor from ISR.
******************************************************************************/ | Allocate RX buffer and descriptor from ISR. | [
"Allocate",
"RX",
"buffer",
"and",
"descriptor",
"from",
"ISR",
"."
] | static void rx_buffer_free_from_isr(void)
{
sl_status_t status;
void *buffer_ptr = NULL;
LDMA_Descriptor_t *current_desc = NULL;
do {
current_desc = (LDMA_Descriptor_t *)sli_mem_pool_alloc(&mempool_rx_dma_desc);
if (current_desc == NULL) {
break;
}
status = sli_cpc_get_raw_rx_buffer(&buffer_ptr);
if (status != SL_STATUS_OK) {
sli_mem_pool_free(&mempool_rx_dma_desc, (void *)current_desc);
break;
}
push_back_new_rx_dma_desc(current_desc, buffer_ptr);
} while (true);
} | [
"static",
"void",
"rx_buffer_free_from_isr",
"(",
"void",
")",
"{",
"sl_status_t",
"status",
";",
"void",
"*",
"buffer_ptr",
"=",
"NULL",
";",
"LDMA_Descriptor_t",
"*",
"current_desc",
"=",
"NULL",
";",
"do",
"{",
"current_desc",
"=",
"(",
"LDMA_Descriptor_t",
"*",
")",
"sli_mem_pool_alloc",
"(",
"&",
"mempool_rx_dma_desc",
")",
";",
"if",
"(",
"current_desc",
"==",
"NULL",
")",
"{",
"break",
";",
"}",
"status",
"=",
"sli_cpc_get_raw_rx_buffer",
"(",
"&",
"buffer_ptr",
")",
";",
"if",
"(",
"status",
"!=",
"SL_STATUS_OK",
")",
"{",
"sli_mem_pool_free",
"(",
"&",
"mempool_rx_dma_desc",
",",
"(",
"void",
"*",
")",
"current_desc",
")",
";",
"break",
";",
"}",
"push_back_new_rx_dma_desc",
"(",
"current_desc",
",",
"buffer_ptr",
")",
";",
"}",
"while",
"(",
"true",
")",
";",
"}"
] | Allocate RX buffer and descriptor from ISR. | [
"Allocate",
"RX",
"buffer",
"and",
"descriptor",
"from",
"ISR",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
80eabcc90dce41e437b50e8b69e07b9f1ab4eea2 | SiliconLabs/Gecko_SDK | platform/service/cpc/src/sl_cpc_drv_uart_secondary.c | [
"Zlib"
] | C | notify_core_error | void | static void notify_core_error(sl_cpc_reject_reason_t reason)
{
current_rx_entry->handle->reason = reason;
// Push rx_entry to pending list
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
// Notify core
sli_cpc_drv_notify_rx_data();
} | /***************************************************************************/
/**
* Send a reject notification to CPC core.
*
* @param reason Reject reason.
******************************************************************************/ | Send a reject notification to CPC core.
@param reason Reject reason. | [
"Send",
"a",
"reject",
"notification",
"to",
"CPC",
"core",
".",
"@param",
"reason",
"Reject",
"reason",
"."
] | static void notify_core_error(sl_cpc_reject_reason_t reason)
{
current_rx_entry->handle->reason = reason;
sli_cpc_push_back_buffer_handle(&rx_pending_list_head, ¤t_rx_entry->node, current_rx_entry->handle);
sli_cpc_drv_notify_rx_data();
} | [
"static",
"void",
"notify_core_error",
"(",
"sl_cpc_reject_reason_t",
"reason",
")",
"{",
"current_rx_entry",
"->",
"handle",
"->",
"reason",
"=",
"reason",
";",
"sli_cpc_push_back_buffer_handle",
"(",
"&",
"rx_pending_list_head",
",",
"&",
"current_rx_entry",
"->",
"node",
",",
"current_rx_entry",
"->",
"handle",
")",
";",
"sli_cpc_drv_notify_rx_data",
"(",
")",
";",
"}"
] | Send a reject notification to CPC core. | [
"Send",
"a",
"reject",
"notification",
"to",
"CPC",
"core",
"."
] | [
"// Push rx_entry to pending list",
"// Notify core"
] | [
{
"param": "reason",
"type": "sl_cpc_reject_reason_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reason",
"type": "sl_cpc_reject_reason_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.