mirror of git://git.sysmocom.de/ofono
stkutil: Merge two versions of bcch_channel_list
This commit is contained in:
parent
ea41f3851d
commit
dc505be373
|
@ -852,10 +852,12 @@ static gboolean parse_dataobj_bcch_channel_list(
|
||||||
unsigned int index = i * 10 / 8;
|
unsigned int index = i * 10 / 8;
|
||||||
unsigned int occupied = i * 10 % 8;
|
unsigned int occupied = i * 10 % 8;
|
||||||
|
|
||||||
bcl->channel[i] = (data[index] << (2 + occupied)) +
|
bcl->channels[i] = (data[index] << (2 + occupied)) +
|
||||||
(data[index + 1] >> (6 - occupied));
|
(data[index + 1] >> (6 - occupied));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bcl->has_list = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4446,27 +4448,27 @@ static gboolean build_dataobj_transaction_id(struct stk_tlv_builder *tlv,
|
||||||
static gboolean build_dataobj_bcch_channel_list(struct stk_tlv_builder *tlv,
|
static gboolean build_dataobj_bcch_channel_list(struct stk_tlv_builder *tlv,
|
||||||
const void *data, gboolean cr)
|
const void *data, gboolean cr)
|
||||||
{
|
{
|
||||||
const struct stk_bcch_ch_list *list = data;
|
const struct stk_bcch_channel_list *list = data;
|
||||||
unsigned char tag = STK_DATA_OBJECT_TYPE_BCCH_CHANNEL_LIST;
|
unsigned char tag = STK_DATA_OBJECT_TYPE_BCCH_CHANNEL_LIST;
|
||||||
int i, bytes, pos, shift;
|
unsigned int i, bytes, pos, shift;
|
||||||
unsigned char value;
|
unsigned char value;
|
||||||
|
|
||||||
/* To distinguish between no BCCH Channel List data object and
|
/* To distinguish between no BCCH Channel List data object and
|
||||||
* an empty object in a sequence of empty and non-empty objects,
|
* an empty object in a sequence of empty and non-empty objects,
|
||||||
* .channels must be non-NULL in objects in sequences. */
|
* .channels must be non-NULL in objects in sequences. */
|
||||||
if (list->channels == NULL)
|
if (list->has_list == FALSE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (stk_tlv_builder_open_container(tlv, cr, tag, TRUE) != TRUE)
|
if (stk_tlv_builder_open_container(tlv, cr, tag, TRUE) != TRUE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
bytes = (list->length * 10 + 7) / 8;
|
bytes = (list->num * 10 + 7) / 8;
|
||||||
for (i = 0; i < bytes; i++) {
|
for (i = 0; i < bytes; i++) {
|
||||||
pos = (i * 8 + 7) / 10;
|
pos = (i * 8 + 7) / 10;
|
||||||
shift = pos * 10 + 10 - i * 8 - 8;
|
shift = pos * 10 + 10 - i * 8 - 8;
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
if (pos < list->length)
|
if (pos < list->num)
|
||||||
value |= list->channels[pos] >> shift;
|
value |= list->channels[pos] >> shift;
|
||||||
if (shift > 2)
|
if (shift > 2)
|
||||||
value |= list->channels[pos - 1] << (10 - shift);
|
value |= list->channels[pos - 1] << (10 - shift);
|
||||||
|
|
|
@ -716,8 +716,9 @@ struct stk_transaction_id {
|
||||||
* is represented as 10 bits, so the maximum number of channel is 127*8/10=101.
|
* is represented as 10 bits, so the maximum number of channel is 127*8/10=101.
|
||||||
*/
|
*/
|
||||||
struct stk_bcch_channel_list {
|
struct stk_bcch_channel_list {
|
||||||
unsigned short channel[101];
|
unsigned short channels[101];
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
|
ofono_bool_t has_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1365,10 +1366,7 @@ struct stk_response_local_info {
|
||||||
const char *imei;
|
const char *imei;
|
||||||
struct stk_network_measurement_results {
|
struct stk_network_measurement_results {
|
||||||
struct stk_common_byte_array nmr;
|
struct stk_common_byte_array nmr;
|
||||||
struct stk_bcch_ch_list {
|
struct stk_bcch_channel_list bcch_ch_list;
|
||||||
const short *channels;
|
|
||||||
int length;
|
|
||||||
} bcch_ch_list;
|
|
||||||
} nmr;
|
} nmr;
|
||||||
struct sms_scts datetime;
|
struct sms_scts datetime;
|
||||||
const char *language;
|
const char *language;
|
||||||
|
|
|
@ -17370,11 +17370,12 @@ static const struct terminal_response_test
|
||||||
.len = 16,
|
.len = 16,
|
||||||
},
|
},
|
||||||
.bcch_ch_list = {
|
.bcch_ch_list = {
|
||||||
.channels = (short[]) {
|
.channels = {
|
||||||
561, 565, 568, 569, 573,
|
561, 565, 568, 569, 573,
|
||||||
575, 577, 581, 582, 585,
|
575, 577, 581, 582, 585,
|
||||||
},
|
},
|
||||||
.length = 10,
|
.num = 10,
|
||||||
|
.has_list = TRUE,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
|
|
Loading…
Reference in New Issue