problem BLE sening message

Wireless communications in Waspmote, topologies, node types...
Post Reply
Mateusz Jozwik
Posts: 1
Joined: Mon Jul 09, 2018 12:43 pm
Company: WAT

problem BLE sening message

Post by Mateusz Jozwik » Tue Jul 10, 2018 9:31 am

Hi !

I'm trying to send BLE message from slave to master. I tried to find a solution or at least some advice on WWW but didn't find anything useful.

FROM SLAVE

Code: Select all


#include <WaspBLE.h>

// Variable to store function returning values
uint8_t flag = 0;
uint8_t aux = 1;

void setup() 
{
  USB.println(F("BLE_08 Example"));  

  // 0. Turn BLE module ON
  BLE.ON(SOCKET0);

  aux = BLE.reset();
   
  if(aux == 1 )
  
  {
    // reset event found.
    USB.println("Module has been reset");  
  }
  else 
  {
    USB.println("Reset failed");  
  }

  delay(50);

   // 2. Print MAC address
  USB.print("BLE MAC is: ");
  USB.println(BLE.getOwnMac());

}

void loop() 
{
  // 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..."));

    flag = BLE.waitEvent(30000);
  if (flag == BLE_EVENT_CONNECTION_STATUS)
  {
    USB.println(F("Connected!"));
    USB.println(F("Now Waspmote is connected as slave.")); 

  }
}
       

Response

Code: Select all

H#
BLE_08 Example
Module has been reset
BLE MAC is: 000780DEDB2D
Waiting for incoming connections...
Connected!
Now Waspmote is connected as slave.
Waiting for incoming connections...

FROM MASTER

Code: Select all

#include <WaspBLE.h>

char attributeData[20] = "czesc"; 
uint8_t aux = 1;

char MAC[14] = "000780DEDB2D";

void setup()
{

// Turn BLE module ON
  
  BLE.ON(SOCKET0);
  
// BLE reset

  aux = BLE.reset();
  if(aux == 1 )
  {
 
 // reset event found.
    USB.println("Module has been reset");  
  }
  else 
  {
    USB.println("Reset failed");  
  }
  
  delay(50);

   //Print MAC address
   
  USB.print("BLE MAC is: ");
  USB.println(BLE.getOwnMac()); 
}

void loop()

{
  if(BLE.connectDirect(MAC) == 1)
{
  USB.print("Status");
 USB.println(BLE.getStatus(BLE.connection_handle),DEC); 
  USB.println();
 // read an attribute
BLE.attributeRead(BLE.connection_handle,  32);  // save the read attribute
  USB.print(F("Attribute Value (ASCII): "));
      for(uint8_t i = 0; i < BLE.attributeValue[0]; i++)
      {
        USB.print(BLE.attributeValue[i+1]);        
      }
      USB.println();
 /*write an attribute
 if (BLE.attributeWrite(BLE.connection_handle,  32, attributeData) == 0)
    {
    USB.println(F("Write OK."));
 } */  
} 

}

RESPONSE

Code: Select all

H#
Module has been reset
BLE MAC is: 000780DEDB1D
Status1

Attribute Value (ASCII): 0
Status1


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

Re: problem BLE sening message

Post by libelium-dev » Tue Jul 10, 2018 2:16 pm

Hello,

You can try with examples from Waspmote IDE, section BLE, examples BLE_10 to BLE_13.

You can find more information about BLA module: http://www.libelium.com/downloads/docum ... _guide.pdf

Regards,

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest