Skip to content

Commit 30072ef

Browse files
larsgkjthm-ot
authored andcommitted
Fix address type for sources
There was a bug in handling the AT field in URIs and how it was displayed in the list
1 parent 12a2ce8 commit 30072ef

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

web/components/source-item.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,24 @@ template.innerHTML = `
113113
`;
114114

115115
const addrString = (addr) => {
116-
if (!addr) {
116+
if (!addr || !addr.value) {
117117
return "Unknown address";
118118
}
119119

120120
const val = bufToAddressString(addr.value.addr);
121+
const addressType = addr.value.type;
121122

122-
if (addr.type === BT_DataType.BT_DATA_RPA) {
123-
return `${val} (random)`;
124-
} else if (addr.type === BT_DataType.BT_DATA_IDENTITY) {
123+
if (addressType === 0) {
125124
return `${val} (public)`;
126125
}
127126

128-
return "Unknown address type";
127+
if (addressType === 1) {
128+
const isStatic = (addr.value.addr[5] & 0xc0) === 0xc0;
129+
130+
return `${val} (random${isStatic ? ' static':''})`;
131+
}
132+
133+
return `${val} (unknown type)`;
129134
}
130135

131136
export class SourceItem extends HTMLElement {

web/models/assistant-model.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ class AssistantModel extends EventTarget {
8787
addSourceFromBroadcastAudioURI(parsedCode) {
8888
const source = {};
8989

90-
// First, fetch the address type
91-
let addressType = BT_DataType.BT_DATA_IDENTITY;
90+
// Fetch address type (AT)
9291
const atToken = parsedCode.find(t => t.type === 'AT');
93-
if (atToken?.value === 1) {
94-
addressType = BT_DataType.BT_DATA_RPA;
92+
93+
// Assume 'random'/'random static' AT if not specified
94+
let addressType = 1;
95+
if (atToken && atToken.value !== undefined) {
96+
addressType = atToken.value;
9597
}
9698

9799
parsedCode.forEach(token => {
@@ -100,9 +102,9 @@ class AssistantModel extends EventTarget {
100102
source.addr = {
101103
value: {
102104
...token.value,
103-
type: 1,
105+
type: addressType
104106
},
105-
type: addressType
107+
type: BT_DataType.BT_DATA_IDENTITY
106108
}
107109
break;
108110
case 'BN':
@@ -471,12 +473,10 @@ class AssistantModel extends EventTarget {
471473

472474
console.log(`Set size = ${set_size}, rank = ${rank}, sirk = ${sirk}`);
473475

474-
/**
475476
setTimeout(() => {
476477
// Delayed setVolume to prevent comm issue
477478
this.findSetMembers(set_size, sirk);
478479
}, 500);
479-
*/
480480
}
481481

482482
handleSetMemberFound(message) {

0 commit comments

Comments
 (0)