Firmware for the BGM111 is written using Silicon Labs’ proprietary scripting language BGScript. The firmware includes the GATT profile, the settings for the GPIO pins, methods to broadcast and connect via BLE, processing interrupts on the pins connected to the buttons, and sending and receiving data over BLE to the client cell phone.
The Silicon Labs development board has a few GPIO pins that I can used to get test basic connectivity and functionality. It plugs into your computer using USB and allows the device to use the UART to send serial communications to your computer, which is essential for debugging. There are a few LEDs and a few push buttons that we can use for further debugging. For the first phase, I designated one of the LED’s to turn on when the device initializes, and another LED to turn on and off when the client cell phone connects and disconnects.
The firmware will set up a GATT profile with a few different services. We will have a “Device Information Service” to broadcast the name and revision of the device, and we will have a custom service which contains characteristics for each button on the device. Each of these characteristics will have its own UUID, and will be set up so that it can provide indications/notifications to the client.
The firmware performs actions in reaction to events detected by the MCU. A summary of the program flow is highlighted below:
- Upon Boot
- Setup GPIO
- Setup BLE parameters and advertise device name
- Initialize global variables
- Turn on LED1
- Upon BLE connection opened
- Set BLE connection parameters, such as connection interval
- Turn on LED2
- Upon BLE Connection Closed
- Turn off LED2
- Begin advertising device name
- Upon GPIO Interrupt (ie, button click)
- Process which button was clicked Send gatt characteristic notification to client
Update 10/23: BGM111 firmware is now uploaded to Github
Summary of important files
- gatt.xml - gatt profile
- hardware.xml - GPIO initial setup
- kDrive.bgs - BGM111 firmware
- Pinout.xls - definition of GPIO pinout