Bluetooth-based Beacon technology pure dry goods tailored to their own exclusive Beacon
We don’t currently have an AltBeacon in the traditional sense, but I’ve got several Bluetooth development boards on hand. These boards are essentially smart microcontrollers with built-in Bluetooth protocol stacks, making them ideal for prototyping. They come with a wide range of peripheral interfaces and headers, which makes them perfect for building functional prototypes or testing ideas before moving to mass production. The firmware can be directly flashed onto the board or even used in the final product for demonstration purposes. I decided to create a Beacon application using the development boards I have, and then test it with the Android Museum Guide app.
I’m using the Bluegiga DK Bluetooth Low Energy Development Kit and the Intel Edison Development Board. The Bluegiga board is programmed using BGScript, a simple yet powerful scripting language. On the other hand, the Intel Edison runs Linux and offers multiple programming options. Since I'm more familiar with Node.js and JavaScript, I chose to use this framework to access the Smart Bluetooth features and libraries.
**Turning Bluegiga into AltBeacon**
BGScript is easy to learn and comes with a rich set of built-in functions provided by the Bluegiga framework. Developing an application with BGScript involves writing a script file along with project configuration files using a text editor. Once written, the firmware can be compiled and uploaded directly to the board via USB using the Bluegiga SDK.
BGScript includes variable declarations, array handling, and event handler callback functions. Callbacks are a crucial part of the programming model, as they allow the system to respond to specific events. For example, calling a standard Bluegiga function will trigger the appropriate callback. Similarly, the framework can also call an event handler when an external condition occurs.
Implementing a Beacon on any platform requires working with the Generic Access Profile (GAP), which involves setting the broadcast packet content and configuring the broadcast parameters.
The key components of my Bluegiga AltBeacon implementation include:
- Declaring variables and arrays.
- Configuring the broadcast settings within the `system_boot` event handler.
- Defining the manufacturer-specific data field to encode AltBeacon information.
- Setting a local name that appears in scan results from central devices like smartphones.
Here’s how the initial setup looks in code:
[Figure 2 – Define flags broadcast type in the system_boot event handler]
In the first part of the process, I defined the flags field, which indicates support for Bluetooth Smart and/or Bluetooth BR/EDR. Then, I filled the last 20 bytes of the array with AltBeacon-specific data, as explained in the previous article.
[Figure 3 – Defining AltBeacon Data in Manufacturer-Specific Data Fields]
Next, I set the local name for the Beacon device, which will appear in the scan results. This is another type of broadcast data, so I added it separately. The local name was set to “AltBeacon.â€
[Figure 4 – Creating a local name for the scan response]
Finally, I configured the broadcast parameters by calling relevant Bluegiga functions and using the previously defined arrays.
[Figure 5 – Configuring GAP Broadcast]
With these steps completed, my custom AltBeacon based on the Bluegiga board is now ready.
[Figure 6 – AltBeacon on DKBLE]
Another option: AltBeacon on Intel Edison
Node.js is highly modular, offering a wide range of libraries. One such library is "Bleno," which provides Bluetooth Low Energy (BLE) peripheral functionality. It was created by Sandeep Mistry and is open source. While Bleno supports iBeacon out of the box, it doesn’t natively support AltBeacon. To address this, I modified the Bleno codebase to generate AltBeacon broadcasts.
I added new features to the `bleno.js` file and then started the broadcast based on predefined parameters. Here’s what the updated code looked like:
[Figure 7 – New features in bleno/lib/bleno.js]
This code fills a buffer with AltBeacon data and calls additional functions in the `linux/bindings.js` file. Bleno works with the BlueZ stack on Linux, and its functions are ultimately mapped to BlueZ API calls. I made changes to the Linux-related parts of Bleno to support AltBeacon.
[Figure 8 – New features in bleno/lib/linux/bindings.js]
[Figure 9 – New features in bleno/lib/linux/hci-ble.js]
These changes prepare a buffer containing all the necessary broadcast data and pass it through the Bleno API to the BlueZ Host Controller Interface (HCI).
Once Bleno was updated, creating an AltBeacon node.js application was straightforward. The entire application consists of just seven lines of code:
[Figure 10 – AltBeacon node.js application]
To run the app, I connected to the Intel Edison via SSH or Telnet using PuTTY and executed the command `node app.js`.
[Figure 11 – Putty establishes a terminal dialogue]
Pp-Pe Film Pelletizing Line,Pelletizing Line For Pp-Pe Film,Pp-Pe Film Recycling Machine, Film Granulator For Pp-Pe
Zhejiang IET Intelligent Equipment Manufacturing Co.,Ltd , https://www.ietmachinery.com