BT Pro 04: Scan with friendly name

This example shows how to scan for bluetooth devices including friendly name of each device.

Required Materials

1 x Waspmote 1 x Battery 1 x Coin battery 1 x Bluetooth module Pro 1 x Bluetooth module antenna 1 x Expansion board (if socket 1 is used) 1 x SD card

Notes

- Socket 1 will be used to connect Bluetooth module (using expansion board) - Socket 0 can also be used, plugging module directly. - It is recommended to set RTC time to your actual time. - SD card must be inserted to allow saving discovered devices. - Never unplug module while Waspmote is turned ON. - Bluetooth module antenna should be connected. - The battery must be connected in ANY example. - This example can be executed in Waspmote v12 and Waspmote v15

Code

/*
 *  ------------------ [BT PRO_04] - Scan with friendly name ----------------- 
 *
 *  Explanation: This example shows how scan devices including friendly
 *  name of each device.
 *
 *  Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
 *  http://www.libelium.com
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see .
 *
 *  Version:		1.1
 *  Design:			David Gascón
 *  Implementation:	Javier Siscart
 */

#include "WaspBT_Pro.h"

void setup()
{

  USB.println(F("BT_PRO_04 Example"));

  // Turn On Bluetooth module
  BT_Pro.ON(SOCKET1);

}

void loop()
{

  // 1. Name scan
  USB.println(F("Scan 5sc."));
  BT_Pro.scanNetworkName(5,TX_POWER_6);
  USB.print(F("discovered: "));
  USB.println(BT_Pro.numberOfDevices, DEC);

  // 2. Prints results of last inquiry (only debug)
  BT_Pro.printInquiry();

}

Output

H#
BT_PRO_04 Example
Scan 5sc.
discovered: 6

9c:4a:7b:95:5a:30; 5a0204; -72; P;
00:1a:70:90:b3:28; 5a0000; -43; O;
00:1e:3d:a6:64:12; 3e0104; -88; O;
00:25:d3:b0:5f:2e; 4a010c; -80; O;
00:16:a4:03:76:54; 5a0100; -69; O;
00:07:80:4a:c6:50; 000000; -74; O;
Friendly names:
9c:4a:7b:95:5a:30 "Libelium Mobile"
00:1a:70:90:b3:28 "Libelium1"
00:1e:3d:a6:64:12 "Libelium3"
00:25:d3:b0:5f:2e "Libelium4"
00:16:a4:03:76:54 "Libelium2"
00:07:80:4a:c6:50 "MeshliumBT"
Total: 06

Last updated