コード例 #1
0
bool LLMediaImplLLMozLib::updateState()
{
    if ( nextCommand() == LLMediaBase::COMMAND_START )
    {
        setStatus( LLMediaBase::STATUS_STARTED );
        clearCommand();
    };

    if ( nextCommand() == LLMediaBase::COMMAND_STOP )
    {
        setStatus( LLMediaBase::STATUS_STOPPED );
        clearCommand();
    };

    if ( nextCommand() == LLMediaBase::COMMAND_BACK  )
    {
        setStatus( LLMediaBase::STATUS_STARTED );
        LLMozLib::getInstance()->navigateBack( mWindowId );
        clearCommand();
    };

    if ( nextCommand() == LLMediaBase::COMMAND_FORWARD  )
    {
        setStatus( LLMediaBase::STATUS_STARTED );
        LLMozLib::getInstance()->navigateForward( mWindowId );
        clearCommand();
    };

    return true;
}
コード例 #2
0
ファイル: shell.c プロジェクト: alejandromagnorsky/so2010
int run_command(command_t* command){
	int i = 0, ret, bk = 0;
	char * bkstring = "&";
    
	if(streq(command->name, ""))
		return 0;
	
	while(command->args[i++] != 0);
	if(command->args[i - 2] == '&'){
		bk = 1;
	}
	
	for (i = 0; i < NUM_COMMANDS; i++) {
	    if(streq(command->name, commands[i].name)) {
			if(bk){
				ret = System.execb(commands[i].function, command->args);			
			}else{
				ret = System.exec(commands[i].function, command->args);			
				System.wait();
			}
			clearCommand(command);
            return ret;
	    }
	}

	printf("%s: command not found\n", command->name);	
	clearCommand(command);
	return 1;
}
コード例 #3
0
ファイル: WaspXBee900.cpp プロジェクト: Babody/waspmoteapi
/*
 * Function: It initalizes all the necessary variables including its parent's 
 * variables
 * 
 * Parameters:
 * 'protocol_used' : specifies the protocol used in the XBee module 
 * 'uart_used' : specifies the UART where the data are sent to (SOCKET0 or SOCKET1)
 * Returns: void
*/
void WaspXBee900::init(	uint8_t uart_used )
{	
	protocol=XBEE_900;
	uart=uart_used;
	
	// in the case the XBee is plugged to SOCKET0 it is necessary to make sure
	// that the multiplexor is selecting teh XBee module
	if(uart_used==SOCKET0)
	{
		Utils.setMuxSocket0();
	}
	
	data_length=0;
	it=0;
	rxFrameType=0;
	
	pos=0;
	discoveryOptions=0x00;
	
	scanTime[0]=SCAN_TIME_DIGIMESH_H;
	scanTime[1]=SCAN_TIME_DIGIMESH_L;
	encryptMode=ENCRYPT_MODE_DIGIMESH;
	timeRSSI=TIME_RSSI_DIGIMESH;
	
	frameNext=0;
	replacementPolicy=XBEE_OUT;	
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #4
0
ファイル: shell.c プロジェクト: akarpovsky/SO_TPE
int run_command(command_t * command){

	int i;
	if(streq(command->name, ""))
		return 0;

	int len = strlen(command->name);

	bool isBackground = (command->name[len-1] == '&')? true:false;
	if(isBackground)
	{
		command->name[len-1] = '\0';
	}

	for (i = 0; i < NUM_COMMANDS; i++) {
			if (streq(command->name, commands[i].name))
			{
				StartNewTask(commands[i].name, commands[i].task_function, command->args, isBackground);
				return 1;
			}
	}
	printfcolor(ERROR_COLOR ,"%s: command not found\n", command->name);
	clearCommand(command);
	return 1;
}
コード例 #5
0
void WaspXBeeDM::init(uint8_t protocol_used, uint8_t frequency, uint8_t model_used, uint8_t uart_used)
{
	protocol=protocol_used;
	freq=frequency;
	model=model_used;
	uart=uart_used;
	
	data_length=0;
	it=0;
	start=0;
	finish=0;
	add_type=0;
	mode=0;
	frag_length=0;
	TIME1=0;
	
	totalFragmentsReceived=0;
	pendingPackets=0;
	pos=0;
	discoveryOptions=0x00;
	
	scanTime[0]=SCAN_TIME_DIGIMESH_H;
	scanTime[1]=SCAN_TIME_DIGIMESH_L;
	encryptMode=ENCRYPT_MODE_DIGIMESH;
	timeRSSI=TIME_RSSI_DIGIMESH;
	
	if( protocol!=XBEE_900 )
	{	
		awakeTime[0]=AWAKE_TIME_DIGIMESH_H;
		awakeTime[1]=AWAKE_TIME_DIGIMESH_M;
		awakeTime[2]=AWAKE_TIME_DIGIMESH_L;
		sleepTime[0]=SLEEP_TIME_DIGIMESH_H;
		sleepTime[1]=SLEEP_TIME_DIGIMESH_M;
		sleepTime[2]=SLEEP_TIME_DIGIMESH_L;
		
		sleepOptions=SLEEP_OPTIONS_DIGIMESH;
		powerLevel=POWER_LEVEL_DIGIMESH;
			
		networkHops=7;
		netDelaySlots=3;
		netRouteRequest=3;
		meshNetRetries=1;
	}
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #6
0
////////////////////////////////////////////////////////////////////////////////
// virtual (derives from LLMediaBase)
bool LLMediaImplCommon::updateCommand()
{
	if ( nextCommand() == LLMediaBase::COMMAND_START )
	{
		setStatus( LLMediaBase::STATUS_STARTED );
		clearCommand();
	};

	if ( nextCommand() == LLMediaBase::COMMAND_STOP )
	{
		setStatus( LLMediaBase::STATUS_STOPPED );
		clearCommand();
	};

	if ( nextCommand() == LLMediaBase::COMMAND_PAUSE  )
	{
		setStatus( LLMediaBase::STATUS_PAUSED );
		clearCommand();
	};

	return true;
}
コード例 #7
0
void	WaspXBee868::init(uint8_t protocol_used, uint8_t frequency, uint8_t model_used, uint8_t uart_used)
{
	protocol=protocol_used;
	freq=frequency;
	model=model_used;
	uart=uart_used;
	
	totalFragmentsReceived=0;
	pendingPackets=0;
	pos=0;
	discoveryOptions=0x00;
	
	scanTime[0]=0x00;
	scanTime[1]=0x82;
	encryptMode=0;
	powerLevel=4;
	timeRSSI=0x20;

	ACKerrors[0]=0x00;
	ACKerrors[1]=0x00;
	errorsRF[0]=0x00;
	errorsRF[1]=0x00;
	goodPackets[0]=0x00;
	goodPackets[1]=0x00;
	transmisionErrors[0]=0x00;
	transmisionErrors[1]=0x00;
	maxPayloadBytes[0]=0x01;
	maxPayloadBytes[1]=0x00;
	multipleBroadcast=0x03;
	macRetries=0x0A;
	resetReason=0x00;
	
	data_length=0;
	it=0;
	start=0;
	finish=0;
	add_type=0;
	mode=0;
	frag_length=0;
	TIME1=0;	
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #8
0
ファイル: WaspXBeeDM.cpp プロジェクト: ClearSP/waspmoteapi
/*
 * Function: It initalizes all the necessary variables including its parent's 
 * variables
 * 
 * Parameters:
 * 'protocol_used' : specifies the protocol used in the XBee module 
 * 'uart_used' : specifies the UART where the data are sent to (SOCKET0 or SOCKET1)
 * Returns: void
*/
void WaspXBeeDM::init(	uint8_t uart_used	)
{	
	protocol=DIGIMESH;
	uart=uart_used;
	
	// in the case the XBee is plugged to SOCKET0 it is necessary to make sure
	// that the multiplexor is selecting teh XBee module
	if(uart_used==SOCKET0)
	{
		Utils.setMuxSocket0();
	}
	
	data_length=0;
	it=0;
	rxFrameType=0;
	
	pos=0;
	discoveryOptions=0x00;
	
	scanTime[0]=SCAN_TIME_DIGIMESH_H;
	scanTime[1]=SCAN_TIME_DIGIMESH_L;
	encryptMode=ENCRYPT_MODE_DIGIMESH;
	timeRSSI=TIME_RSSI_DIGIMESH;
	
	awakeTime[0]=AWAKE_TIME_DIGIMESH_H;
	awakeTime[1]=AWAKE_TIME_DIGIMESH_M;
	awakeTime[2]=AWAKE_TIME_DIGIMESH_L;
	sleepTime[0]=SLEEP_TIME_DIGIMESH_H;
	sleepTime[1]=SLEEP_TIME_DIGIMESH_M;
	sleepTime[2]=SLEEP_TIME_DIGIMESH_L;
	
	sleepOptions=SLEEP_OPTIONS_DIGIMESH;
	powerLevel=POWER_LEVEL_DIGIMESH;
			
	networkHops=7;
	netDelaySlots=3;
	netRouteRequest=3;
	meshNetRetries=1;
	
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #9
0
ファイル: WaspXBee868.cpp プロジェクト: AppSaloon/waspmoteapi
/*
 Function: It initalizes all the necessary variables
 Parameters:
	protocol_used : specifies the protocol used in the XBee module 
	uart_used : specifies the UART where the data are sent to (UART0 or UART1)	
 Returns: void
*/
void WaspXBee868::init(	uint8_t uart_used )
{
	// set protocol and socket used for XBee module	
	protocol=XBEE_868;
	uart=uart_used;
	
	// in the case the XBee is plugged to SOCKET0 it is necessary to make sure
	// that the multiplexor is selecting the XBee module
	if(uart_used==SOCKET0)
	{
		Utils.setMuxSocket0();
	}
	
	pos=0;
	discoveryOptions=0x00;
	
	scanTime[0]=0x00;
	scanTime[1]=0x82;
	encryptMode=0;
	powerLevel=4;
	timeRSSI=0x20;

	ACKerrors[0]=0x00;
	ACKerrors[1]=0x00;
	errorsRF[0]=0x00;
	errorsRF[1]=0x00;
	goodPackets[0]=0x00;
	goodPackets[1]=0x00;
	transmisionErrors[0]=0x00;
	transmisionErrors[1]=0x00;
	maxPayloadBytes[0]=0x01;
	maxPayloadBytes[1]=0x00;
	multipleBroadcast=0x03;
	macRetries=0x0A;
	resetReason=0x00;
	
	data_length=0;
	it=0;
	rxFrameType=0;
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #10
0
ファイル: WaspXBee802.cpp プロジェクト: Spectos/waspmoteapi
/*
 Function: It initializes the necessary variables
 Parameters:
	'uart_used' : specifies the UART where the data are sent to 
 Returns: void
*/
void WaspXBee802::init(	uint8_t uart_used	)
{
	// set protocol and socket used for XBee module
	protocol=XBEE_802_15_4;
	uart=uart_used;
	
	// in the case the XBee is plugged to SOCKET0 it is necessary to make sure
	// that the multiplexor is selecting teh XBee module
	if(uart_used==SOCKET0)
	{
		Utils.setMuxSocket0();
	}

	pos=0;
	discoveryOptions=0x00;
	awakeTime[0]=AWAKE_TIME_802_15_4_H;
	awakeTime[1]=AWAKE_TIME_802_15_4_L;
	sleepTime[0]=SLEEP_TIME_802_15_4_H;
	sleepTime[1]=SLEEP_TIME_802_15_4_L;
	scanTime[0]=SCAN_TIME_802_15_4;
	scanChannels[0]=SCAN_CHANNELS_802_15_4_H;
	scanChannels[1]=SCAN_CHANNELS_802_15_4_L;
	encryptMode=ENCRYPT_MODE_802_15_4;
	powerLevel=POWER_LEVEL_802_15_4;
	timeRSSI=TIME_RSSI_802_15_4;
	sleepOptions=SLEEP_OPTIONS_802_15_4;
	retries=0;
	delaySlots=0;
	macMode=0;
	energyThreshold=0x2C;
	counterCCA[0]=0x00;
	counterCCA[1]=0x00;
	counterACK[0]=0x00;
	counterACK[1]=0x00;

	counter=0;
	data_length=0;
	it=0;		
	rxFrameType=0;
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #11
0
ファイル: WaspXBee802.cpp プロジェクト: ipadron/waspmote-api
void	WaspXBee802::init(uint8_t protocol_used, uint8_t frequency, uint8_t model_used)
{
	protocol=protocol_used;
	freq=frequency;
	model=model_used;

	totalFragmentsReceived=0;
	pendingPackets=0;
	pos=0;
	discoveryOptions=0x00;
	awakeTime[0]=AWAKE_TIME_802_15_4_H;
	awakeTime[1]=AWAKE_TIME_802_15_4_L;
	sleepTime[0]=SLEEP_TIME_802_15_4_H;
	sleepTime[1]=SLEEP_TIME_802_15_4_L;
	scanTime[0]=SCAN_TIME_802_15_4;
	scanChannels[0]=SCAN_CHANNELS_802_15_4_H;
	scanChannels[1]=SCAN_CHANNELS_802_15_4_L;
	encryptMode=ENCRYPT_MODE_802_15_4;
	powerLevel=POWER_LEVEL_802_15_4;
	timeRSSI=TIME_RSSI_802_15_4;
	sleepOptions=SLEEP_OPTIONS_802_15_4;
	retries=0;
	delaySlots=0;
	macMode=0;
	energyThreshold=0x2C;
	counterCCA[0]=0x00;
	counterCCA[1]=0x00;
	counterACK[0]=0x00;
	counterACK[1]=0x00;

        counter=0;
	data_length=0;
	it=0;
	start=0;
	finish=0;
	add_type=0;
	mode=0;
	frag_length=0;
	TIME1=0;
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
}
コード例 #12
0
void lwGenericClient::submit()
{
    //去掉cmdJSON最后面的逗号
    int len;
    len=strlen(cmdJSON);
    cmdJSON[len-1]=']';
    //converter.appendChar(cmdJSON,"]");

    //formatCommand();
    uploadValue(); //由各子类来实现,提交完数据之后,复位cmdJSON和lastTime.
    clearCommand();

    lastTime = millis();

};
コード例 #13
0
ファイル: WaspXBee802.cpp プロジェクト: ClearSP/waspmoteapi
/*
 * Function: Send a packet from one XBee to another XBee in API mode
 * 
 * Parameters: 
 *   packet :	A struct of packetXBee type
 * 
 * Returns: Integer that determines if there has been any error 
 * 	error=2 --> The command has not been executed
 * 	error=1 --> There has been an error while executing the command
 * 	error=0 --> The command has been executed with no errors
 * 
 * --> DIGI's XBee Packet inner structure:
 * 
 * StartDelimiter(1B) + Length(2B) +  Frame Data(variable) + Checksum(1B)
 *  ______________     ___________     __________________     __________
 * |              |   |     |     |   |					 |   |			|
 * |	0x7E	  | + | MSB | LSB | + |    Frame Data    | + |	1 Byte	|
 * |______________|   |_____|_____|   |__________________|   |__________|
 * 
*/
uint8_t WaspXBee802::sendXBeePriv(struct packetXBee* packet)
{	
	// Local variables
	uint8_t TX[120];
    uint8_t counter=0; 
    unsigned long previous=0;
    uint8_t protegido=0;
    uint8_t tipo=0;
    uint8_t estado=1;
    int8_t error=2;
    uint8_t old_netAddress[2];
    uint8_t net_Address_changed = 0;    

    clearCommand();

    error_TX=2;
    
    // clear TX variable where the frame is going to be filled
	memset(TX,0x00,120);
    
    // Create the XBee frame
    TX[0]=0x7E;
    TX[1]=0x00;
    
    // set frame ID as 0x01, so response message will be sent
    TX[4]=0x01;
    
    it=0;
    error_AT=2;
 
	// initialize variable
    old_netAddress[0]=0x00;
    old_netAddress[1]=0x00;
 
	// BROADCAST MODE
    if(packet->mode==BROADCAST)
	{
		tipo=15;
		
		// set packet length
		TX[2]=11+packet->data_length; 
		
		// set TX request frame (0x00)
		TX[3]=0x00;
	    
		previous=millis();
		error_AT=2;
		while( ((error_AT==1) || (error_AT==2)) && (millis()-previous<500) )
		{
			estado=getOwnNetAddress();
			
			 //avoid millis overflow problem
			if( millis() < previous ) previous=millis();
        }
			
        old_netAddress[0]=sourceNA[0];
        old_netAddress[1]=sourceNA[1];
	    
	    previous=millis();
        error_AT=2;
        
        while( ((error_AT==1) || (error_AT==2)) && (millis()-previous<500) )
        {
			estado=setOwnNetAddress(0xFF,0xFF);
			net_Address_changed = 1;
			
			//avoid millis overflow problem
			if( millis() < previous ) previous=millis();
        }
        error=2;
		
		// set BROADCAST address
        TX[5]=0x00;
		TX[6]=0x00;
		TX[7]=0x00;
		TX[8]=0x00;
		TX[9]=0x00;
		TX[10]=0x00;
		TX[11]=0xFF;
		TX[12]=0xFF;
		
		// set Options enabling ACK 
		TX[13]=0x00;
		it=0;
		
		// generate RF Data payload which is composed by [Api header]+[Data]
		genDataPayload(packet,TX,14);
				
		// set checksum
		TX[packet->data_length+14]=getChecksum(TX); 
    }   
    else if(packet->mode==UNICAST)
	{
		// 64-bit Destination Address
		if( packet->address_type == _64B )
		{
			tipo=15;
			
			// set fragment length			 
			TX[2]=11+packet->data_length;
			
			// set TX Request Frame Type (64-bit address)
			TX[3]=0x00;
			
			// set chosen address in setDestinationParams function
			TX[5]=packet->macDH[0];
			TX[6]=packet->macDH[1];
			TX[7]=packet->macDH[2];
			TX[8]=packet->macDH[3];
			TX[9]=packet->macDL[0];
			TX[10]=packet->macDL[1];
			TX[11]=packet->macDL[2];
			TX[12]=packet->macDL[3];  
			
			previous=millis();
			error_AT=2;
			while( ((error_AT==1) || (error_AT==2)) && (millis()-previous<500) )
			{
				estado=getOwnNetAddress();
				
				// avoid millis overflow problem
				if( millis() < previous ) previous=millis(); 
            }
			
			old_netAddress[0]=sourceNA[0];
			old_netAddress[1]=sourceNA[1];
			
			previous=millis();
			error_AT=2;
			while( ((error_AT==1) || (error_AT==2)) && (millis()-previous<500) )
			{
				estado=setOwnNetAddress(0xFF,0xFF);
				net_Address_changed = 1;
				
				// avoid millis overflow problem
				if( millis() < previous ) previous=millis(); 
            }
			
			error=2;
			TX[13]=0x00;
			it=0;

			// generate RF Data payload which is composed by [Api header]+[Data]
			genDataPayload(packet,TX,14);
					
			// setting checksum
			TX[packet->data_length+14]=getChecksum(TX);
        }
		// 16-Bit Destination Address
		else if( packet->address_type == _16B)
		{
			tipo=9;
			
			// set TX Request frame Type (16-bit address)
			TX[3]=0x01;
			
			// set Destination Address
			TX[5]=packet->naD[0];
			TX[6]=packet->naD[1];
			
			// Set Options enabling ACK
			TX[7]=0x00;
			it=0;
			
			// generate RF Data payload which is composed by [Api header]+[Data]
			genDataPayload(packet,TX,8);
			
			// fragment length
			TX[2]=5+packet->data_length;			

            // set checksum
            TX[packet->data_length+8]=getChecksum(TX);
		}
	}
	else
	{
		// no mode selected, exit with error
		return 2;
	}
   
    // Generate the escaped API frame (it is necessary because AP=2)
	gen_frame_ap2(packet,TX,protegido,tipo);
   
	counter=0;
	// send frame through correspondent UART
	while(counter<(packet->data_length+tipo+protegido))
	{
		// switch MUX in case SOCKET1 is used
		if( uart==SOCKET1 )
		{
			Utils.setMuxSocket1();
		}
		// print byte through correspondent UART
		printByte(TX[counter], uart); 
		counter++;
	}
	counter=0;
	
	// read XBee response to TX request
	error_TX = txStatusResponse();
    error = error_TX; 
    
    // set delivery status
	packet->deliv_status=delivery_status;
		
	if( net_Address_changed )
	{
		error_AT=2;
		previous=millis();
		while( ((error_AT==1) || (error_AT==2)) && (millis()-previous<500) )
		{
			estado=setOwnNetAddress(old_netAddress[0],old_netAddress[1]);
			
			//avoid millis overflow problem
			if( millis() < previous ) previous=millis(); 
		}
	}
    
    return error;
}
コード例 #14
0
ファイル: WaspXBeeDM.cpp プロジェクト: ClearSP/waspmoteapi
/*
 * Function: Send a packet from one XBee to another XBee in API mode
 * 
 * Parameters: 
 *   packet :	A struct of packetXBee type
 * 
 * Returns: Integer that determines if there has been any error 
 * 	error=2 --> The command has not been executed
 * 	error=1 --> There has been an error while executing the command
 * 	error=0 --> The command has been executed with no errors
 * 
 * --> DIGI's XBee Packet inner structure:
 * 
 * StartDelimiter(1B) + Length(2B) +  Frame Data(variable) + Checksum(1B)
 *  ______________     ___________     __________________     __________
 * |              |   |     |     |   |					 |   |			|
 * |	0x7E	  | + | MSB | LSB | + |    Frame Data    | + |	1 Byte	|
 * |______________|   |_____|_____|   |__________________|   |__________|
 * 
*/
uint8_t WaspXBeeDM::sendXBeePriv(struct packetXBee* packet)
{
	// Local variables
	uint8_t TX[120];
    uint8_t counter=0;
    uint16_t aux=0;
    uint8_t protegido=0;
    uint8_t tipo=0;
    int8_t error=2;
    
    clearCommand();

    error_TX=2;
    
    // clear TX variable where the frame is going to be filled
	memset(TX,0x00,120);
    
    /* Create the XBee frame */
    TX[0]=0x7E;
    TX[1]=0x00;
    
    // set frame ID as 0x01, so response message will be sent
    TX[4]=0x01;
    
    it=0;
    error_AT=2;
    

    if( (packet->mode==BROADCAST) || (packet->mode==UNICAST) )
    {
		// set fragment length for 'Transmit Request' frames (0x10)
        TX[2]=14+packet->data_length; 
        
        aux=0;
        TX[3]=0x10; // frame ID
        tipo=18;	 
        
        // set 64-Destination Address   
        if(packet->mode == BROADCAST)
        {
			// set BROADCAST address
            TX[5]=0x00;
			TX[6]=0x00;
			TX[7]=0x00;
			TX[8]=0x00;
			TX[9]=0x00;
			TX[10]=0x00;
			TX[11]=0xFF;
			TX[12]=0xFF;	                
        }
        else if(packet->mode==UNICAST)
        {
			// set chosen address in setDestinationParams function
			TX[5]=packet->macDH[0];
			TX[6]=packet->macDH[1];
			TX[7]=packet->macDH[2];
			TX[8]=packet->macDH[3];
			TX[9]=packet->macDL[0];
			TX[10]=packet->macDL[1];
			TX[11]=packet->macDL[2];
			TX[12]=packet->macDL[3];       
        }
        
        // set frame bytes
        TX[13]=0xFF;
        TX[14]=0xFE; 
		TX[15]=0x00;	
        TX[16]=0x00;  
        it=0;
        
        // generate RF Data payload which is composed by [Api header]+[Data]
        genDataPayload(packet,TX,17);
        
        // set checksum     
        TX[packet->data_length+17]=getChecksum(TX); 
    }
    else // CLUSTER Type (Explicit Addressing Command Frame)
    {
		// set fragment length for 'Explicit Addressing Command' frames (0x11)
        TX[2]=20 + packet->data_length; 
        
        // set frame ID
        TX[3]=0x11; 
        
        tipo=24;
		TX[5]=packet->macDH[0];
		TX[6]=packet->macDH[1];
		TX[7]=packet->macDH[2];
		TX[8]=packet->macDH[3];
		TX[9]=packet->macDL[0];
		TX[10]=packet->macDL[1];
		TX[11]=packet->macDL[2];
		TX[12]=packet->macDL[3];     
	
        TX[13]=0xFF;
        TX[14]=0xFE;        
        TX[15]=packet->SD;
        TX[16]=packet->DE;
        TX[17]=0x00;
        TX[18]=packet->CID[0];     
        TX[19]=packet->PID[0];
        TX[20]=packet->PID[1];     
        TX[21]=0x00;
        TX[22]=0x00;
        it=0;
        
        // generate RF Data payload which is composed by [Api header]+[Data]
        genDataPayload(packet,TX,23);

        // set checksum
        TX[packet->data_length+23]=getChecksum(TX);  
            
    }
        
    
    // Generate the escaped API frame (it is necessary because AP=2)
    gen_frame_ap2(packet,TX,protegido,tipo);
    
    // send frame through correspondent UART
    while(counter<(packet->data_length+tipo+protegido))
    {	    
	  	// switch MUX in case SOCKET1 is used
	    if( uart==SOCKET1 )
		{
		    Utils.setMuxSocket1();
		}
		// print byte through correspondent UART
		printByte(TX[counter], uart); 
        counter++;
    }
    
    counter=0;    
   
	// read XBee's answer to TX request
	error_TX=txZBStatusResponse();
	error = error_TX; 
	
    packet->deliv_status=delivery_status;
    packet->discov_status=discovery_status;
    packet->true_naD[0]=true_naD[0];
    packet->true_naD[1]=true_naD[1];
    packet->retries=retries_sending;
    
    return error;
}
コード例 #15
0
void	WaspXBeeZB::init(uint8_t protocol_used, uint8_t frequency, uint8_t model_used, uint8_t uart_used)
{
	protocol=protocol_used;
	freq=frequency;
	model=model_used;
	uart=uart_used;
	
	totalFragmentsReceived=0;
	pendingPackets=0;
	pos=0;
	discoveryOptions=0x00;
	awakeTime[0]=AWAKE_TIME_ZIGBEE_H;
	awakeTime[1]=AWAKE_TIME_ZIGBEE_L;
	sleepTime[0]=SLEEP_TIME_ZIGBEE_H;
	sleepTime[1]=SLEEP_TIME_ZIGBEE_L;
	scanTime[0]=SCAN_TIME_ZIGBEE;
	scanChannels[0]=SCAN_CHANNELS_ZIGBEE_H;
	scanChannels[1]=SCAN_CHANNELS_ZIGBEE_L;
	timeEnergyChannel=TIME_ENERGY_CHANNEL_ZIGBEE;
	encryptMode=ENCRYPT_MODE_ZIGBEE;
	powerLevel=POWER_LEVEL_ZIGBEE;
	timeRSSI=TIME_RSSI_ZIGBEE;
	sleepOptions=SLEEP_OPTIONS_ZIGBEE;

	parentNA[0]=0xFF;
	parentNA[1]=0xFE;
	deviceType[0]=0x00;
	deviceType[1]=0x03;
	deviceType[2]=0x00;
	deviceType[3]=0x00;
	for(it=0;it<8;it++)
	{
		extendedPAN[it]=0x00;
	}
	maxUnicastHops=0x1E;
	maxBroadcastHops=0x00;
	stackProfile=0;
	joinTime=0xFF;
	channelVerification=0x00;
	joinNotification=0x00;
	aggregateNotification=0xFF;
	encryptOptions=0;
	for(it=0;it<16;it++)
	{
		networkKey[it]=0x00;
	}
	powerMode=4;
	
	data_length=0;
	it=0;
	start=0;
	finish=0;
	add_type=0;
	mode=0;
	frag_length=0;
	TIME1=0;
	nextIndex1=0;
	frameNext=0;
	replacementPolicy=XBEE_OUT;
	indexNotModified=1;
	error_AT=2;
	error_RX=2;
	error_TX=2;
	clearFinishArray();
	clearCommand();
	apsEncryption=0;
}
コード例 #16
0
///////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplGStreamer::updateMedia()
{
	//LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL;
	
	// sanity check
	if (mPump == NULL || mPlaybin == NULL)
	{
#ifdef LL_GST_REPORT_STATE_CHANGES
		LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL;
#endif
		mState = GST_STATE_NULL;
		setStatus(LLMediaBase::STATUS_DEAD);
		return false;
	}

	if (mState == GST_STATE_VOID_PENDING || mState == GST_STATE_NULL)
		return false;

	// process next outstanding command
	switch (nextCommand())
	{
	case LLMediaBase::COMMAND_START:
		LL_DEBUGS("MediaImpl") << "COMMAND_START" << LL_ENDL;
		if (getStatus() == LLMediaBase::STATUS_PAUSED ||
		    getStatus() == LLMediaBase::STATUS_NAVIGATING ||
		    getStatus() == LLMediaBase::STATUS_STOPPED)
		{
			play();
			setStatus(LLMediaBase::STATUS_STARTED);
			clearCommand();
		}
		break;
	case LLMediaBase::COMMAND_STOP:
		LL_DEBUGS("MediaImpl") << "COMMAND_STOP" << LL_ENDL;
		stop();
		setStatus(LLMediaBase::STATUS_STOPPED);
		clearCommand();
		break;
	case LLMediaBase::COMMAND_PAUSE:
		LL_DEBUGS("MediaImpl") << "COMMAND_PAUSE" << LL_ENDL;
		if (getStatus() == LLMediaBase::STATUS_STARTED)
		{
			pause();
			setStatus(LLMediaBase::STATUS_PAUSED);
			clearCommand();
		}
		break;
	default:
		LL_INFOS("MediaImpl") << "Unknown command" << LL_ENDL;
		clearCommand();
		break;
	case LLMediaBase::COMMAND_NONE:
		break;
	}

	// deal with results
	if (g_main_context_pending(g_main_loop_get_context(mPump)))
	{
	       g_main_context_iteration(g_main_loop_get_context(mPump), FALSE);
	}

	if (mVideoSink)
	{
	        GST_OBJECT_LOCK(mVideoSink);
		if (mVideoSink->retained_frame_ready)
		{
#ifdef LL_GST_REPORT_STATE_CHANGES
			LL_DEBUGS("MediaImpl") <<"NEW FRAME " << LL_ENDL;
#endif
			if (mVideoSink->retained_frame_width != getMediaWidth() ||
			    mVideoSink->retained_frame_height != getMediaHeight())
				// *TODO: also check for change in format
			{
				// just resize containe
				int neww = mVideoSink->retained_frame_width;
				int newh = mVideoSink->retained_frame_height;
				int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format];
				if (SLV_PF_RGBX == mVideoSink->retained_frame_format)
				{
					mTextureFormatPrimary = LL_MEDIA_RGBA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				else
				{
					mTextureFormatPrimary = LL_MEDIA_BGRA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				mMediaRowbytes = neww * newd;
				LL_DEBUGS("MediaImpl")
				    << "video container resized to " <<
				    neww <<"x"<< newh << LL_ENDL;
				
				delete[] mediaData;
				mediaData = new unsigned char[mMediaRowbytes *
							      newh];
				
				GST_OBJECT_UNLOCK(mVideoSink);

				setMediaDepth(newd);
				setMediaSize(neww, newh);
				return true;
			}

			// we're gonna totally consume this frame - reset 'ready' flag
			mVideoSink->retained_frame_ready = FALSE;
			memcpy(mediaData, mVideoSink->retained_frame_data,
			       mMediaRowbytes * getMediaHeight());
			
			GST_OBJECT_UNLOCK(mVideoSink);
			LLMediaEvent event( this );
			mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
			return true;
		}
		else
		{
			// nothing to do yet.
			GST_OBJECT_UNLOCK(mVideoSink);
			return true;
		}
	}

	return true;
}
コード例 #17
0
bool LLMediaImplQuickTime::processState()
{
	// start stream
	if ( nextCommand() == LLMediaBase::COMMAND_START )
	{
		// valid when we are in these states
		if ( getStatus() == LLMediaBase::STATUS_NAVIGATING|| getStatus() == LLMediaBase::STATUS_STOPPED || getStatus() == LLMediaBase::STATUS_PAUSED )
		{
			// it appears that the movie must be in a loaded state before we do this command
			if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
			{
				MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate( mMovieHandle ) );

				MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );

				setStatus( LLMediaBase::STATUS_STARTED );

				clearCommand();
			}
		}
	}
	else
	if ( nextCommand() == LLMediaBase::COMMAND_STOP )
	{
		// valid when we are in these states
		if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_PAUSED )
		{
			// it appears that the movie must be in a loaded state before we do this command
			if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
			{
				// stop playing
				Fixed rate = X2Fix( 0.0 );
				MCDoAction( mMovieController, mcActionPlay, (void*)rate );

				// go back to start
				rewind();

				setStatus( LLMediaBase::STATUS_STOPPED );
				clearCommand();
			};
		};
	}
	else
	if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
	{
		// valid when we are in these states
		if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_STOPPED )
		{
			// it appears that the movie must be in a loaded state before we do this command
			if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
			{
				// stop playing
				Fixed rate = X2Fix( 0.0 );
				MCDoAction( mMovieController, mcActionPlay, (void*)rate );

				setStatus( LLMediaBase::STATUS_PAUSED );
				clearCommand();
			};
		};
	};

	return true;
}
コード例 #18
0
///////////////////////////////////////////////////////////////////////////////
// virtual
bool
LLMediaImplGStreamer::
updateMedia ()
{
	DEBUGMSG("updating media...");
	
	// sanity check
	if (NULL == mPump
#ifdef LL_GST_SOUNDSINK
	    || NULL == mAudioSink
#endif
	    || NULL == mPlaybin)
	{
		DEBUGMSG("dead media...");
		return false;
	}

	// process next outstanding command
	switch (nextCommand())
	{
	case LLMediaBase::COMMAND_START:
		DEBUGMSG("COMMAND_START");
		if (getStatus() == LLMediaBase::STATUS_PAUSED ||
		    getStatus() == LLMediaBase::STATUS_NAVIGATING ||
		    getStatus() == LLMediaBase::STATUS_STOPPED)
		{
			DEBUGMSG("doing COMMAND_START");
			play();
			setStatus(LLMediaBase::STATUS_STARTED);
			clearCommand();
		}
		break;
	case LLMediaBase::COMMAND_STOP:
		DEBUGMSG("COMMAND_STOP");
		DEBUGMSG("doing COMMAND_STOP");
		stop();
		setStatus(LLMediaBase::STATUS_STOPPED);
		clearCommand();
		break;
	case LLMediaBase::COMMAND_PAUSE:
		DEBUGMSG("COMMAND_PAUSE");
		if (getStatus() == LLMediaBase::STATUS_STARTED)
		{
			DEBUGMSG("doing COMMAND_PAUSE");
			pause();
			setStatus(LLMediaBase::STATUS_PAUSED);
			clearCommand();
		}
		break;
	default:
		DEBUGMSG("COMMAND_?");
		clearCommand();
		break;
	case LLMediaBase::COMMAND_NONE:
		break;
	}

	// deal with results
	if (g_main_context_pending(g_main_loop_get_context(mPump)))
	{
	       g_main_context_iteration(g_main_loop_get_context(mPump), FALSE);
	}

	if (mVideoSink)
	{
	        GST_OBJECT_LOCK(mVideoSink);
		if (mVideoSink->retained_frame_ready)
		{
			DEBUGMSG("NEW FRAME ");
			if (mVideoSink->retained_frame_width != getMediaWidth() ||
			    mVideoSink->retained_frame_height != getMediaHeight())
				// *TODO: also check for change in format
			{
				// just resize containe
				int neww = mVideoSink->retained_frame_width;
				int newh = mVideoSink->retained_frame_height;
				int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format];
				if (SLV_PF_RGBX == mVideoSink->retained_frame_format)
				{
					mTextureFormatPrimary = LL_MEDIA_RGBA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				else
				{
					mTextureFormatPrimary = LL_MEDIA_BGRA;
					mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
				}
				mMediaRowbytes = neww * newd;
				DEBUGMSG("video container resized to %dx%d",
					 neww, newh);
				
				delete[] mediaData;
				mediaData = new unsigned char[mMediaRowbytes *
							      newh];
				
				GST_OBJECT_UNLOCK(mVideoSink);

				setMediaDepth(newd);
				setMediaSize(neww, newh);
				return true;
			}

			// we're gonna totally consume this frame - reset 'ready' flag
			mVideoSink->retained_frame_ready = FALSE;
			memcpy(mediaData, mVideoSink->retained_frame_data,
			       mMediaRowbytes * getMediaHeight());
			
			GST_OBJECT_UNLOCK(mVideoSink);
			LLMediaEvent event( this );
			mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
			return true;
		}
		else
		{
			// nothing to do yet.
			GST_OBJECT_UNLOCK(mVideoSink);
			return true;
		}
	}

	return true;
}