Ticket refs #5626: Add in-tree definitions for usp events

This commit is contained in:
Amin Ben Ramdhane 2021-08-17 10:33:56 +01:00
parent dc618bc473
commit ec78e61128
15 changed files with 664 additions and 31 deletions

View file

@ -157,11 +157,15 @@ Each object in the **DMOBJ** table contains the following arguments:
| `leaf` | Pointer to a **DMLEAF** array which contains a list of the child parameters |
| `linker` | This argument is used for LowerLayer parameters or to make reference to other instance object in the tree |
| `bbfdm_type` | The bbfdm type of the object. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this object in all protocols (CWMP, USP,...) |
| `uniqueKeys` | The unique key parameters defined for the object. |
### Parameter definition
### Leaf definition
Each parameter in the **DMLEAF** table contains the following arguments:
Each leaf in the **DMLEAF** table can be a **Parameter**, **Command** or **Event**.
#### 1.Parameter definition
| Argument | Description |
| ------------------- | -------------------------------------------------------------------------------------------------- |
@ -172,6 +176,31 @@ Each parameter in the **DMLEAF** table contains the following arguments:
| `setvalue` | The function which set the value of this parameter |
| `bbfdm_type` | The bbfdm type of the parameter. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this parameter in all protocols (CWMP, USP,...) |
#### 2.Command definition
| Argument | Description |
| ------------------- | -------------------------------------------------------------------------------------------------- |
| `PARAM` | A string of the command name. Example “IPPing()”, “DownloadDiagnostics()”, “Renew()” |
| `permission` | The permission of the command. Could be **&DMASYNC** or **&DMSYNC**. |
| `type` | Type of the command, It should be **DMT_COMMAND** |
| `getvalue` | The function which return the input, output arguments of the command |
| `setvalue` | The function which call the operation of the command |
| `bbfdm_type` | The bbfdm type of the command. It should be **BBFDM_USP** as long as operate commands are only defined in USP protocol. |
#### 3.Event definition
| Argument | Description |
| ------------------- | -------------------------------------------------------------------------------------------------- |
| `PARAM` | A string of the event name. Example “Boot!”, “Push!”, “Periodic!” |
| `permission` | The permission of the event. It should be **DMREAD** |
| `type` | Type of the event, It should be **DMT_EVENT** |
| `getvalue` | The function which return the parameter arguments of the event |
| `setvalue` | The function which call the operation of the event, It should be **NULL** |
| `bbfdm_type` | The bbfdm type of the event. It should be **BBFDM_USP** as long as events are only defined in USP protocol. |
## BBF API
`libbbf_api` is a library which contains the source code of all API functions (UCI, Ubus, JSON, CLI and memory management). these API are used for GET/SET/ADD/Delete/Operate calls which can be called in internal or external packages.

View file

@ -223,6 +223,9 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
case CMD_USP_LIST_OPERATE:
fault = dm_entry_list_operates(ctx);
break;
case CMD_USP_LIST_EVENT:
fault = dm_entry_list_events(ctx);
break;
case CMD_GET_SCHEMA:
fault = dm_entry_get_schema(ctx);
break;

View file

