From: Alexander Couzens Date: Sat, 9 Mar 2024 19:10:50 +0000 (+0100) Subject: data/code-gen: add support for indications X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7c77e7742e486b4acd68f3f6c86207a2f79c6843;p=project%2Fuqmi.git data/code-gen: add support for indications Indication (or also notifactions) are send by the modem towards the hosts. They are similar to response, but without a request. Some indication will send towards the host as soon the host has created a session with a service. For other indication the host need to subscribe first. Signed-off-by: Alexander Couzens --- diff --git a/data/gen-code.pl b/data/gen-code.pl index 4d53471..d05cc76 100755 --- a/data/gen-code.pl +++ b/data/gen-code.pl @@ -251,6 +251,72 @@ EOF EOF } +sub gen_parse_ind_func($$) +{ + my $name = shift; + my $data = shift; + + my $type = "svc"; + $ctl and $type = "ctl"; + + print gen_tlv_parse_func($name, $data)."\n"; + print <$type.tlv; + unsigned int tlv_len = le16_to_cpu(msg->$type.tlv_len); +EOF + + if (gen_has_types($data)) { + my $n_bits = scalar @$data; + my $n_words = int(($n_bits + 31) / 32); + my $i = 0; + + print <len); + unsigned int ofs = 0; + + switch(tlv->type) { +EOF + foreach my $field (@$data) { + $field = gen_common_ref($field); + my $cname = gen_cname($field->{name}); + gen_tlv_type($cname, $field, $i++); + } + + print <type, le16_to_cpu(tlv->len)); + return QMI_ERROR_INVALID_DATA; +EOF + } else { + print < sub { my $a = shift; my $b = shift; print "*(uint8_t *) $a = $b;\n" }, guint16 => sub { my $a = shift; my $b = shift; print "*(uint16_t *) $a = cpu_to_le16($b);\n" }, @@ -454,4 +520,4 @@ print <{name}." Request", $entry->{input}, $entry); &$res_sub($prefix.$entry->{name}." Response", $entry->{output}, $entry); } + + foreach my $entry (@$data) { + my $args = []; + my $fields = []; + + $common_ref{$entry->{'common-ref'}} = $entry if $entry->{'common-ref'} ne ''; + + next if $entry->{type} ne 'Indication'; + next if not defined $entry->{input} and not defined $entry->{output}; + + &$ind_sub($prefix.$entry->{name}." Indication", $entry->{output}, $entry); + } } + 1; diff --git a/data/gen-header.pl b/data/gen-header.pl index 45edb85..3d2b9b4 100755 --- a/data/gen-header.pl +++ b/data/gen-header.pl @@ -115,5 +115,5 @@ sub gen_parse_func_header($$) $func and print "$func;\n\n"; } -gen_foreach_message_type($data, \&gen_tlv_struct, \&gen_tlv_struct); -gen_foreach_message_type($data, \&gen_set_func_header, \&gen_parse_func_header); +gen_foreach_message_type($data, \&gen_tlv_struct, \&gen_tlv_struct, \&gen_tlv_struct); +gen_foreach_message_type($data, \&gen_set_func_header, \&gen_parse_func_header, \&gen_parse_func_header);