Arduino101 BLE how to sending data

Hello Arduino~
I try to use BLE to send data from arduino101 to another
so I refer to the heart rate monitor sample code

My code looks like this

#include <CurieBLE.h>


BLEPeripheral blePeripheral;         // BLE Peripheral Device (the board you're programming)
BLEService heartRateService("180D"); // BLE Heart Rate Service

// BLE Heart Rate Measurement Characteristic"
BLECharacteristic heartRateChar("2A37",  // standard 16-bit characteristic UUID
    BLERead | BLENotify, 2);  // remote clients will be able to get notifications if this characteristic changes
                              // the characteristic is 2 bytes long as the first field needs to be "Flags" as per BLE specifications
                              // https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml
int heartRate = 0;
int oldHeartRate = 0;  // last heart rate reading from analog input
long previousMillis = 0;  // last time the heart rate was checked, in ms


int PIN = 3;  // 3번핀은 오른쪽과 동시에 되므로 오른쪽 키를 사용하지 말
int PIN_BUTTON_UP = 2;
int PIN_BUTTON_LEFT = 5;
int PIN_ANALOG_X = 0;
int PIN_ANALOG_Y = 1;
int button[] = {2,5};

int *pX;
int *pY;


void setup() {
  Serial.begin(9600);    // initialize serial communication
  pinMode(13, OUTPUT);   // initialize the LED on pin 13 to indicate when a central is connected

  /* Set a local name for the BLE device
     This name will appear in advertising packets
     and can be used by remote devices to identify this BLE device
     The name can be changed but maybe be truncated based on space left in advertisement packet */
  blePeripheral.setLocalName("Controller");
  blePeripheral.setAdvertisedServiceUuid(heartRateService.uuid());  // add the service UUID
  blePeripheral.addAttribute(heartRateService);   // Add the BLE Heart Rate service
  blePeripheral.addAttribute(heartRateChar); // add the Heart Rate Measurement characteristic

  /* Now activate the BLE device.  It will start continuously transmitting BLE
     advertising packets and will be visible to remote BLE central devices
     until it receives a new connection */
  blePeripheral.begin();
  Serial.println("Bluetooth device active, waiting for connections...");

  for(int i = 0; i < 2; i++){pinMode(button[i], INPUT_PULLUP);}
}

void loop() {
  // listen for BLE peripherals to connect:

  int UP = digitalRead(PIN_BUTTON_UP);
  int LEFT = digitalRead(PIN_BUTTON_LEFT);
  int X = analogRead(PIN_ANALOG_X);
  int Y = analogRead(PIN_ANALOG_Y);

  pX = &X;
  pY = &Y;
  
  
  BLECentral central = blePeripheral.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());
    // turn on the LED to indicate the connection:
    digitalWrite(13, HIGH);

    // check the heart rate measurement every 200ms
    // as long as the central is still connected:
    while (central.connected()) {
      long currentMillis = millis();
      // if 200ms have passed, check the heart rate measurement:
      if (currentMillis - previousMillis >= 200) {
        previousMillis = currentMillis;
        updateHeartRate();
      }
    }
    // when the central disconnects, turn off the LED:
    digitalWrite(13, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}

void updateHeartRate() {
    heartRate = controller(*pX,*pY);
    if(heartRate != oldHeartRate) 
    {      // if the heart rate has changed
      Serial.print("Heart Rate is now: "); // print it
      Serial.println(heartRate);
      const unsigned char heartRateCharArray[2] = { 0, (char)heartRate };
      heartRateChar.setValue(heartRateCharArray, 2);  // and update the heart rate measurement characteristic
    oldHeartRate = heartRate;           // save the level for next comparison
    }
}

