BLE example for the Edge?

Where can I find an example of using BLE on the Edge? I’ve read the Apollo3 docs, and I’ve used BLE on other devices, but an example for this specific platform would be very helpful.

I’d like to be able to make the Edge send HID Keyboard Report messages in response to voice commands.

Any help would be appreciated!

Check out these examples for the Apollo3 Evaluation Board. Since Bluetooth is all internal to the MCU (no multiplexed pins or anything) they should work out. I haven’t personally tried any of them however. Do you have all the info that you need to get running with the AmbiqSuite SDK (either Release 2.0.0 or 2.1.0)?

frogman:
I’d like to be able to make the Edge send HID Keyboard Report messages in response to voice commands.

So, how did you do?

I bought the Edge, and after very long hours, I got the drivers right and managed to play with the LEDs.

Now, I’m spending some more hours trying to get some bluetooth action going. I tried reading through the examples that liquid.soulder mentioned.

liquid.soulder:
Check out these examples for the Apollo3 Evaluation Board.

But I couldn’t figure out how to make my own bluetooth connection.

There are many examples, but all the code looks pretty much the same, and I couldn’t understand which parts are necessary boilerplate, and which parts are actually application specific.

I also tried skimming through the Apollo3 Blue Datasheet on BLE Module section, but found nothing truly helpful.

Now that I have nothing else to try, I’m thinking of creating a thread on this forum.

Could you share how’s your experience going?

Hi diblacksmith - just thought I would also mention that I have added a very basic BLE example to the Arduino core (v1.0.7). You can load up the example sketch from File->Examples->Artemis Examples->Example8_BLE_LED

You should be able to turn an LED on and off by writing to the ‘Immediate Alert’ characteristic with NRF Connect.

https://github.com/sparkfun/Arduino_Apollo3

Hi liquid.soulder! Thanks for the link!

It was somewhat helpful. I tried “porting” (translating?) the code you provided for use on the Edge board. I read the code, trying to identify the key parts that would get me going on the Edge.

I don’t know how well I did, because right now I’m stuck in linking the objects after compiling. I stitched the code all I thought was necessary, and at the last step, which is compiling and shipping to the board, I ran into “undefined reference” issues.

It’s mostly with key function calls somewhere within NusStart() [1], which is the function that starts the profile for the example:

...
...
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: bin/nus_api.o: in function `tagBtnCback':
/opt/AmbiqSuite-Rel2.2.0/boards/apollo3_evb/examples/area_privada_projeto/gcc/../src/nus_api.c:701: undefined reference to `FmplSendAlert'
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /opt/AmbiqSuite-Rel2.2.0/boards/apollo3_evb/examples/area_privada_projeto/gcc/../src/nus_api.c:706: undefined reference to `FmplSendAlert'
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: bin/nus_api.o: in function `tagDiscCback':
/opt/AmbiqSuite-Rel2.2.0/boards/apollo3_evb/examples/area_privada_projeto/gcc/../src/nus_api.c:861: undefined reference to `FmplIasDiscover'
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /opt/AmbiqSuite-Rel2.2.0/boards/apollo3_evb/examples/area_privada_projeto/gcc/../src/nus_api.c:884: undefined reference to `GattDiscover'
/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /opt/AmbiqSuite-Rel2.2.0/boards/apollo3_evb/examples/area_privada_projeto/gcc/../src/nus_api.c:889: undefined reference to `GapDiscover'
...
...

Note: the AmbiqSuite path is because I tried stitching the code you provided into one of the bluetooth examples from AmbiqSuite SDK, as a last resort. This way I could just use the pre-made Makefile and add whatever was missing as needed. Didn’t have any luck in the linking phase though.

Could this be some compiler flag that I’m missing? I don’t know what to try next.

Could you please help me? Or connect me with someone who can?

I was hoping to get through the basic functionalities (buttons, LEDs, bluetooth, etc) of the board before downloading my models to it.

Once I’ve succeeded, and since it’s been so hard, I’ll write some tutorials to help get through all this much easier.

If you can help me, let me know how I can give you more details of what I’m doing.

[1]: https://github.com/sparkfun/Arduino_Apo … in.c#L1158

Hmmm.

Yes I’d be happy to try and help. First of all I could use a little more explanation of what system you are using in total.

  1. Are you using the Arduino IDE? Or are you using the AmbiqSuite SDK directly? In either case how did you install it?

I’ve tried using a BLE example from the apollo3_evb board in the AmbiqSuite SDK directly and had mixed success. The ‘ble_cordio_tag’ example did not work (maybe hung up waiting for some kind of signal?) however if I recall correctly the ‘ble_freertos_fit’ example did work for me (Using release 2.0.0 and a BlackBoard Artemis)

How did you fare with the other features like LEDs and Buttons? I’d rank BLE as a far more advanced topic, so I hope that you did not have too much trouble with those first two.

Hello, I am interested in this forum. We are able to load and code onto the board but our problem lies in correctly calling the sequence of am_hal_ble functions. More specifically, we are able to call

Ble initialization

Ble Power Control

Ble config

ble_boot

with a sucess return value of 0 but I am not sure on how to send hci packets to a phone. We look at your RTOS example but we are not sure how to set up a handler that sends packages through the BLE, could we get some help. We are using the SDK and booting from bash using Ubuntu. Any help would be greatly appreciated. :slight_smile:

Our current recommendation for BLE examples is to use the ‘ble_freertos_tag’ example that is included in the [SparkFun_Apollo3_AmbiqSuite_BSPs repo. You may either use the BSPs individually with your custom toolchain or you could use our containerized development platform [artemis_dev_platform.

Currently those examples are our best understanding of how to operate the BLE radio. HCI is a standard interface between host microcontrollers and BLE radio modules - the Apollo3 has an integrated BLE radio module and the HCI transactions occur entirely within the chip. The packets that should be transferred over RF are BLE packets and may require several HCI packets to configure.](GitHub - sparkfun/artemis_dev_platform: Containerized development platform for Artemis / Apollo3)](GitHub - sparkfun/SparkFun_Apollo3_AmbiqSuite_BSPs: One-stop-shop for all your AmbiqSuite SDK board support package needs.)

The BLE_led is indicated is very basic. In case you want to look for Bluetooth examples that can do more build with the Arduino IDE:

Based on the BLE_LED I have created a server reads the battery level and internal temperature of the Apollo3 chip and provides that information over Bluetooth. It can be read with nRf app or with a client program written in C, tested on Ubuntu and raspberry PI ( needs Bluez)

Like others have done, porting the AMD transfer Protocol (AMDTP) from the SDK to the Arduino was not that difficult. BUT I have taken that a step further and created a user layer on top that. You can read from remote ADC channel, read digital or set digital pins, set the on-board led, provide internal Apollo3 chip temperature, provide battery level in percentage and simple chat. A client solution is written in C, tested on Ubuntu and Raspberry PI. It is build on Bluez (the Bluetooth Protocol tack for Linux), supports the AMDTP stack and a user level application to communicate with the server to request and exchange information.

Both can be found at : https://github.com/paulvha/apollo3

Awesome Paul! Thanks for sharing your work