Ejemplo n.º 1
0
void
Esp8266WiFiPhy::ConfigureSoftAP(SoftAccessPoint sap, bool flashStore){
	string ATCommand;

	testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__);
	// header
	ATCommand = "AT+CWSAP_";
	// store
	if (flashStore){
		ATCommand += "DEF";
	}
	else {
		ATCommand += "CUR";
	}
	ATCommand += "=" + StringEscape(sap.m_ssid);
	ATCommand += "," + StringEscape(sap.m_password);
	ATCommand += "," + IntegerToString(sap.m_channel);
	ATCommand += "," + IntegerToString(sap.m_encryption);
	ATCommand += "," + IntegerToString(sap.m_maxconnections);
	ATCommand += "," + IntegerToString(sap.m_ssidbroadcast);
	//tail
	ATCommand += "\r\n";

	// resets the buffer from any spurious previous output and send
	m_UART->rxBufferFlush();
	UART_TX(ATCommand);
	dbgprintf("SEND:\r\n%s",ATCommand.c_str());
	if(!DoubleWaitFor("OK","ERROR")){
		printf("Error: Missed OK reply - AT+CWSAP_xxx\r\n");
		return;
	}
	// assign to internal variable
	m_softAP = sap;
	testprintf("Ended!\r\n");
}
Ejemplo n.º 2
0
void
Esp8266WiFiPhy::ListStationAP(StationAccessPoint sap){
	string ATCommand;

	testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__);
	// header
	ATCommand = "AT+CWLAP";
	if (!sap.m_ssid.empty()){
		ATCommand += "=" + StringEscape(sap.m_ssid);
		if (!sap.m_bssidmac.empty()){
			ATCommand += "," + StringEscape(sap.m_bssidmac);
			if (sap.m_channel != -1){
				ATCommand += "," + IntegerToString(sap.m_channel); // not to be escaped, since number!
			}
		}
	}
	//tail
	ATCommand += "\r\n";

	// resets the buffer from any spurious previous output and send
	m_UART->rxBufferFlush();
	UART_TX(ATCommand);
	dbgprintf("SEND:\r\n%s",ATCommand.c_str());
	if(!DoubleWaitFor("OK","ERROR")){
		printf("Error: Missed OK reply - AT+CWLAP\r\n");
		return;
	}
	dbgprintf("+CWLAP:(<ECN>,<SSID>,<RSSI>,<MAC>,<CH>,<FREQ OFFSET>,<FREQ CALIB>)\r\n");
	testprintf("Ended!\r\n");
}
Ejemplo n.º 3
0
/**
 * @brief Returns the Json representation of a Json Value.
 */
std::string JsonProcessor::PrintValue (const JsonValue* value)
{
    switch(value->type()) {
        case JsonValue::kNull:
        case JsonValue::kBool:
            return value->ToString();
            break;

        case JsonValue::kNumber:
            return ToStringPrecise(JsonValueToNumber(value)->value, precision);
            break;

        case JsonValue::kString:
            return "\"" + StringEscape(JsonValueToString(value)->value) + "\"";
            break;

        // this function is only called from within PrintArray() and PrintObject(), and both of them
        // handle those two cases separately. so the assertion holds as long as this function
        // is not called illegaly from a different context.
        case JsonValue::kArray:
        case JsonValue::kObject:
        default:
            assert(false);
    }
}
Ejemplo n.º 4
0
void
Esp8266WiFiPhy::SetSoftAPMac(string mac_addr, bool flashStore){
	string ATCommand;

	testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__);
	// header
	ATCommand = "AT+CIPAPMAC_";
	// store
	if (flashStore){
		// NB: DISABLED: WARNING!!! THIS CHANGES THE DEVICE PHYSICAL MAC ADDRESS!!
		// ATCommand += "DEF";
	}
	else {
		ATCommand += "CUR";
	}
	ATCommand += "=" + StringEscape(mac_addr);
	//tail
	ATCommand += "\r\n";

	// resets the buffer from any spurious previous output and send
	m_UART->rxBufferFlush();
	UART_TX(ATCommand);
	dbgprintf("SEND:\r\n%s",ATCommand.c_str());
	if(!DoubleWaitFor("OK","ERROR")){
		printf("Error: Missed OK reply - AT+CIPAPMAC_xxx\r\n");
		return;
	}
	m_softAPInterfaceMac = mac_addr;
	testprintf("Ended!\r\n");
}
Ejemplo n.º 5
0
bool
Esp8266WiFiPhy::ConnectToStationAP (StationAccessPoint sap, bool flashStore){
	string ATCommand;

	testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__);
	// header
	ATCommand = "AT+CWJAP_";
	if (flashStore){
		ATCommand += "DEF";
	}
	else {
		ATCommand += "CUR";
	}

	ATCommand += "=" + StringEscape(sap.m_ssid) + ",";
	ATCommand += StringEscape(sap.m_password);
	if (!(sap.m_bssidmac.empty())) {
		ATCommand += "," + StringEscape(sap.m_bssidmac);
	}
	//tail
	ATCommand += "\r\n";

	// resets the buffer from any spurious previous output and send
	m_UART->rxBufferFlush();
	UART_TX(ATCommand);
	dbgprintf("SEND:\r\n%s",ATCommand.c_str());

	if(!DoubleWaitFor("OK","FAIL")){
		printf("Error: +CWJAP: Error Code (1<=>4)==(TIMEOUT,WRONG PASSWORD,AP NOT FOUND,FAIL)\r\n");
		return false;
	}
	// assign to internal variable
	m_stationAP = sap;
	testprintf("Ended!\r\n");
	return true;
}
Ejemplo n.º 6
0
BOOL CSetProxyPage::OnApply()
{
	UpdateData();

	CString temp;
	Store (m_serveraddress, m_regServeraddress);
	temp.Format(_T("%d"), m_serverport);
	Store (temp, m_regServerport);
	Store (m_username, m_regUsername);
	Store (m_password, m_regPassword);


	CString http_proxy;
	if(!m_serveraddress.IsEmpty())
	{
		if (m_serveraddress.Find(_T("://")) == -1)
			http_proxy=_T("http://");

		if(!m_username.IsEmpty())
		{
			CString escapedUsername;

			if (StringEscape(m_username, &escapedUsername))
			{
				::MessageBox(NULL, _T("Could not encode username."), _T("TortoiseGit"), MB_ICONERROR);
				return FALSE;
			}

			http_proxy += escapedUsername;

			if(!m_password.IsEmpty())
			{
				CString escapedPassword;
				if (StringEscape(m_password, &escapedPassword))
				{
					::MessageBox(NULL, _T("Could not encode password."), _T("TortoiseGit"), MB_ICONERROR);
					return FALSE;
				}
				http_proxy += _T(":") + escapedPassword;
			}

			http_proxy += _T("@");
		}
		http_proxy+=m_serveraddress;

		if(m_serverport)
		{
			temp.Format(_T("%d"), m_serverport);
			http_proxy  += _T(":")+temp;
		}
	}

	if (m_isEnabled)
	{
		g_Git.SetConfigValue(_T("http.proxy"),http_proxy,CONFIG_GLOBAL);
	}
	else
	{
		g_Git.UnsetConfigValue(_T("http.proxy"), CONFIG_GLOBAL);
	}
	m_regSSHClient = m_SSHClient;
	SetModified(FALSE);
	return ISettingsPropPage::OnApply();
}