Problems with bluetooth disconnecting after sending one command.

Hello, I’m using the BLE shield 2.1 from readbear and every time i use an app to send a command via bluetooth the arduino recieves and executes it but then instantly disconnects. Wondering if anyone might know that the problem is. (using the app iShield with an iphone 7)
Here is the code:

#include <SPI.h>
#include <boards.h>
#include <RBL_nRF8001.h>
#include <EEPROM.h>

#define DIR_A 12
#define BRAKE_A 9
#define PWM_A 3
#define DIR_B 13
#define BRAKE_B 8
#define PWM_B 11

void setup() {
pinMode(DIR_A, OUTPUT);
pinMode(DIR_B,OUTPUT);
pinMode(BRAKE_A,OUTPUT);
pinMode(BRAKE_B,OUTPUT);
pinMode(BRAKE_A,HIGH);
pinMode(BRAKE_B,HIGH);
Serial.begin(9600);
ble_begin();
ble_set_name(“ble_led”);

Serial.println(“ble_begin done!”);

}

void loop() {
if(ble_available()){
Serial.println(“funkar så långt”);
int cmd=0;
cmd=ble_read();
Serial.println(cmd);
Serial.println(“Nästa steg?”);

if(cmd==1){
Serial.println(“kom hit”);
fram();
ble_do_events();
}
if(cmd==2){
bak();
ble_do_events();
}
if(cmd==3){
H();
ble_do_events();
}
if(cmd==4){
V();
ble_do_events();
}
if(cmd==5){
digitalWrite(BRAKE_A,HIGH);
digitalWrite(BRAKE_B,HIGH);
analogWrite(PWM_A,0);
analogWrite(PWM_B,0);
ble_do_events();
}

}
ble_do_events();
}

void fram(){
digitalWrite(BRAKE_A,LOW);
digitalWrite(BRAKE_B,LOW);
digitalWrite(DIR_A,HIGH);
digitalWrite(DIR_B,HIGH);
analogWrite(PWM_A,255);
analogWrite(PWM_B,255);
Serial.println(“Kom hela vägen”);
}
void bak(){
analogWrite(BRAKE_A,LOW);
analogWrite(BRAKE_B,LOW);
analogWrite(PWM_A,255);
analogWrite(PWM_B,255);
digitalWrite(DIR_A,LOW);
digitalWrite(DIR_B,HIGH);
}

void V(){
digitalWrite(DIR_A,HIGH);
digitalWrite(DIR_B,LOW);
analogWrite(PWM_A,0);
analogWrite(PWM_B,255);
}

void H(){
digitalWrite(DIR_A,HIGH);
digitalWrite(DIR_B,LOW);
analogWrite(PWM_A,255);
analogWrite(PWM_B,0);
}

Should add that I've got an Arduino Motorshield ontop of the BLE shield

macbook1:
Should add that I’ve got an Arduino Motorshield ontop of the BLE shield

What you should add is links to the hardware (motor shield and BLE shield) and links to the non-core libraries you are using. What I’m looking for are pin conflicts, for starters.