int controller(int X, int Y)
  {
    if(0 <= X && X < 134 && 583 <= Y && Y < 1025){heartRate = 10;}         // FL30
    else if(134 <= X && X < 198 && 583 <= Y && Y < 1025){heartRate = 11;}  // FL25
    else if(198 <= X && X < 262 && 583 <= Y && Y < 1025){heartRate = 12;}  // FL20
    else if(262 <= X && X < 326 && 583 <= Y && Y < 1025){heartRate = 13;}  // FL15 
    else if(326 <= X && X < 390 && 583 <= Y && Y < 1025){heartRate = 14;}  // FL10
    else if(390 <= X && X < 454 && 583 <= Y && Y < 1025){heartRate = 15;}  // FL05
    else if(454 <= X && X < 554 && 583 <= Y && Y < 1025){heartRate = 16;}  // FS00
    else if(554 <= X && X < 632 && 583 <= Y && Y < 1025){heartRate = 17;}  // FR05
    else if(632 <= X && X < 710 && 583 <= Y && Y < 1025){heartRate = 18;}  // FR10
    else if(710 <= X && X < 788 && 583 <= Y && Y < 1025){heartRate = 19;}  // FR15
    else if(788 <= X && X < 866 && 583 <= Y && Y < 1025){heartRate = 20;}  // FR20
    else if(866 <= X && X < 944 && 583 <= Y && Y < 1025){heartRate = 21;}  // FR25
    else if(944 <= X && X < 1025 && 583 <= Y && Y < 1025){heartRate = 22;} // FR30
  
  
    else if(0 <= X && X < 134 && 473 <= Y && Y < 583){heartRate = 23;}     // HL30
    else if(134 <= X && X < 198 && 473 <= Y && Y < 583){heartRate = 24;}   // HL25
    else if(198 <= X && X < 262 && 473 <= Y && Y < 583){heartRate = 25;}   // HL20
    else if(262 <= X && X < 326 && 473 <= Y && Y < 583){heartRate = 26;}   // HL15
    else if(326 <= X && X < 390 && 473 <= Y && Y < 583){heartRate = 27;}   // HL10
    else if(390 <= X && X < 454 && 473 <= Y && Y < 583){heartRate = 28;}   // HL05
    else if(454 <= X && X < 554 && 473 <= Y && Y < 583){heartRate = 29;}   // HS00
    else if(554 <= X && X < 632 && 473 <= Y && Y < 583){heartRate = 30;}   // HR05
    else if(632 <= X && X < 710 && 473 <= Y && Y < 583){heartRate = 31;}   // HR10
    else if(710 <= X && X < 788 && 473 <= Y && Y < 583){heartRate = 32;}   // HR15
    else if(788 <= X && X < 866 && 473 <= Y && Y < 583){heartRate = 33;}   // HR20
    else if(866 <= X && X < 944 && 473 <= Y && Y < 583){heartRate = 34;}   // HR25
    else if(944 <= X && X < 1025 && 473 <= Y && Y < 583){heartRate = 35;}  // HR30
  
    else if(0 <= X && X < 134 && 0 <= Y && Y < 473){heartRate = 36;}       // BL30
    else if(134 <= X && X < 198 && 0 <= Y && Y < 473){heartRate = 37;}     // BL25
    else if(198 <= X && X < 262 && 0 <= Y && Y < 473){heartRate = 38;}     // BL20
    else if(262 <= X && X < 326 && 0 <= Y && Y < 473){heartRate = 39;}     // BL15
    else if(326 <= X && X < 390 && 0 <= Y && Y < 473){heartRate = 40;}     // BL10
    else if(390 <= X && X < 454 && 0 <= Y && Y < 473){heartRate = 41;}     // BL05
    else if(454 <= X && X < 554 && 0 <= Y && Y < 473){heartRate = 42;}     // BS00
    else if(554 <= X && X < 632 && 0 <= Y && Y < 473){heartRate = 43;}     // BR05
    else if(632 <= X && X < 710 && 0 <= Y && Y < 473){heartRate = 44;}     // BR10
    else if(710 <= X && X < 788 && 0 <= Y && Y < 473){heartRate = 45;}     // BR15
    else if(788 <= X && X < 866 && 0 <= Y && Y < 473){heartRate = 46;}     // BR20
    else if(866 <= X && X < 944 && 0 <= Y && Y < 473){heartRate = 47;}     // BR25
    else if(944 <= X && X < 1025 && 0 <= Y && Y < 473){heartRate= 48;}     // BR30

    return heartRate;
  }

well My code is not very well made code
full of errors, but it compiled anyway
I use joystick shield and read the data from that
and send specific data to another via BLE

return to the topic
when I upload this and connect to android nRF toolbox applications
nothing shows in graph

why this happens?
because this service just read analog sample?
If I want to send data like this which service is fit to me?

please help me :o

full of errors, but it compiled anyway

I haven't looked through your code for specific problems, but if your code compiled with a lot of warnings, than that's a sign that your program may not behave in the way you're expecting :slight_smile:

Fixing those warnings might go a long way for you!