I need to be able to have 5 functions that happen in a single function that are the same command with different parameters each time. I have read through many tutorial and looked at a few examples and tried to implement it with no success. I think I understand the function of callbakc but I can not figure out how to implement it with more than 2 deep.

Here is the 5 calls I need nested each line is calling the same function with different parameters passed to it.

function send(Callback) {

var Angle = document.getElementById(“DampAngle”).value;

var AtCmd6 = 0x4 ;

var AtCmd4 = 0x4 ;

var AtCmd3 = 0x4 ;

var AtCmd2 = 0x4 ;

if ((Angle & 0x8) == 0x8) { // ANGL[3:0] = [D6, D4, D2, D1]

atCmd6 = “0x05”;}//

else {

atCmd6 = “0x04”;}//

if ((Angle & 0x4) == 0x4) { // ANGL[3:0] = [D6, D4, D2, D1]

atCmd4 = “0x05”;}//

else {

atCmd4 = “0x04”;}//

if ((Angle & 0x2) == 0x2) { // ANGL[3:0] = [D6, D4, D2, D1]

atCmd3 = “0x05”;}//

else {

atCmd3 = “0x04”;}//

if ((Angle & 0x1) == 0x1) { // ANGL[3:0] = [D6, D4, D2, D1]

atCmd2 = “0x05”;}//

else {

atCmd2 = “0x04”;}//

sendCmd(damp1Addr, “D2”, atCmd2,

sendCmd(damp1Addr, “D4”, atCmd4,

sendCmd(damp1Addr, “D3”, atCmd3,

sendCmd(damp1Addr, “D6”, atCmd6 // <<<<<<< ONLY PERFORM this

) ) ) )

function Callback() {sendCmd(damp1Addr, “AC”, 0 );} //apply changes <<<<< AND THIS

}

I have tried this in at least 5 or 6 different configuration and the command only perform two of the calls the last in the bunch of 4 and the last line of the function.

I am trying to send out packets to a wireless module through UART2 on the BBB, and I will need 5 or more to be sent consecutively.

Thanks in advance for any help anyone can provide.