Arduino 101 -Android BLE chat, need to store the ACSII into variable.

Hello, this was originally a sketch for Nordics BLE Arduino chip but slightly modified to the Arduino 101.

What i’m trying to figure out is how to store the transmitted text into a variable…I assume down in the while loop with the red text? Can anyone give me advice or tell me in plain english what to do here(No Need to write the code yourself).

Thanks in advance

/*
 *    Chat
 *
 *    Simple chat sketch, work with the BLEController iOS/Android App.
 *    Type something from the Arduino serial monitor to send
 *    to the BLEController App or vice verse.
 *    Characteristics received from App will print on Serial Monitor.
 */

// Import libraries (BLEPeripheral depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <CurieBle.h>
// define pins (varies per shield/board)


/*----- BLE Utility -------------------------------------------------------------------------*/
// create peripheral instance, see pinouts above
BLEPeripheral            blePeripheral;

// create service
BLEService               uartService          = BLEService("713d0000503e4c75ba943148f18d941e");

// create characteristic
BLECharacteristic    txCharacteristic = BLECharacteristic("713d0002503e4c75ba943148f18d941e", BLENotify, 20);
BLECharacteristic    rxCharacteristic = BLECharacteristic("713d0003503e4c75ba943148f18d941e", BLEWriteWithoutResponse, 20);
/*--------------------------------------------------------------------------------------------*/

void setup()
{
  delay(5000);
  Serial.begin(115200);
  Serial.print(F("Hello "));


/*----- BLE Utility ---------------------------------------------*/
  // set advertised local name and service UUID
  blePeripheral.setLocalName("ble-Micro");
  blePeripheral.setAdvertisedServiceUuid(uartService.uuid());

  // add service and characteristic
  blePeripheral.addAttribute(uartService);
  blePeripheral.addAttribute(rxCharacteristic);
  blePeripheral.addAttribute(txCharacteristic);

  // begin initialization
  blePeripheral.begin();
/*---------------------------------------------------------------*/

  Serial.println(F("BLE UART Peripheral"));
}

unsigned char buf[16] = {0};
unsigned char len = 0;

void loop()
{
  BLECentral central = blePeripheral.central();
  Serial.println("Check if Working...");
  if (central)
  {
    // central connected to peripheral
    Serial.print(F("Connected to central: "));
    Serial.println(central.address());

    while (central.connected())
    {
      // central still connected to peripheral
      if (rxCharacteristic.written())
      {
        unsigned char len = rxCharacteristic.valueLength();
        const unsigned char *val = rxCharacteristic.value();
        Serial.println(len,DEC);
        

       // Serial.print("didCharacteristicWritten, Length: ");
       // Serial.println(len, DEC);
        unsigned char i = 0;

        while(i<len)
        {
[b]          Serial.write(val[i++]);
                       / CODE ENTERED HERE? /
[/b]        }
      }

      if ( Serial.available() )
      {
        delay(5);
        unsigned char len = 0;
        len = Serial.available();
        char val[len];
        Serial.readBytes(val, len);
        txCharacteristic.setValue((const unsigned char *)val, len);
      }
    }

    // central disconnected
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}

I guess, to shorten it down, the important part for me is here:

      if (rxCharacteristic.written())
      {
        unsigned char len = rxCharacteristic.valueLength();
        const unsigned char *val = rxCharacteristic.value();
        Serial.println(len,DEC);
        

       // Serial.print("didCharacteristicWritten, Length: ");
       // Serial.println(len, DEC);
        unsigned char i = 0;

        while(i<len)
        {
          Serial.write(val[i++]);
          
        }

Instead of Serial.write(val[i++])

I would like to read each character into a variable

Hello again.

        while(i<len)
        {
          
          Serial.write(val[i++]);
          const unsigned char inByte1 =   char(Serial.read());
          delay (500);
          Serial.println(inByte1);

Output is

h255
e255
l255
l255
o255

Can anyone assist? Why won't it convert to char? Why 255?
fyi: I'm sending 'hello' from android device. Which is written via serial.write() to the console