@ -56,6 +56,59 @@
"usp"
]
},
"Boot!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
],
"CommandKey": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"Cause": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"enumerations": [
"LocalReboot",
"RemoteReboot",
"LocalFactoryReset",
"RemoteFactoryReset"
]
},
"FirmwareUpdated": {
"type": "boolean",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "boolean"
},
"ParameterMap": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "JSONObject"
}
},
"FactoryReset()": {
"type": "command",
"async": false,
@ -4564,6 +4617,129 @@
}
}
},
"DUStateChange!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
],
"UUID": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "UUID",
"range": [
{
"min": 36,
"max": 36
}
],
"pattern": [
"[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"
]
},
"DeploymentUnitRef": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"Version": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"range": [
{
"max": 32
}
]
},
"CurrentState": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"enumerations": [
"Installed",
"UnInstalled",
"Failed"
]
},
"Resolved": {
"type": "boolean",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "boolean"
},
"ExecutionUnitRefList": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"list": {
"datatype": "string"
}
},
"StartTime": {
"type": "dateTime",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "dateTime"
},
"CompleteTime": {
"type": "dateTime",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "dateTime"
},
"OperationPerformed": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"enumerations": [
"Install",
"Update",
"Uninstall"
]
}
},
"Device.SoftwareModules.ExecEnv.{i}.": {
"type": "object",
"version": "2.1",
@ -41744,9 +41920,9 @@
"uci": {
"file": "network",
"section": {
"type": "interface"
"type": "device"
},
"dmmapfile": "dmmap_network"
"dmmapfile": "dmmap_bridge"
}
},
"Enable": {
@ -76499,6 +76675,23 @@
],
"datatype": "string"
},
"Push!": {
"type": "event",
"version": "2.13",
"protocols": [
"usp"
],
"Data": {
"type": "string",
"read": true,
"write": true,
"version": "2.13",
"protocols": [
"usp"
],
"datatype": "string"
}
},
"Device.BulkData.Profile.{i}.Parameter.{i}.": {
"type": "object",
"version": "2.5",
@ -88594,6 +88787,141 @@
"datatype": "unsignedInt",
"unit": "seconds"
},
"Periodic!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
]
},
"WakeUp!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
]
},
"TransferComplete!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
],
"Command": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"CommandKey": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"Requestor": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"TransferType": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"enumerations": [
"Download",
"Upload"
]
},
"Affected": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
},
"TransferURL": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "URL",
"range": [
{
"max": 2048
}
]
},
"StartTime": {
"type": "dateTime",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "dateTime"
},
"CompleteTime": {
"type": "dateTime",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "dateTime"
},
"FaultCode": {
"type": "unsignedInt",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "unsignedInt"
},
"FaultString": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string",
"range": [
{
"max": 256
}
]
}
},
"AddCertificate()": {
"type": "command",
"async": false,
@ -89170,6 +89498,33 @@
"usp"
],
"datatype": "string"
},
"Triggered!": {
"type": "event",
"version": "2.13",
"protocols": [
"usp"
],
"ParamPath": {
"type": "string",
"read": true,
"write": true,
"version": "2.13",
"protocols": [
"usp"
],
"datatype": "string"
},
"ParamValue": {
"type": "string",
"read": true,
"write": true,
"version": "2.13",
"protocols": [
"usp"
],
"datatype": "string"
}
}
},
"Device.LocalAgent.Controller.{i}.": {
@ -89368,6 +89723,23 @@
}
}
},
"Timer!": {
"type": "event",
"version": "2.12",
"protocols": [
"usp"
],
"CommandKey": {
"type": "string",
"read": true,
"write": true,
"version": "2.12",
"protocols": [
"usp"
],
"datatype": "string"
}
},
"AddMyCertificate()": {
"type": "command",
"async": false,

View file

@ -37,7 +37,7 @@ echo "Validate UserInterface JSON Plugin"
./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
check_ret $?
echo "Validate TR-181 JSON Plugin afetr generating from XML"
echo "Validate TR-181 JSON Plugin after generating from XML"
json_path=$(./tools/convert_dm_xml_to_json.py test/tools/tr-181-2-14-1-cwmp-full.xml test/tools/tr-181-2-14-1-usp-full.xml Device.)
./test/tools/validate_json_plugin.py $json_path
check_ret $?

View file

@ -210,7 +210,7 @@ static int dm_browse_leaf(struct dmctx *dmctx, DMNODE *parent_node, DMLEAF *leaf
if (!bbfdatamodel_matches(leaf->bbfdm_type))
continue;
if (dmctx->iscommand != (leaf->type == DMT_COMMAND))
if (dmctx->iscommand != (leaf->type == DMT_COMMAND) || dmctx->isevent != (leaf->type == DMT_EVENT))
continue;
snprintf(dm_browse_path, MAX_DM_PATH, "%s%s", parent_node->current_object, leaf->parameter);
@ -231,7 +231,7 @@ static int dm_browse_leaf(struct dmctx *dmctx, DMNODE *parent_node, DMLEAF *leaf
if (!bbfdatamodel_matches(jleaf->bbfdm_type))
continue;
if (dmctx->iscommand != (jleaf->type == DMT_COMMAND))
if (dmctx->iscommand != (jleaf->type == DMT_COMMAND) || dmctx->isevent != (jleaf->type == DMT_EVENT))
continue;
snprintf(dm_browse_path, MAX_DM_PATH, "%s%s", parent_node->current_object, jleaf->parameter);
@ -1669,6 +1669,46 @@ int dm_entry_operate(struct dmctx *dmctx)
return CMD_NOT_FOUND;
}
/* ************
* list event
* ************/
static int mobj_list_events_name(DMOBJECT_ARGS)
{
return 0;
}
static int mparam_list_events_name(DMPARAM_ARGS)
{
char *value = NULL;
char *full_param;
dmastrcat(&full_param, node->current_object, lastname);
if (get_cmd)
(get_cmd)(full_param, dmctx, data, instance, &value);
add_list_parameter(dmctx, full_param, value, permission->val, NULL);
return 0;
}
int dm_entry_list_events(struct dmctx *dmctx)
{
DMOBJ *root = dmctx->dm_entryobj;
DMNODE node = {.current_object = ""};
int err;
dmctx->inparam_isparam = 0;
dmctx->isgetschema = 1;
dmctx->isevent = 1;
dmctx->findparam = 0;
dmctx->stop = 0;
dmctx->checkobj = NULL;
dmctx->checkleaf = NULL;
dmctx->method_obj = mobj_list_events_name;
dmctx->method_param = mparam_list_events_name;
err = dm_browse(dmctx, &node, root, NULL, NULL);
return err;
}
int dm_browse_last_access_path(char *path, size_t len)
{
snprintf(path, len, "%s", dm_browse_path);

View file

@ -185,6 +185,7 @@ struct dmctx
unsigned int end_session_flag;
bool isgetschema;
bool iscommand;
bool isevent;
};
typedef struct dmnode {
@ -231,6 +232,10 @@ typedef struct {
const char **out;
} operation_args;
typedef struct {
const char **param;
} event_args;
typedef enum operate_ret_status opr_ret_t;
typedef opr_ret_t (*operation) (struct dmctx *dmctx, char *p, json_object *input);
@ -260,6 +265,7 @@ enum {
CMD_DEL_OBJECT,
CMD_USP_OPERATE,
CMD_USP_LIST_OPERATE,
CMD_USP_LIST_EVENT,
CMD_GET_SCHEMA,
CMD_GET_INSTANCES,
CMD_EXTERNAL_COMMAND
@ -385,6 +391,7 @@ enum dmt_type_enum {
DMT_HEXBIN,
DMT_BASE64,
DMT_COMMAND,
DMT_EVENT,
};
enum amd_version_enum {
@ -433,6 +440,7 @@ int dm_entry_get_linker(struct dmctx *dmctx);
int dm_entry_get_linker_value(struct dmctx *dmctx);
int dm_entry_list_operates(struct dmctx *ctx);
int dm_entry_operate(struct dmctx *dmctx);
int dm_entry_list_events(struct dmctx *dmctx);
int dm_browse_last_access_path(char *path, size_t len);
char *get_last_instance(char *package, char *section, char *opt_inst);
char *get_last_instance_bbfdm(char *package, char *section, char *opt_inst);

View file

@ -314,6 +314,25 @@ static int operate_DeviceXIOPSYSEUPingTEST_Run(char *refparam, struct dmctx *ctx
return CMD_SUCCESS;
}
/*************************************************************
* EVENTS
*************************************************************/
static event_args boot_event_args = {
.param = (const char *[]) {
"CommandKey",
"Cause",
"FirmwareUpdated",
"ParameterMap",
NULL
}
};
static int get_event_args_XIOPSYSEU_Boot(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = (char *)&boot_event_args;
return 0;
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -351,6 +370,8 @@ DMOBJ tDynamicDeviceObj[] = {
DMLEAF tDynamicDeviceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"X_IOPSYS_EU_Reboot()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_X_IOPSYS_EU_Reboot, BBFDM_USP},
{"X_IOPSYS_EU_Boot!", &DMREAD, DMT_EVENT, get_event_args_XIOPSYSEU_Boot, NULL, BBFDM_USP},
{"X_IOPSYS_EU_WakeUp!", &DMREAD, DMT_EVENT, NULL, NULL, BBFDM_USP},
{0}
};

View file

@ -288,6 +288,52 @@ static void test_api_bbfdm_valid_library_operate(void **state)
}
}
static void test_api_bbfdm_valid_library_event(void **state)
{
struct dmctx *ctx = (struct dmctx *) *state;
struct dm_parameter *n;
int fault = 0, idx = 0;
fault = dm_entry_param_method(ctx, CMD_USP_LIST_EVENT, NULL, NULL, NULL);
assert_int_equal(fault, 0);
list_for_each_entry(n, &ctx->list_parameter, list) {
if (strcmp(n->name, "Device.X_IOPSYS_EU_WakeUp!") == 0) {
assert_string_equal(n->type, "0");
assert_null(n->data);
}
if (strcmp(n->name, "Device.X_IOPSYS_EU_Boot!") == 0) {
assert_string_equal(n->type, "0");
event_args *args = (event_args *)n->data;
assert_non_null(args);
const char **event_param = args->param;
assert_non_null(event_param);
for (int i = 0; event_param[i] != NULL; i++) {
switch (i) {
case 0:
assert_string_equal(event_param[i], "CommandKey");
break;
case 1:
assert_string_equal(event_param[i], "Cause");
break;
case 2:
assert_string_equal(event_param[i], "FirmwareUpdated");
break;
case 3:
assert_string_equal(event_param[i], "ParameterMap");
break;
}
}
}
idx++;
}
assert_int_equal(idx, 2);
}
int main(void)
{
const struct CMUnitTest tests[] = {
@ -304,6 +350,9 @@ int main(void)
// Operate method test cases
cmocka_unit_test_setup_teardown(test_api_bbfdm_valid_standard_operate, setup, teardown_commit),
cmocka_unit_test_setup_teardown(test_api_bbfdm_valid_library_operate, setup, teardown_commit),
// Event method test cases
cmocka_unit_test_setup_teardown(test_api_bbfdm_valid_library_event, setup, teardown_commit),
};
return cmocka_run_group_tests(tests, NULL, group_teardown);

View file

@ -396,6 +396,19 @@ static void test_api_bbfdm_get_list_operate(void **state)
assert_true(&first_entry->list != &ctx->list_parameter);
}
static void test_api_bbfdm_get_list_event(void **state)
{
struct dmctx *ctx = (struct dmctx *) *state;
struct dm_parameter *first_entry;
int fault = 0;
fault = dm_entry_param_method(ctx, CMD_USP_LIST_EVENT, NULL, NULL, NULL);
assert_int_equal(fault, 0);
first_entry = list_first_entry(&ctx->list_parameter, struct dm_parameter, list);
assert_true(&first_entry->list != &ctx->list_parameter);
}
static void test_api_bbfdm_get_schema(void **state)
{
struct dmctx *ctx = (struct dmctx *) *state;
@ -687,6 +700,9 @@ int main(void)
// Get List Operate method test cases
cmocka_unit_test_setup_teardown(test_api_bbfdm_get_list_operate, setup, teardown_commit),
// Get List Operate method test cases
cmocka_unit_test_setup_teardown(test_api_bbfdm_get_list_event, setup, teardown_commit),
// Get Schema method test cases
cmocka_unit_test_setup_teardown(test_api_bbfdm_get_schema, setup, teardown_commit),

View file

@ -165,7 +165,7 @@ def parse_value( key , value ):
validate(instance = value, schema = obj_schema if key.endswith('.') else param_schema)
for k, v in value.items():
if not k.endswith('()') and k != "list" and k != "mapping" and isinstance(v, dict):
if not k.endswith('()') and not k.endswith('!') and k != "list" and k != "mapping" and isinstance(v, dict):
parse_value(k, v)
### main ###

View file

@ -39,7 +39,8 @@ Array_Types = {"string": "DMT_STRING",
"dateTime": "DMT_TIME",
"hexBinary": "DMT_HEXBIN",
"base64": "DMT_BASE64",
"command": "DMT_COMMAND"}
"command": "DMT_COMMAND",
"event": "DMT_EVENT"}
def rename_file(old_file_name, new_file_name):

View file

@ -798,7 +798,7 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
fp.close()
def cprinOperateCommands(getoperateargs, operate, in_args, out_args, struct_name):
def cprintOperateCommands(getoperateargs, operate, in_args, out_args, struct_name):
# Open file
fp = open('./.operatecommands.c', 'a')
@ -808,35 +808,35 @@ def cprinOperateCommands(getoperateargs, operate, in_args, out_args, struct_name
if in_args != None:
if isinstance(in_args, dict):
print(" .in = (const char *[]) {", file=fp)
print(" .in = (const char *[]) {", file=fp)
for obj, _val in in_args.items():
print(" \"%s\"," % obj, file=fp)
print(" NULL", file=fp)
print(" %s" % ("}," if out_args != None else "}"), file=fp)
print(" \"%s\"," % obj, file=fp)
print(" NULL", file=fp)
print(" %s" % ("}," if out_args != None else "}"), file=fp)
if out_args != None:
if isinstance(out_args, dict):
print(" .out = (const char *[]) {", file=fp)
print(" .out = (const char *[]) {", file=fp)
for obj, _val in out_args.items():
print(" \"%s\"," % obj, file=fp)
print(" NULL", file=fp)
print(" }", file=fp)
print(" \"%s\"," % obj, file=fp)
print(" NULL", file=fp)
print(" }", file=fp)
print("};", file=fp)
print("", file=fp)
print("static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)" % getoperateargs, file=fp)
print("{", file=fp)
print(" *value = (char *)&%s;" % struct_name, file=fp)
print(" return 0;", file=fp)
print(" *value = (char *)&%s;" % struct_name, file=fp)
print(" return 0;", file=fp)
print("}", file=fp)
print("", file=fp)
############################## OPERATE ########################################
print("static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)" % operate, file=fp)
print("{", file=fp)
print(" //TODO", file=fp)
print(" return CMD_SUCCESS;", file=fp)
print(" //TODO", file=fp)
print(" return CMD_SUCCESS;", file=fp)
print("}", file=fp)
print("", file=fp)
@ -844,6 +844,34 @@ def cprinOperateCommands(getoperateargs, operate, in_args, out_args, struct_name
fp.close()
def cprintEvent(geteventargs, param_args, struct_name):
# Open file
fp = open('./.events.c', 'a')
if param_args != None:
############################## OPERATE ARGUMENTS ########################################
print("static event_args %s = {" % struct_name, file=fp)
if isinstance(param_args, dict):
print(" .param = (const char *[]) {", file=fp)
for obj, _val in param_args.items():
print(" \"%s\"," % obj, file=fp)
print(" NULL", file=fp)
print(" }", file=fp)
print("};", file=fp)
print("", file=fp)
print("static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)" % geteventargs, file=fp)
print("{", file=fp)
print(" *value = (char *)&%s;" % struct_name, file=fp)
print(" return 0;", file=fp)
print("}", file=fp)
print("", file=fp)
# Close file
fp.close()
def cprintheaderPARAMS(objname):
fp = open('./.objparamarray.c', 'a')
print("DMLEAF %s[] = {" % ("t" + getname(objname) + "Params"), file=fp)
@ -906,13 +934,30 @@ def printCOMMANDline( parentname, dmparam, value ):
else:
getoperateargs = "NULL"
cprinOperateCommands(getoperateargs, operate, in_args, out_args, commonname.replace("()", "").lower()+"_args")
cprintOperateCommands(getoperateargs, operate, in_args, out_args, commonname.replace("()", "").lower()+"_args")
fp = open('./.objparamarray.c', 'a')
print("{\"%s\", %s, %s, %s, %s, %s}," % (dmparam, c_type, ptype, getoperateargs, operate, bbfdm), file=fp)
fp.close()
def printEVENTline( parentname, dmparam, value ):
commonname = getname(parentname) + "_" + dmparam
ptype = bbf.get_param_type(value)
bbfdm = getprotocolsparam(value, "protocols")
hasparam = bbf.obj_has_param(value)
if hasparam:
geteventargs = "get_event_args_" + commonname.replace("!", "")
cprintEvent(geteventargs, value, commonname.replace("!", "").lower()+"_args")
else:
geteventargs = "NULL"
fp = open('./.objparamarray.c', 'a')
print("{\"%s\", &DMREAD, %s, %s, NULL, %s}," % (dmparam, ptype, geteventargs, bbfdm), file=fp)
fp.close()
def printtailArray():
fp = open('./.objparamarray.c', 'a')
print("{0}", file=fp)
@ -1018,7 +1063,11 @@ def object_parse_childs(dmobject, value, nextlevel):
if k1 == "type" and v1 == "command":
printCOMMANDline(dmobject, k, v)
break
break
if k1 == "type" and v1 == "event":
printEVENTline(dmobject, k, v)
break
if k1 == "type" and v1 != "object":
printPARAMline(dmobject, k, v)
@ -1103,6 +1152,19 @@ def generatecfromobj(pobj, pvalue, pdir, nextlevel):
except IOError:
pass
try:
exists = os.path.isfile("./.events.c")
if exists:
print("/*************************************************************", file=dmfpc)
print("* EVENTS", file=dmfpc)
print("**************************************************************/", file=dmfpc)
tmpf = open("./.events.c", "r")
tmpd = tmpf.read()
tmpf.close()
dmfpc.write(tmpd)
except IOError:
pass
try:
print("/**********************************************************************************************************************************", file=dmfpc)
print("* OBJ & PARAM DEFINITION", file=dmfpc)
@ -1134,6 +1196,7 @@ def removetmpfiles():
bbf.remove_file("./.objbrowse.c")
bbf.remove_file("./.getstevalue.c")
bbf.remove_file("./.operatecommands.c")
bbf.remove_file("./.events.c")
### main ###

View file

@ -646,6 +646,33 @@ def printCOMMAND(dmparam, dmobject, _bbfdm_type):
fp.close()
def printEVENT(dmparam, dmobject, _bbfdm_type):
fp = open('./.json_tmp', 'a')
print("\"%s\" : {" % dmparam.get('name'), file=fp)
print("\"type\" : \"event\",", file=fp)
print("\"version\" : \"%s\"," % dmparam.get('version'), file=fp)
has_param = 0
for c in dmparam:
if c.tag == "parameter":
has_param = 1
print(("\"protocols\" : [\"usp\"],") if (has_param) else (
"\"protocols\" : [\"usp\"]"), file=fp)
if has_param:
fp.close()
for param in dmparam:
if param.tag == "parameter":
printPARAM(param, dmobject, "\"usp\"")
if has_param:
fp = open('./.json_tmp', 'a')
print("}", file=fp)
fp.close()
def printusage():
print("Usage: " +
sys.argv[0] + " <tr-xxx cwmp xml data model> <tr-xxx usp xml data model> [Object path]")
@ -728,6 +755,8 @@ def chech_obj_with_other_obj(obj, dmobject):
printPARAM(c, obj, "\"cwmp\"")
if c.tag == "command":
printCOMMAND(c, obj, "\"usp\"")
if c.tag == "event":
printEVENT(c, obj, "\"usp\"")
def object_parse_childs(dmobject, level, generatelist, check_obj):
@ -760,6 +789,8 @@ def object_parse_childs(dmobject, level, generatelist, check_obj):
printPARAM(c, dmobject, bbfdm_type)
if c.tag == "command":
printCOMMAND(c, dmobject, "\"usp\"")
if c.tag == "event":
printEVENT(c, dmobject, "\"usp\"")
if check_obj == 1 and "tr-181" in sys.argv[1] and exist == 1:
chech_obj_with_other_obj(obj, dmobject)

View file

@ -27,7 +27,7 @@ def getprotocols(value):
return "CWMP+USP"
def check_param_obj_command(dmobject):
def is_param_obj_command_event_supported(dmobject):
for value in bbf.LIST_SUPPORTED_DM:
obj = value.split(",")
if obj[0] == dmobject:
@ -44,7 +44,7 @@ def parse_standard_object(dmobject, value):
hasobj = bbf.obj_has_child(value)
hasparam = bbf.obj_has_param(value)
supported = check_param_obj_command(dmobject)
supported = is_param_obj_command_event_supported(dmobject)
add_data_to_list_dm(dmobject, supported, getprotocols(value), "object")
if hasparam:
@ -55,8 +55,8 @@ def parse_standard_object(dmobject, value):
if isinstance(v, dict):
for k1, v1 in v.items():
if k1 == "type" and v1 != "object":
supported = check_param_obj_command(dmobject + k)
add_data_to_list_dm(dmobject + k, supported, getprotocols(v), "operate" if "()" in k else "parameter")
supported = is_param_obj_command_event_supported(dmobject + k)
add_data_to_list_dm(dmobject + k, supported, getprotocols(v), "operate" if "()" in k else "event" if "!" in k else "parameter")
break
if hasobj:
@ -151,7 +151,7 @@ def generate_excel_file(output_file):
'pattern: pattern solid, fore_colour custom_colour_yellow')
style = xlwt.easyxf(
'pattern: pattern solid, fore_colour custom_colour_yellow;''alignment: horizontal center;')
elif param[3] == "operate":
elif param[3] == "operate" or param[3] == "event":
style_name = xlwt.easyxf(
'pattern: pattern solid, fore_colour custom_colour_green')
style = xlwt.easyxf(

View file

@ -53,7 +53,7 @@ def generate_bbf_xml_file(output_file):
for value in bbf.LIST_SUPPORTED_DM:
if "()" in value:
if "()" in value or "!" in value:
continue
obj = value.strip().split(",")
@ -149,7 +149,7 @@ def generate_hdm_xml_file(output_file):
for value in bbf.LIST_SUPPORTED_DM:
if "()" in value:
if "()" in value or "!" in value:
continue
obj = value.strip().split(",")