{"action":"created","issue":{"url":"https://api.github.com/repos/secdev/scapy/issues/1743","repository_url":"https://api.github.com/repos/secdev/scapy","labels_url":"https://api.github.com/repos/secdev/scapy/issues/1743/labels{/name}","comments_url":"https://api.github.com/repos/secdev/scapy/issues/1743/comments","events_url":"https://api.github.com/repos/secdev/scapy/issues/1743/events","html_url":"https://github.com/secdev/scapy/issues/1743","id":391050222,"node_id":"MDU6SXNzdWUzOTEwNTAyMjI=","number":1743,"title":"unable to set Advertising Data","user":{"login":"ygtat","id":9306455,"node_id":"MDQ6VXNlcjkzMDY0NTU=","avatar_url":"https://avatars2.githubusercontent.com/u/9306455?v=4","gravatar_id":"","url":"https://api.github.com/users/ygtat","html_url":"https://github.com/ygtat","followers_url":"https://api.github.com/users/ygtat/followers","following_url":"https://api.github.com/users/ygtat/following{/other_user}","gists_url":"https://api.github.com/users/ygtat/gists{/gist_id}","starred_url":"https://api.github.com/users/ygtat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygtat/subscriptions","organizations_url":"https://api.github.com/users/ygtat/orgs","repos_url":"https://api.github.com/users/ygtat/repos","events_url":"https://api.github.com/users/ygtat/events{/privacy}","received_events_url":"https://api.github.com/users/ygtat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-14T10:21:07Z","updated_at":"2018-12-15T09:44:07Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\nI can't set Advertising Data (HCI_Cmd_LE_Set_Advertising_Data) and Scan Response Data (HCI_Cmd_LE_Set_Scan_Response_Data) with scapy.  and I got the error message:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"test.py\", line 52, in <module>\r\n    sock.send_command(HCI_Hdr()/HCI_Command_Hdr()/HCI_Cmd_LE_Set_Advertising_Data(\"\\x02\\x01\\x02\\x06\\x09\\x41\\x41\\x41\\x41\\x00\"))\r\n  File \"/usr/local/lib/python2.7/dist-packages/scapy/layers/bluetooth.py\", line 1120, in send_command\r\n    raise BluetoothCommandError(\"Command %x failed with %x\" % (opcode, r.status))\r\nscapy.layers.bluetooth.BluetoothCommandError: Command 2008 failed with 12\r\n```\r\nI got the same error when testing on multiple systems. Is this a bug in scapy? Or..my code is wrong？\r\n\r\nMy  code for test is as below:\r\n\r\n```\r\nimport os\r\nimport sys\r\nfrom fcntl import ioctl\r\nimport logging as log\r\nimport time\r\nimport socket as s\r\nfrom scapy.layers.bluetooth import *\r\nfrom select import select\r\n\r\n\r\nclass HCIConfig(object):\r\n    @staticmethod\r\n    def down(iface):\r\n        # 31 => PF_BLUETOOTH\r\n        # 0 => HCI_CHANNEL_USER\r\n        # 0x400448ca => HCIDEVDOWN\r\n        sock = s.socket(31, s.SOCK_RAW, 1)\r\n        ioctl(sock.fileno(), 0x400448ca, iface)\r\n        sock.close()\r\n        return True\r\n\r\n    @staticmethod\r\n    def up(iface):\r\n        sock = s.socket(31, s.SOCK_RAW, iface)\r\n        # TODO\r\n        # ioctl(sock.fileno(), HCIDEVUP, 0)\r\n        sock.close()\r\n        return False\r\n\r\ndef get_socket(adapter):\r\n    try:\r\n        return BluetoothUserSocket(adapter)\r\n    except BluetoothSocketError as e:\r\n        log.debug(\"[!] Creating socket failed: %s\\n\" % (repr(e)))\r\n        if os.getuid() > 0:\r\n            log.error(\"[!] Are you definitely root? detected uid: %d\\n\" % (os.getuid()))\r\n        else:\r\n            log.debug(\"[+] have root, attempting to take iface down\\n\")\r\n            HCIConfig.down(adapter)\r\n            try:\r\n                return BluetoothUserSocket(adapter)\r\n            except BluetoothSocketError as e:\r\n                print e\r\n                log.error(\"[!] Failed to create socket: %s\" % repr(e))\r\n                log.error(\"[!] Giving up.\\n\")\r\n    sys.exit(1)\r\n\r\n\r\n\r\nsock=get_socket(0)\r\n\r\nsock.send_command(HCI_Hdr()/HCI_Command_Hdr()/HCI_Cmd_LE_Set_Advertising_Data(\"\\x02\\x01\\x02\\x06\\x09\\x41\\x41\\x41\\x41\\x00\"))\r\nsock.send_command(HCI_Hdr()/HCI_Command_Hdr()/HCI_Cmd_LE_Set_Advertise_Enable(enable=True))\r\n\r\ntime.sleep(10000)\r\n```"},"comment":{"url":"https://api.github.com/repos/secdev/scapy/issues/comments/447554961","html_url":"https://github.com/secdev/scapy/issues/1743#issuecomment-447554961","issue_url":"https://api.github.com/repos/secdev/scapy/issues/1743","id":447554961,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzU1NDk2MQ==","user":{"login":"ygtat","id":9306455,"node_id":"MDQ6VXNlcjkzMDY0NTU=","avatar_url":"https://avatars2.githubusercontent.com/u/9306455?v=4","gravatar_id":"","url":"https://api.github.com/users/ygtat","html_url":"https://github.com/ygtat","followers_url":"https://api.github.com/users/ygtat/followers","following_url":"https://api.github.com/users/ygtat/following{/other_user}","gists_url":"https://api.github.com/users/ygtat/gists{/gist_id}","starred_url":"https://api.github.com/users/ygtat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygtat/subscriptions","organizations_url":"https://api.github.com/users/ygtat/orgs","repos_url":"https://api.github.com/users/ygtat/repos","events_url":"https://api.github.com/users/ygtat/events{/privacy}","received_events_url":"https://api.github.com/users/ygtat/received_events","type":"User","site_admin":false},"created_at":"2018-12-15T09:44:07Z","updated_at":"2018-12-15T09:44:07Z","author_association":"NONE","body":"Thanks! \r\n\r\nAt first, I also thought it was a problem with the bluetooth device. But there is no problem if I send HCI_Cmd_LE_Set_Advertise_Enable command , and it can enable ble advertising. It just doesn't support send HCI_Cmd_LE_Set_Advertising_Data  and HCI_Cmd_LE_Set_Scan_Response_Data command.\r\n\r\nAnd if my bluetooth adaptor is not supported, is there any supported Bluetooth adapter recommended? I have tried three bluetooth adapter.\r\n\r\n"}}
{"actor":{"display_login":"ygtat"}}