Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us
 

Forward Logo (image)      

pfodParserMicroBit Library
for BBC micro:bit

by Matthew Ford 20th October 2016 (originally posted 20th October 2016)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

pfodParserMicroBit Library V1.0
(Protocol For Operations Discovery)
Library for BBC micro:bit

This page describes how to install the pfodParserMicroBit library for connecting BBC micro:bit to pfodApp. This library supplies the support files that when, combined with the pfodMenu class generated by pfodDesignerV2, will let you display menus on pfodApp and control your micro:bit.

pfodDesignerV2 V2.0.2211+ is needed to generate the code for the micro:bit.

An Arduino version of the pfodParser library is also available.

Installation, Configuration and Testing:

1) Follow the instructions on Offline Compiler Setup for BBC micro:bit to setup Netbeans and the Lancaster University micro:bit support.

2) Close Netbeans delete all the source files in pfodtest/source. Then download the pfodParserMicroBit.zip file and unzip pfodParserMicroBit into that pfodtest/source directory. In the top level pfodtest directory check that the config.json file here has at least these settings. They disable the unused bluetooth services and set the bluetooth security to OPEN. This simplifies initial testing of the setup. See below for how to enable BLE security.

3) Run Yotta again and cd to the pfodtest directory and run the following two commands
> yotta clean
> yotta build

4) Open Netbeans again are re-create the bbc-microbit_classic_gcc project as described in the Compilier Setup tutorial. (The yotta clean removed it.) When Netbeans finishes doing its full compile you can drag the pfodtest-combined.hex file to your micro:bit drive to download the program. (See Step 3 on https://www.microbit.co.uk/device/usb)

5) You micro:bit now has a small pfodMenu installed. To test it, install the pfodApp and create a connection to your micro:bit. With these config.json settings, there is no BLE security and you can just follow the instructions in pfodAppForAndroidGettingStarted.pdf for adding a BLE device.

6) Once the pfodApp connection is setup you should be able to connect to your BBC micro:bit device and see the following screen



That completes the installation, configuration and testing. You can now use pfodDesignerV2 to create your own menus and generate the necessary micro:bit code. pfodDesignerV2 will generate a file containing the pfodMenu.h and pfodMenu.cpp code. Replace the existing code in pfodMenu.h and pfodMenu.cpp with the new code from pfodDesignerV2 and recompile and downloaded to your micro:bit to install your new menu.

Connecting with BLE security Enabled

If BLE security is enabled, that is if the config.json contains “open”:0 ,

"microbit-dal": {
        "bluetooth": {
            "enabled": 1,
            "pairing_mode": 1,
            "private_addressing": 0,
            "open": 0,    <<<< NOT OPEN security
. 
        },

Then connecting is a two step process. First install Samsung micro:bit app and use that app's Connect option to connect your micro:bit to your Android mobile. Once you have done that you can then go back and setup a pfodApp connection for this micro:bit.

Library Reference:

pfodParser

Description
pfodParser for Arduino, Parses commands of the form {ver : cmd} or {ver : cmd ` arg1`arg2 ... } or {ver : cmd ~ arg1 ~ arg2 … }
The ver : and the args are optional.

This is a complete parser for ALL commands a pfodApp will send to a pfodDevice

Methods

Public Methods and Variables

Other variables are created by pfodDesignerV2 to access the data being sent to and from pfodApp, plot_1_var, cmd_A_var, etc

Utility Public Print Fns
These functions provide a minimal set of print capability for sending menus and responses. All of these methods send nothing if the pfodParser is not connected and block if there is not enough space in the outgoing buffer. The pfodParser_TXfree() can be used to check the available space in the TX buffer

int println(void)send \r\n to underlying TX buffer, does not send data if pfodParser is not connected.

int print(char c)sends a char c to the underlying TX buffer, does not send data if pfodParser is not connected.

int print(const char *str)send the string to the underlying TX buffer, does not send data if pfodParser is not connected.

int print(const long l)converts a long to a string and send it to the underlying TX buffer, does not send data if pfodParser is not connected.

int print(const float l)converts a float to a string and send it to the underlying TX buffer, does not send data if pfodParser is not connected.

Examples

Android Controlled C++ micro:bit contains a detailed tutorial on controlling your micro:bit from your Android mobile.



AndroidTM is a trademark of Google Inc, For use of the Arduino name see http://arduino.cc/en/Main/FAQ


pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2017 Forward Computing and Control Pty. Ltd. ACN 003 669 994