• Enter email to sit in the first row

Ten lines BBMagic application


This project contains

  • ‘bbmagic_10_lines_app.c’ file – main app c file.
  • ‘bbmagic_lib.h’ file – all bbmagic_lib functions declarations. You can dive into it to discover BBMagic modules functionality.
  • ‘Makefile’ – compilation instructions. Thanks for this file you can write ‘make’ and all compilation is automatically done.
  • ‘libs’ directory – contains precompiled libraries.
  • ‘tools’ directory – contains tools like bbm_scanner_2.

The shortest BBMagic app

#include <stdlib.h>
#include "bbmagic_lib.h"
int main(void)
{
    unsigned char bbm_buf[100] ;
    int i, bbm_id ;
    i = bbm_bt_open(0, 0, 0, LIB_SHOW_CONFIG | LIB_SHOW_SENSORS | LIB_SHOW_ACTORS) ;
    if(i) exit(1) ;
    do
    {
        bbm_id = bbm_bt_read(bbm_buf) ;
        bbm_sleep_ms(100) ;
    }while(bbm_id != -1) ;
    bbm_bt_close() ;
    exit(0) ;
}

bbm_buf[100]
Its buffer for data received from BBMagic sensors and actors.

bbm_bt_open(0, 0, 0, LIB_SHOW_CONFIG | LIB_SHOW_SENSORS | LIB_SHOW_ACTORS)
It opens BBMagic Bluetooth Smart communication. For more see ‘bbmagic_lib.h’ file.

bbm_bt_read(bbm_buf)
bbmagic_lib_2 library function for reading modules data. For more see ‘bbmagic_lib.h’ file.

bbm_sleep_ms(100)
It stops main application loop for 100 miliseconds. In BBMagic apps you must not use usleep(), sleep(), etc.

bbm_bt_close()
Closes BBMagic Bluetooth Smart communication.

Do It Yourself

Get shell script:

wget www.bbmagic.net/download/get_BBMagic_10_line_app.sh

Change permision:

chmod +x get_BBMagic_10_line_app.sh

Run it:

./get_BBMagic_10_line_app.sh

getting BBMagic 10 lines app
Go to project directory:

cd bbmagic_10_lines_app

Run application:

sudo ./bbmagic_10_lines_app

run BBMagic 10 lines app

Is this really 10 lines app?

Check it out 🙂

#include <stdlib.h>
#include "bbmagic_lib.h"
int main(void){
    unsigned char bbm_buf[100] ; int bbm_id ;
    if(bbm_bt_open(0, 0, 0, LIB_SHOW_CONFIG | LIB_SHOW_SENSORS | LIB_SHOW_ACTORS)) exit(1) ;
    do{
        bbm_id = bbm_bt_read(bbm_buf) ; bbm_sleep_ms(100) ;
    }while(bbm_id != -1) ;
    bbm_bt_close() ; exit(0) ;
}
Tagged , . Bookmark the permalink.

Comments are closed.