Hi Marcel, On Thursday, 22 September 2016 17:47:15 CEST Marcel Holtmann wrote: > Hi Michal, > > > Use complete name if it fits. If not and there is short name > > check if it fits. If not then use shortened name as prefix > > of complete name. > > > > Signed-off-by: Michał Narajowski <michal.narajowski@xxxxxxxxxxx> > > --- > > net/bluetooth/hci_request.c | 46 > > +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 > > insertions(+), 12 deletions(-) > > > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > > index c813568..880758c 100644 > > --- a/net/bluetooth/hci_request.c > > +++ b/net/bluetooth/hci_request.c > > @@ -973,25 +973,47 @@ void __hci_req_enable_advertising(struct hci_request > > *req) > > > > static u8 append_local_name(struct hci_dev *hdev, u8 *ptr, u8 ad_len) > > { > > - size_t name_len; > > + size_t complete_len; > > + size_t short_len; > > > > int max_len; > > > > max_len = HCI_MAX_AD_LENGTH - ad_len - 2; > > > > - name_len = strlen(hdev->dev_name); > > - if (name_len > 0 && max_len > 0) { > > + complete_len = strlen(hdev->dev_name); > > + short_len = strlen(hdev->short_name); > > > > - if (name_len > max_len) { > > - name_len = max_len; > > - ptr[1] = EIR_NAME_SHORT; > > - } else > > - ptr[1] = EIR_NAME_COMPLETE; > > + /* no space left for name */ > > + if (max_len < 1) > > + return ad_len; > > > > - ptr[0] = name_len + 1; > > + /* no name set */ > > + if (!complete_len) > > + return ad_len; > > > > - memcpy(ptr + 2, hdev->dev_name, name_len); > > + /* complete name fits */ > > + if (complete_len <= max_len) { > > + ptr[0] = complete_len + 1; > > + ptr[1] = EIR_NAME_COMPLETE; > > + memcpy(ptr + 2, hdev->dev_name, complete_len); > > > > - ad_len += (name_len + 2); > > - ptr += (name_len + 2); > > + return ad_len + complete_len + 2; > > + } > > so what we discussed is that at minimum 11 octets of name will be included > into the scan response. That is the same size of the Short_name (which > includes the nul-byte). minimum? And do we need to put null byte there? > > If the full name is 11 octets or smaller, then that is included. If the full > name is longer and a short name has been set, then the short name is used. > If the short name is not set, then the full name is truncated to 11 octets. > > For the case where the full name is 11 octets or smaller, the complete tag > is used. For the case where the short name is used or the full name is > truncated, the partial tag is used. So we never include full name if it is longer then 11 octets (with null)? BTW where this 11 octets value came from? I cannot find such requirement in spec. Or this is just limited on mgmt interface level? I don't undertand why not to include complete name if it fits, even if longer than 11 octets. > > + > > + /* shortened name set and fits */ > > Just a note here, it is not called shortened name. It is the short name. We > clearly separated the full name vs short name in the mgmt API. It is called 'shortened' in both CoreSpec and CSS. > Regards > > Marcel > > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" > in the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- pozdrawiam Szymon Janc -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html