setting BLE friendlyname

Wireless communications in Waspmote, topologies, node types...
Post Reply
marcelloioppolo
Posts: 22
Joined: Thu Jun 19, 2014 4:23 pm

setting BLE friendlyname

Post by marcelloioppolo » Mon Jun 23, 2014 3:08 pm

hi all,
im sorry to disturb you once more,but i cannot find in WaspBLE class the function to set the friendly name in a certain ble!i want to order them with progressive numbers that is 1,2,3,etc etc so that i can read the rssi correspondent to a certain device with the scanner ble.
how can i set the friendlyname in a certain ble?
thank you very much for your support.
best regards marcello ioppolo

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: setting BLE friendlyname

Post by libelium-dev » Mon Jun 23, 2014 4:46 pm

Hi marcelloioppolo,

The friendly name is stored in the General access profile, on characteristic 2A00 which is readable/writeable, as defined by the standard.

You should write this characteristic to name each module, using the writeLocalAttribute() function.

The handler of the name characteristic is 3. See full list below:
  • name 3
  • class 5
  • manufacturer 9
  • module 11
  • serial 13
  • software_rev 15
  • scan_interval_window 18
  • scan_refresh 21
  • alert_level 26
  • alert_level 29
  • us1_0 32
  • us1_1 35
  • us1_2 38
  • us1_3 41
  • us1_4 44
  • us1_5 48
  • us1_6 52
  • us1_7 56
  • us1_8 60
  • us1_9 63
  • us1_10 67
  • us1_11 71
  • us1_12 75
  • us1_13 79
  • us1_rx_data 82
  • us1_tx_data 85
  • us2_0 90
  • us2_1 93
  • us2_2 97
  • us2_3 101
For instance, in example BLE 11 you can see how a local attribute is changed.

regards

marcelloioppolo
Posts: 22
Joined: Thu Jun 19, 2014 4:23 pm

Re: setting BLE friendlyname

Post by marcelloioppolo » Tue Jun 24, 2014 11:03 am

hello everybody,

thanks for your prompt response.

im trying to set the friendlyname by putting into the setup code of the advertiser the command line:
BLE.writeLocalAttribute(3, 1,"1");
but the scanner cannot see "1" in the field friendlyname of the received string.
where am i mistaken?
thanks a lot for your support
marcello ioppolo

marcelloioppolo
Posts: 22
Joined: Thu Jun 19, 2014 4:23 pm

Re: setting BLE friendlyname

Post by marcelloioppolo » Tue Jun 24, 2014 11:08 am

i also tried the command line:
BLE.writeLocalAttribute(3, BLE_INDICATE_ENABLED,"1");
but the scanner cannot see the friendlyname as well.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: setting BLE friendlyname

Post by libelium-dev » Tue Jun 24, 2014 11:40 am

HI there. See below a dummy code which changes the name of the BLE device by writing the name attribute.
#include <WaspBLE.h>
uint8_t flag = 0;
void setup()
{
 
  // 0. Turn BLE module ON
  BLE.ON(SOCKET0);

  // 4.4.1 Write the local attribute (friendly name)
  flag = BLE.writeLocalAttribute(3, "Name");

  if (flag == 0)
  {
    USB.println("Attribute changed");
  }
  else
  {
    USB.printf("Error writing. flag = %u\r\n", flag);
  }

  // 1. Make Waspmote visible to other BLE modules
  BLE.setDiscoverableMode(BLE_GAP_GENERAL_DISCOVERABLE);

  // 2. Make Waspmote connectable to any other BLE device
  BLE.setConnectableMode(BLE_GAP_UNDIRECTED_CONNECTABLE);
  USB.println(F("Waiting for incoming connections..."));

}

void loop()
{
}
Scanning this node with the example BLE 02 you will be able to see the name of the device.
output wrote:Name scan for 5 seconds..
discovered devices: 1
Print Last inquiry saved on EEPROM
Scan params: GAP mode=2; scan_interval=75: scan_window=64; scan_duplicate_filtering=1; TXPower=15;
Device 0; 000780789eeb; RSSI:-40; Name:Name
let us know your progress

marcelloioppolo
Posts: 22
Joined: Thu Jun 19, 2014 4:23 pm

Re: setting BLE friendlyname

Post by marcelloioppolo » Tue Jun 24, 2014 1:39 pm

thanks a lot with this code i can read rssi and friendlyname associated.
i have a further question.
now i get rssi and friendly name after calling in sequence the functions scannetworkname() and printinquiry() (i disabled the saving in eeprom and it works as well).
is there a way to read directly the rssi and friendlyname of each device (at the moment i have a star topology with 5 advertisers and a single scanner) after scannetworkname() without using printinquiry()?
i think i can speed up the scanning process in this way,i need to collect the rssi as fast as possible in order to perform real time localization.
thanks a lot for all the support you are giving to me
marcello ioppolo

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: setting BLE friendlyname

Post by libelium-dev » Tue Jun 24, 2014 2:37 pm

marcelloioppolo,

you are welcome.

Regarding your question about how to obtain RSSI and name as fast as possible, you will need to go a bit deeper into WaspBLE API to understand how a scan is performed.

When you call a scan function, the scan command is sent, and then the function waits for scan events during the desired time.

When one of these events is received by the waitEvent() function, then the function parseScanEvent() is called to save the information. You can take a look inside this function to see which variables are involved and how the information is saved. You can modify this function to save only rssi and name and do only what you need and discard the rest of the data.

The structure of a scan event is also described in the .cpp file at line 354

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: setting BLE friendlyname

Post by arajakar » Thu Sep 27, 2018 10:20 am

It seems that this example code is not compatible with waspmote v15. Please explain why?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: setting BLE friendlyname

Post by libelium-dev » Fri Sep 28, 2018 8:41 am

Hi,

This topic is from 2014. There are a lot of changes in our libraries since 2014. Here you can see the example code for Waspmote v15 and the Bluetooth Low Energy Networking Guide
http://www.libelium.com/development/was ... low-energy
http://www.libelium.com/downloads/docum ... _guide.pdf

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest