示例#1
0
void gui_set_bluetooth_action(uint8_t index)
{
	switch (index)
	{
		case(1):
			config.system.use_bt = !config.system.use_bt;
			eeprom_busy_wait();
			eeprom_update_byte(&config_ee.system.use_bt, config.system.use_bt);

			if (config.system.use_bt)
				bt_module_init();
			else
				bt_module_deinit();
		break;

		case(2):
			config.system.protocol = (config.system.protocol + 1) % NUMBER_OF_PROTOCOLS;
			eeprom_busy_wait();
			eeprom_update_byte(&config_ee.system.protocol, config.system.protocol);
		break;

		case(3):
			config.system.forward_gps = !config.system.forward_gps;
			eeprom_busy_wait();
			eeprom_update_byte(&config_ee.system.forward_gps, config.system.forward_gps);
		break;
	}
}
示例#2
0
void bt_irqh(uint8_t type, uint8_t * buf)
{
	uint8_t old_type;

	switch(type)
	{
		case(BT_IRQ_INIT):
		DEBUG("BT_MOD_STATE_INIT\n");
			bt_module_state = BT_MOD_STATE_INIT;
		break;
		case(BT_IRQ_INIT_OK):
			DEBUG("BT_MOD_STATE_OK\n");
			bt_module_state = BT_MOD_STATE_OK;
			bt_autodetect = false;
		break;
		case(BT_IRQ_DEINIT):
			DEBUG("BT_MOD_STATE_OFF\n");
			bt_module_state = BT_MOD_STATE_OFF;
			bt_device_connected = false;
		break;
		case(BT_IRQ_CONNECTED):
			DEBUG("BT_IRQ_CONNECTED\n");
			gui_showmessage_P(PSTR("Bluetooth\nconnected"));
			bt_device_connected = true;
		break;
		case(BT_IRQ_DISCONNECTED):
			DEBUG("BT_IRQ_DISCONNECTED\n");
			gui_showmessage_P(PSTR("Bluetooth\ndisconnected"));
			bt_device_connected = false;
			bt_output.Clear();
		break;
		case(BT_IRQ_RESET):
			DEBUG("BT_IRQ_RESET\n");
			bt_device_connected = false;
		break;
		case(BT_IRQ_INIT_FAIL):
			DEBUG("BT_IRQ_INIT_FAIL!\n");
			if (bt_autodetect)
			{
				old_type = bt_module_type;

				bt_module_deinit();
				bt_module_type = BT_UNKNOWN;
				_delay_ms(500);

				BT_UART_PWR_ON;

				if (old_type == BT_PAN1322)
				{
					bt_module_type = BT_PAN1026;
					bt_pan1026_init();
				}

				if (old_type == BT_PAN1026)
				{
					bt_module_type = BT_PAN1322;
					bt_pan1322_init();
				}

			}
			else
			{
//				gui_showmessage_P(PSTR("Bluetooth\nInit failed!"));
			}
		break;
	}
}
示例#3
0
void bt_stop()
{
	bt_module_deinit();

	GpioSetPull(BT_CTS, gpio_totem);
}