'Cant't send a data from my cell phone(android) to HM10

I am using HM10(Bluetooth module) and the NUCLEO board. I am trying to send data (like A, B... just characters) from my android phone using "Serial Bluetooth terminal" app. I succeeded in connecting the phone and HM10, but data is not sent to HM10. I never know what is problem. Plz, give me some advice.

#include "mbed.h"
// set up the HM10 Serial connection
BufferedSerial hm10(D10,D2,9600); //TX, RX
BufferedSerial pc(CONSOLE_TX,CONSOLE_RX,9600);
DigitalOut led1(D3);
DigitalOut led2(D4);

char buf[80];

int main(){
    sprintf(buf,"\r\nHello New Serial Function in mbed-os v.%.1f\r\n",6.0);
    pc.write(buf, strlen(buf));

while(true) {
    sprintf(buf,"waiting for data");
    pc.write(buf, strlen(buf));
    int num = hm10.read(buf,sizeof(buf));
    led1=!led1; // for debugging
    pc.write(buf,num);
    //memset(buf,0,sizeof(buf));
}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source