title: Write advertising packet in bluetooth low energy with python?
body: <p>On Ubuntu, after installing bluez, according to <a href="https://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi/adding-ibeacon-data" rel="nofollow noreferrer">https://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi/adding-ibeacon-data</a> we can set the bluetooth low energy / 4.0 advertisement data via </p>
  
  <pre><code>sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 
  </code></pre>
  
  <p>and using wireshark or python with <code>sudo hcitool lescan</code> we can see that the data is received by a second btle dongle. Is there also a way to <em>write</em> the advertisement packet in python instead of using hcitool? A library of some kind would be ideal.</p>
  
  <p>In python, I can print the received data using a modified version of <a href="https://stackoverflow.com/questions/22568232/how-to-retrieve-advertising-payload-from-ibeacon-ble">How to retrieve advertising payload from iBeacon / BLE</a> (<code>data[44:13:-1]</code> instead of <code>data[12:6:-1]</code>), and now I wish to <em>transmit</em> data.</p>
  
  <p>(The backstory: I want to broadcast a message fairly frequently (one-to-many multicasting), I have heard btle advertisement can do every 20ms, to several robots without bothering to pair every robot. I do not care about security, I do not need to connect to the robots, I only need to transmit from a central station and have several robots receive the data. I would also be interested in learning how to do write of advertisement packet data on iOS / Android if people have hints).</p>
  
  <p>Specs: python2.7 / 3.2, two CSR 4.0 USB dongles off of ebay, ubuntu 14.04.</p>