Пример #1
0
void at_i( uint8_t *at_cmd )
{
    switch (at_cmd[3]) {
	case '\0':
	case '0':
		break;
		
	case '1':
		
		system_reset = 1;
		break;
		
	case '2':
		
		Tx_dutycycle = 1000;
		g_macData.phySF = 7;
		g_macData.phyModulation = MODULATION_LORA;
		LoRaMac_setMacLayerParameter(&g_macData, PARAMETER_PHY_MODULATION_MODE|PARAMETER_PHY_SPREADING_FACTOR);
		LoRaMac_setMode(MODE_PHY);
		osal_set_event(APP_taskID,APP_PERIOD_SEND);
		break;
		
	case '3':
		
		Tx_dutycycle = 1000;
		g_macData.phyModulation = MODULATION_FSK;
		LoRaMac_setMacLayerParameter(&g_macData, PARAMETER_PHY_MODULATION_MODE);
		LoRaMac_setMode(MODE_PHY);
		osal_set_event(APP_taskID,APP_PERIOD_SEND);
		break;

	default:
		break;
	}

}
/* Private functions ---------------------------------------------------------*/
void APP_Init(u8 task_id)
{
	//LoRaMacAppPara_t appData;

	//LoRaMacMacPara_t macData;

	//LoRaMacAppPara_t g_appData;
    //LoRaMacMacPara_t g_macData;

	APP_taskID = task_id;

	g_appData.devAddr = 0x00120560;
	LoRaMac_setAppLayerParameter(&g_appData, PARAMETER_DEV_ADDR);
	LoRaMac_getAppLayerParameter(&g_appData, PARAMETER_DEV_ADDR);
	APP_ShowMoteID(g_appData.devAddr);


	//memset( &g_macData , 0 , sizeof(g_macData) );
	//g_macData.channels[0].Frequency = 779500000;
	//g_macData.channels[0].DrRange.Value = 0x50;
	//g_macData.channels[0].Band = 0;

#if 0
	g_macData.channels[1].Frequency = 779500000;
	g_macData.channels[1].DrRange.Value = 0x50;
	g_macData.channels[1].Band = 0;

	g_macData.channels[2].Frequency = 779500000;
	g_macData.channels[2].DrRange.Value = 0x50;
	g_macData.channels[2].Band = 0;

	LoRaMac_setMacLayerParameter(&g_macData, PARAMETER_CHANNELS);
#endif

	//RedLED(OFF);
	//GreenLED(OFF);
	HalLedSet (HAL_LED_ALL, HAL_LED_MODE_OFF);

 	osal_set_event(APP_taskID,APP_PERIOD_SEND);
  //osal_set_event(APP_taskID,APP_TEST_UART);

}
Пример #3
0
void at_s( uint8_t *at_cmd , int32_t at_cmd_len )
{
		int32_t		ret;
		static uint8_t		idx;
		static uint8_t    ats_action1,ats_action2 ;
		uint8_t ack_buf[64];
		InsParam_t ins_param_at[8] ;
		static uint8_t param_num = 0  ;

		memset( ack_buf , 0 ,sizeof(ack_buf) );

		ret = get_ins_ats_action( at_cmd , &ats_action1, &ats_action2 );
		if( ERR_SUCCESS != ret )
						return ;
		switch( ats_action1 )
		{
		case '?':
						break;

		case '=':
					switch ( ats_action2 )
					{
					 case 0x00:
						  memset( ins_param_at , 0 ,sizeof(ins_param_at) );
	            idx = 5 ;
	            param_num = get_ins_param( &at_cmd[idx],at_cmd_len-idx-2, ins_param_at );//2//--表示0d,0a
	            if( 1 != param_num )
	            {
	                send_to_host(AT_ERROR ,strlen(AT_ERROR) );
	                break;
	            }
	            g_config_at_t.banud = atoi( (char*)&ins_param_at[0].value[0] );
	            HAL_UART_BandRateChange( g_config_at_t.banud);
						 break;
							 
						case 0x01:
							memset( ins_param_at , 0 ,sizeof(ins_param_at) );
							idx = 5;
							param_num = get_ins_param( &at_cmd[idx],at_cmd_len-idx-2, ins_param_at );
							if( 4 != param_num )
							{
									send_to_host( AT_ERROR ,strlen(AT_ERROR) );
									break;
							}
							g_config_at_t.tx_rx = ins_param_at[0].value[0];
							g_config_at_t.phy_modulation= atoi((char *)&ins_param_at[1].value[0]);
							g_config_at_t.phy_freq = atoi((char *)&ins_param_at[2].value[0]);
							g_config_at_t.phy_sf = atoi((char *)&ins_param_at[3].value[0]);
							
							if( g_config_at_t.tx_rx == 'S' )
							{		
									g_at_set_tx = true;
									Tx_dutycycle = 1000;
									g_macData.phySF = g_config_at_t.phy_sf;
									g_macData.phyFrequency = g_config_at_t.phy_freq;	
									g_macData.phyModulation = g_config_at_t.phy_modulation;
									LoRaMac_setMacLayerParameter(&g_macData, PARAMETER_PHY_FREQUENCY|PARAMETER_PHY_SPREADING_FACTOR|PARAMETER_PHY_MODULATION_MODE);
									
									LoRaMac_setMode(MODE_PHY);
									osal_set_event(APP_taskID,APP_PERIOD_SEND);
									
							}
							else if( g_config_at_t.tx_rx == 'R' )
							{

									g_at_set_tx = false;	
									
									g_macData.phySF = g_config_at_t.phy_sf;
									g_macData.phyFrequency = g_config_at_t.phy_freq;	
									g_macData.phyModulation = g_config_at_t.phy_modulation;
									LoRaMac_setMacLayerParameter(&g_macData, PARAMETER_PHY_FREQUENCY|PARAMETER_PHY_SPREADING_FACTOR|PARAMETER_PHY_MODULATION_MODE);
									
									LoRaMac_setMode(MODE_PHY);
									
							}
							break;
							
						case 0x02:
						  memset( ins_param_at , 0 ,sizeof(ins_param_at) );
	            idx = 5 ;
	            param_num = get_ins_param( &at_cmd[idx],at_cmd_len-idx-2, ins_param_at );//2//--表示0d,0a
	            if( 2 != param_num )
	            {
	               send_to_host( AT_ERROR ,strlen(AT_ERROR) );
	               break;
	            }
	            g_at_set_diffrq = atoi( (char*)&ins_param_at[0].value[0] );
							
							if( g_at_set_diffrq == 1 )
							{
								LoRa_SetDifFrq( atoi( (char*)&ins_param_at[1].value[0] ) );
							}
	            
						 break;

					default:
							break;
					}
						
					break;
		default:
			break;
		}
}