standalone/blueRadiosCmd.js
function blueRadiosAT(command){
	if (! wsclient.listeners('notification').length) {
		console.log('subscribe to RX notification');
		//listen for notification response
		wsclient.on('notification', function(peripheralId, serviceUuid, characteristicUuid, data) {
	//		console.log("NOTIFICATION: " + data.toString('hex') + ' : ' + data.toString('ascii').yellow);
			console.log(data.toString('ascii').trim().yellow);
		});		
	}

	//convert command to hex, add CR (0x0d = \r) at the end
	var hexCommand = new Buffer(command + '\r','ascii');

	wsclient.notify(peripheralId, blueRadiosService,blueRadiosRxCharacteristic,true, function() {
		wsclient.write(peripheralId, blueRadiosService,blueRadiosCmdCharacteristic, new Buffer('02','hex'), false, function(error) {
			console.log('Switch to CMD mode');
			wsclient.write(peripheralId, blueRadiosService, blueRadiosTxCharacteristic, hexCommand, false, function(){
				console.log('sent CMD: ' + command.cyan);
			})
		})
	});
}
function blueRadiosAT(command){
	if (! wsclient.listeners('notification').length) {
		console.log('subscribe to RX notification');
		//listen for notification response
		wsclient.on('notification', function(peripheralId, serviceUuid, characteristicUuid, data) {
	//		console.log("NOTIFICATION: " + data.toString('hex') + ' : ' + data.toString('ascii').yellow);
			console.log(data.toString('ascii').trim().yellow);
		});		
	}

	//convert command to hex, add CR (0x0d = \r) at the end
	var hexCommand = new Buffer(command + '\r','ascii');

	wsclient.notify(peripheralId, blueRadiosService,blueRadiosRxCharacteristic,true, function() {
		wsclient.write(peripheralId, blueRadiosService,blueRadiosCmdCharacteristic, new Buffer('02','hex'), false, function(error) {
			console.log('Switch to CMD mode');
			wsclient.write(peripheralId, blueRadiosService, blueRadiosTxCharacteristic, hexCommand, false, function(){
				console.log('sent CMD: ' + command.cyan);
			})
		})
	});
}
function blueRadiosAT ( command ) { if ( ! wsclient . listeners ( 'notification' ) . length ) { console . log ( 'subscribe to RX notification' ) ; //listen for notification response wsclient . on ( 'notification' , function ( peripheralId , serviceUuid , characteristicUuid , data ) { //		console.log("NOTIFICATION: " + data.toString('hex') + ' : ' + data.toString('ascii').yellow); console . log ( data . toString ( 'ascii' ) . trim ( ) . yellow ) ; } ) ; } //convert command to hex, add CR (0x0d = \r) at the end var hexCommand = new Buffer ( command + '\r' , 'ascii' ) ; wsclient . notify ( peripheralId , blueRadiosService , blueRadiosRxCharacteristic , true , function ( ) { wsclient . write ( peripheralId , blueRadiosService , blueRadiosCmdCharacteristic , new Buffer ( '02' , 'hex' ) , false , function ( error ) { console . log ( 'Switch to CMD mode' ) ; wsclient . write ( peripheralId , blueRadiosService , blueRadiosTxCharacteristic , hexCommand , false , function ( ) { console . log ( 'sent CMD: ' + command . cyan ) ; } ) } ) } ) ; }
command - string
command - string