Go Down

Topic: CurieBLE and phone terminal connection (Read 1 time) previous topic - next topic

etairl

Hello,

I'm trying to achieve a very task:
Read a string via BLE, write it to the Serial connection (my pc in this example), and then write a new string ("TEST") to BLE.

I'm using my phone's BLE via terminal apps to achieve it (Serial Bluetooth & BleTerm). The issue is that unlike other devices, the Write & Read characteristics are not set by default, so in order to create a terminal connection, I'm asked to either pick one, or write it manually.

Screenshot from my phone:


How can I set these characteristics by default like other BLE devices are behaving?

My Code:
Code: [Select]

/*
 * Copyright (c) 2016 Intel Corporation.  All rights reserved.
 * See the bottom of this file for the license terms.
 */

#include <CurieBLE.h>

//----------------------------------------------------------- BLE declaring
BLEPeripheral blePeripheral; 
BLEService InitAdmin("41300000-EB90-09D7-0001-413031360000");     
BLECharacteristic ATTOBLE("41300001-EB90-09D7-0001-413031360000", BLERead | BLEWrite | BLENotify,16);

//---------------------------------------------------------------------- Global Variables
char BLEString[32] ;

//----------------------------------------------------------------- Initialisation

void setup()
{
  Serial.begin(9600);
 
  // Set advertised local name and service UUID:
  blePeripheral.setLocalName("ATTO BLE");

  // Add Service & Caracteristic
  blePeripheral.addAttribute(InitAdmin);
  blePeripheral.addAttribute(ATTOBLE);

  // BLE Events
  ATTOBLE.setEventHandler(BLEWritten, switchCharacteristicWritten);

  // begin advertising BLE service:
  blePeripheral.begin();
}

void loop()
{
  blePeripheral.poll();
}

void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
  sprintf(BLEString,"%16c",NULL);
  strncpy(BLEString,(char*)ATTOBLE.value(),ATTOBLE.valueLength());
  Serial.println(BLEString);
 
  ATTOBLE.setValue("TEST");
}


Minicarpet

Hi,
I don't understand what is wrong.
Your characteristic got these atteibutes Write | Read | Notify.
Then you should succesfully read and write value. And at least see your service and characteristic.
Arduino UNO R3, ESPLORA, Due, Zero Pro
Robot Arduino
Arduino Standalone

Go Up