title: Is there a method to implement in flutter a sort of bluetooth broadcast like beacons?
body: <p>I would like to know how to realize a sort of "bluetooth broadcast" (using Bluetooth Low Energy) for a Flutter application.
  In particular, i want to achieve those points:</p>
  
  <ul>
  <li>I want to send random string and integers "in the air" using bluetooth.</li>
  <li>I want also to be able to receive those data by other devices</li>
  <li>The app must be able to send and receive simultaneously</li>
  </ul>
  
  <p>Now, i checked some beacon library from pub.dev (like <a href="https://pub.dev/packages/flutter_beacon" rel="nofollow noreferrer">this</a> or <a href="https://pub.dev/packages/beacon_broadcast" rel="nofollow noreferrer">this</a>) but it turns out that probably i did not understand if and how those libraries can help me.</p>
  
  <p>For example, let's consider <strong>beacon_broadcast</strong> library:</p>
  
  <p>The suggested code to make a beacon is the following:</p>
  
  <pre><code>beaconBroadcast
    .setUUID('39ED98FF-2900-441A-802F-9C398FC199D2')
    .setMajorId(1)
    .setMinorId(100)
    .setTransmissionPower(-59) //optional
    .setIdentifier('com.example.myDeviceRegion') //iOS-only, optional
    .setLayout('s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-21v') //Android-only, optional
    .setManufacturerId(0x001D) //Android-only, optional
    .start();
  </code></pre>
  
  <p>However i'm a little bit confused. I would like to understand how can i send custom data (a simple string and a simpler integer).
  On the receiver side, i would like to get all beacons with a specific layout, not only beacons matching a specific UUID.</p>
  
  <p>Something similar to what I want to achieve can be found <a href="http://www.davidgyoungtech.com/2020/04/24/hacking-with-contact-tracing-beacons" rel="nofollow noreferrer">here</a> but it's made in kotlin. If you consider this as the nearest thing to what i need, please suggest me how can i use native code in my flutter project.</p>
  
  <p>Thank you very much.</p>
  
  <p><strong>Edit 1:</strong> we now need to find two Flutter libraries in order to simultaneously send and receive all kind of beacons with the AltBeacon layout. This is not trivial, because it turns out that other devs have strangely implemented one side of the communication and not both. Moreover, it's difficult to find libraries with "batteries included" (i.e able to talk each other out-of-the-box).</p>
  
  <p><strong>Edit 2:</strong> Breaking News ! I combined two flutter libraries, in particular <strong>flutter_beacon</strong> and <strong>beacon_broadcast</strong>. Now, please, help me with the following problem: i can receive beacon, start advertising but not both at the same time.</p>
  
  <p>I don't know what my mistake is, anyway, let's have a look here:</p>
  
  <p>The code i use to scan beacons is the following:</p>
  
  <pre><code>  Future&lt;void&gt; beacon() async {
  
    await flutterBeacon.initializeScanning;
  
    final regions = &lt;Region&gt;[];
  
  // Android platform, it can ranging out of beacon that filter all of Proximity UUID
    regions.add(Region(identifier: 'unito'));
  
        // to start monitoring beacons
    var _streamRanging = flutterBeacon.ranging(regions).listen((RangingResult result) {
      // result contains a region, event type and event state
       print(result);
       print(result.toJson);
       print(result.beacons.toString());
    });
  }
  </code></pre>
  
  <p>The following content is displayed into the debug console:</p>
  
  <p><a href="https://i.stack.imgur.com/IqJkG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IqJkG.png" alt="When i turn on scanning"></a></p>
  
  <p>But, unfortunately, nothing happens if i also activate BLE Advertising:</p>
  
  <p><a href="https://i.stack.imgur.com/d4r7j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d4r7j.png" alt="When i turn on advertising"></a></p>
  
  <p>So, are there any advices ? When i use separately a device for scanning and another for advertising it works...</p>