Problems with BLE 4.0

I have a project that ask me to use bluetooth 4.0 to send data from an Arduino UNO.
however, when i was trying out the examples that the bluetooth chip producer provided, some problems occured.
I cannot pair the bluetooth module to other 4.0 devices such as iPad, android phone nor windows PC. it can be found when using APP to search device, but can’t build up a serial port between device and the board.
using BLE shield and ZBmodule chip on a Arduino UNO R3. since a shield board is used, I’m pretty sure the pins are connected correctly, so the problem is most like to stem from the controlling code.

ZBmodule: http://www.lillyelectronics.com/download/BLE4.0_module_datasheet.pdf
BLE shield: http://learn.linksprite.com/arduino/shields/bluetooth-4-0-shield-for-arduino/

Plus, i can’t find the mentioned app in the example in appstore, so i tried to connect with several bluetooth terminal apps, non of them worked to pair with the chip…

running example code as follow:

#if defined(ARDUINO) && ARDUINO >= 100
#  include <Arduino.h>
#else
#  include <WProgram.h>
#endif
#include <Wire.h>
#include <Servo.h> 


//#define SOFTUART 1



#define BaudRate 9600


#if defined SOFTUART
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
#endif

Servo servos[6];
uint8_t myservoPin[6]={3,5,6,9,10,11};

String parameter[10];
int arg[10];
volatile uint8_t state=0;
volatile int paraIndex=-1;

uint8_t readData[20];
uint8_t readIndex=0;

unsigned long time;

/************************************************
    Clear the serial receive data
/************************************************/
void clearbuff() {
	int i;
	for(i=0;i<8;i++){
		parameter[i] ="";
		arg[i]=0;
	}
	paraIndex=-1;
	state=0;
}


/************************************************
	ASCII characters into int
/************************************************/
void convert(){
	int i;
	for(i=1;i<=paraIndex;i++){
		char temp_char[parameter[i].length() + 1];
		parameter[i].toCharArray(temp_char, sizeof(temp_char));
		arg[i-1] = (uint8_t)(atoi(temp_char));
	}
}


/************************************************
      Servo  Control
/***********************************************/
void servoCtrl(uint8_t channer, uint8_t value){
	if(channer>6) return;
	uint8_t pin=channer+1;
#if defined SOFTUART
	mySerial.print("ServoControl:");
	mySerial.print(",");
	mySerial.print(pin);
	mySerial.print(",");
	mySerial.println(value);
#endif
	if(!servos[channer-1].attached())
		servos[channer-1].attach(pin);
	servos[channer-1].write(value);
	delay(10);
}

/************************************************
      Arduino  setup
/***********************************************/
void setup()  
{
	Wire.begin();	
	Serial.begin(BaudRate);

#if defined SOFTUART
	mySerial.begin(BaudRate);
	mySerial.println("Hello");
#endif
}


/************************************************
      Arduino loop
/***********************************************/
void loop() {
	if(state==1){
		convert();
#if defined SOFTUART
                mySerial.print("state:");
		mySerial.print(parameter[0]);
		mySerial.print(",");
		mySerial.print(parameter[1]);
		mySerial.print(",");
		mySerial.println(parameter[2]);
#endif
		if (parameter[0]=="OFF"){	// Leave ctro
			for(readIndex=0;readIndex<20;readIndex++)
				readData[readIndex]=0;
		} 
		
		if (parameter[0]=="PW"){	// PWM
			if(servos[arg[0]-2].attached())  servos[arg[0]-2].detach();
			pinMode(arg[0], OUTPUT); 
			analogWrite(arg[0], arg[1]);
		}
		
		if (parameter[0]=="SE"){	// Servo
			servoCtrl(arg[0], arg[1]);
		}
		
		if (parameter[0]=="DL"){	// Dimmer
			
		}
		
		if (parameter[0]=="AD"){	// ADC
			float tmp =analogRead(arg[0])*0.0048;
			Serial.print("@AD,");
			Serial.print(arg[0]);
			Serial.print(",");
			Serial.print(tmp);
			Serial.print("\r\n");
			readData[arg[0]+14]=arg[1];
		}
		
		if (parameter[0]=="OP"){	// OUTPUT
			if(servos[arg[0]-2].attached())  servos[arg[0]-2].detach();
			pinMode(arg[0], OUTPUT); 
			digitalWrite(arg[0], arg[1]);
			readData[arg[0]]=0;
		}
		
		if (parameter[0]=="IP"){	// INPUT
			if(servos[arg[0]-2].attached())  servos[arg[0]-2].detach();
			if(arg[1]==1){
				pinMode(arg[0], INPUT); 				
			}else{
				pinMode(arg[0], OUTPUT); 				
			}
			readData[arg[0]]=arg[1];
		}

		
        clearbuff();
        // ouput data
	}else if(millis()-time>60){  
	
		time = millis();
		
		int tmp;
		float adVar;
		
		while(readData[readIndex]!=1){
			readIndex++;
			if(readIndex>19){
				readIndex=0;
				break;
			}
		}
#if defined SOFTUART
//		mySerial.print("readData:");
//		mySerial.println(readIndex);
#endif
		if(readData[readIndex]==1){
			if(readIndex<14){	//PIN INPUT 
				pinMode(readIndex, INPUT); 
				tmp =digitalRead(readIndex);
				Serial.print("@IP,");
				Serial.print(readIndex);
				Serial.print(",");
				Serial.print(tmp);
				Serial.print("\r\n");
				
#if defined SOFTUART
				mySerial.print("@IP,");
				mySerial.print(readIndex);
				mySerial.print(",");
				
				mySerial.println(tmp);
				mySerial.print("\r\n");
#endif
			}else{	// ADC
				tmp =readIndex-14;
				adVar =analogRead(tmp)*0.0049;
				Serial.print("@AD,");
				Serial.print(tmp);
				Serial.print(",");
				Serial.print(adVar);
				Serial.print("\r\n");
			}
			readIndex++;
			if(readIndex>19) readIndex=0;
		}
	}
    
	
}



/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent() {
	while (Serial.available()) {
                
		char inChar = (char)Serial.read(); 
                if(state==1) return;
		switch(inChar){
			case'@':
				clearbuff();
				paraIndex=0;
			break;
			case',':
				paraIndex++;
			break;
			case '\n':	//0x0A
				state=1;
				return;
			break;
			case '\r':	//0x0D
				state=1;
				return;
			break;
			default: 
				if(paraIndex>=0&&state==0) parameter[paraIndex] +=inChar;
			break;
		}
	}
}

If you can, stay away from iPhone and PC, unless the latter is a laptop with a clearly defined bluetooth procedure.

Your problems may be nothing more than procedural, not helped by somebody making it harder than it should be.

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

but this assumes you can connect bluetooth to Uno's hardware serial ports D0,D1. Note the brevity of the code

Great thanks, I'll try it out soon, hope this is really just a procedural problem.