当前位置: 首页>>代码示例>>C++>>正文


C++ os_sprintf函数代码示例

本文整理汇总了C++中os_sprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ os_sprintf函数的具体用法?C++ os_sprintf怎么用?C++ os_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了os_sprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WIFI_Connect

void ICACHE_FLASH_ATTR WIFI_Connect(uint8_t* ssid, uint8_t* pass, WifiCallback cb)
{
	struct station_config stationConf;

	INFO("WIFI_INIT\r\n");
	wifi_set_opmode(STATION_MODE);
	wifi_station_set_auto_connect(FALSE);
	wifiCb = cb;

	os_memset(&stationConf, 0, sizeof(struct station_config));

	os_sprintf(stationConf.ssid, "%s", ssid);
	os_sprintf(stationConf.password, "%s", pass);

	wifi_station_set_config(&stationConf);

	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);

	wifi_station_set_auto_connect(TRUE);
	wifi_station_connect();
}
开发者ID:eprzenic,项目名称:esp8266-dev,代码行数:23,代码来源:wifi.c

示例2: light_SendMeshBroadcastUpgrade

void ICACHE_FLASH_ATTR
	light_SendMeshBroadcastUpgrade(uint32 nonce,char* version,int pkt_len)
{
    struct espconn* pconn = (struct espconn*)user_GetUserPConn();

	uint8* pkt_upgrade = (uint8*)os_zalloc(pkt_len);
	if(pkt_upgrade == NULL) return;
	
	os_sprintf(pkt_upgrade,UPGRADE_BROADCAST_CMD,nonce,version);
	//data_send_buf(pconn, true, pkt_upgrade,os_strlen(pkt_upgrade),NULL,0);
	espconn_esp_sent(pconn, pkt_upgrade, os_strlen(pkt_upgrade),0);
	os_free(pkt_upgrade);
	pkt_upgrade = NULL;
}
开发者ID:koanpl,项目名称:ESP8266_LIGHT_WITH_MESH,代码行数:14,代码来源:user_light_mesh.c

示例3: mesh_MacIdInit

void ICACHE_FLASH_ATTR
mesh_MacIdInit()
{
    if(mdev_mac){
        os_printf("Mesh mdev_mac: %s \r\n",mdev_mac);
        return;
    }
    mdev_mac = (char*)os_zalloc(ESP_MESH_JSON_DEV_MAC_ELEM_LEN+1);	
    //uint32 MAC_FLG = READ_PERI_REG(0x3ff00054);
    uint8 mac_sta[6] = {0};
    wifi_get_macaddr(STATION_IF, mac_sta);
    os_sprintf(mdev_mac,"\"mdev_mac\":\"%02X%02X%02X%02X%02X%02X\"",MAC2STR(mac_sta));
    os_printf("Disp mdev_mac: %s\r\n",mdev_mac);
}
开发者ID:koanpl,项目名称:ESP8266_LIGHT_WITH_MESH,代码行数:14,代码来源:user_light_mesh.c

示例4: mqttConnectedCb

void ICACHE_FLASH_ATTR mqttConnectedCb(uint32_t *args) {
	char topic[100];

	MQTT_Client* client = (MQTT_Client*) args;
	mqttConnected = true;
	INFOP("MQTT is Connected to %s:%d\n", sysCfg.mqtt_host, sysCfg.mqtt_port);

	os_sprintf(topic, "/Raw/%s/set/#", sysCfg.device_id);
	INFOP("Subscribe to: %s\n", topic);
	MQTT_Subscribe(client, topic, 0);

	os_sprintf(topic, "/Raw/%s/+/set/filter", sysCfg.device_id);
	INFOP("Subscribe to: %s\n", topic);
	MQTT_Subscribe(client, topic, 0);

	MQTT_Subscribe(client, "/App/#", 0);

	publishDeviceInfo(client);
	publishData(client);

	os_timer_disarm(&switch_timer);
	os_timer_setfn(&switch_timer, (os_timer_func_t *) switchTimerCb, NULL);
	os_timer_arm(&switch_timer, 100, true);

	os_timer_disarm(&display_timer);
	os_timer_setfn(&display_timer, (os_timer_func_t *) displayCb, NULL);
	os_timer_arm(&display_timer, 2000, true);

	os_timer_disarm(&date_timer);
	os_timer_setfn(&date_timer, (os_timer_func_t *) dateTimerCb, NULL);
	os_timer_arm(&date_timer, 10 * 60 * 1000, false); //10 minutes

	os_timer_disarm(&transmit_timer);
	os_timer_setfn(&transmit_timer, (os_timer_func_t *) transmitCb, (void *) client);
	os_timer_arm(&transmit_timer, sysCfg.updates * 1000, true);
	lightOff();
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:37,代码来源:user_main.c

示例5: printWifiInfo

// print various Wifi information into json buffer
int ICACHE_FLASH_ATTR printWifiInfo(char *buff) {
  int len;
    //struct station_config stconf;
    wifi_station_get_config(&stconf);
    //struct softap_config apconf;
    wifi_softap_get_config(&apconf);

    uint8_t op = wifi_get_opmode() & 0x3;
    char *mode = wifiMode[op];
    char *status = "unknown";
    int st = wifi_station_get_connect_status();
    if (st >= 0 && st < sizeof(connStatuses)) status = connStatuses[st];
    int p = wifi_get_phy_mode();
    char *phy = wifiPhy[p&3];
    char *warn = wifiWarn[op];
    if (op == 3) op = 4; // Done to let user switch to AP only mode from Soft-AP settings page, using only one set of warnings
    char *apwarn = wifiWarn[op];
    char *apauth = apAuthMode[apconf.authmode];
    sint8 rssi = wifi_station_get_rssi();
    if (rssi > 0) rssi = 0;
    uint8 mac_addr[6];
    uint8 apmac_addr[6];
    wifi_get_macaddr(0, mac_addr);
    wifi_get_macaddr(1, apmac_addr);
    uint8_t chan = wifi_get_channel();

    len = os_sprintf(buff,
                     "\"mode\": \"%s\", \"modechange\": \"%s\", \"ssid\": \"%s\", \"status\": \"%s\", \"phy\": \"%s\", "
                     "\"rssi\": \"%ddB\", \"warn\": \"%s\",  \"apwarn\": \"%s\",\"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\", \"chan\":\"%d\", \"apssid\": \"%s\", "
                     "\"appass\": \"%s\", \"apchan\": \"%d\", \"apmaxc\": \"%d\", \"aphidd\": \"%s\", \"apbeac\": \"%d\", \"apauth\": \"%s\",\"apmac\":\"%02x:%02x:%02x:%02x:%02x:%02x\"",
                     mode, MODECHANGE, (char*)stconf.ssid, status, phy, rssi, warn, apwarn,
                     mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5], chan, (char*)apconf.ssid,(char*)apconf.password,apconf.channel,apconf.max_connection,apconf.ssid_hidden?"enabled":"disabled",apconf.beacon_interval, apauth,apmac_addr[0], apmac_addr[1], apmac_addr[2], apmac_addr[3], apmac_addr[4], apmac_addr[5]);

    struct ip_info info;
    if (wifi_get_ip_info(0, &info)) {
        len += os_sprintf(buff+len, ", \"ip\": \"%d.%d.%d.%d\"", IP2STR(&info.ip.addr));
        len += os_sprintf(buff+len, ", \"netmask\": \"%d.%d.%d.%d\"", IP2STR(&info.netmask.addr));
        len += os_sprintf(buff+len, ", \"gateway\": \"%d.%d.%d.%d\"", IP2STR(&info.gw.addr));
        len += os_sprintf(buff+len, ", \"hostname\": \"%s\"", flashConfig.hostname);
    } else {
        len += os_sprintf(buff+len, ", \"ip\": \"-none-\"");
    }
    len += os_sprintf(buff+len, ", \"staticip\": \"%d.%d.%d.%d\"", IP2STR(&flashConfig.staticip));
    len += os_sprintf(buff+len, ", \"dhcp\": \"%s\"", flashConfig.staticip > 0 ? "off" : "on");

    return len;
}
开发者ID:mgf909,项目名称:presence-firmware,代码行数:48,代码来源:cgiwifi.c

示例6: topicGetKeys

static void
topicGetKeys(
    v_entity e,
    c_voidp arg)
{
    c_array keyList = v_topicMessageKeyList(e);
    gapi_char     **keys  = (gapi_char **) arg;
    gapi_char      *ptr;
    c_ulong i;
    c_ulong size;
    c_ulong total = 0;
    c_ulong len = 0;

    size = c_arraySize(keyList);

    for ( i = 0; i < size; i++ ) {
        total += strlen(c_fieldName(keyList[i])) + 1;
    }

    if ( total > 0 ) {
        *keys = (gapi_char *)os_malloc(total);
        memset(*keys, 0, total);
    } else {
        *keys = (gapi_char *)os_malloc(1);
        **keys = '\0';
    }

    ptr = *keys;
    for ( i = 0; i < size; i++ ) {
        if ( i == 0 ) {
            len = os_sprintf(ptr, "%s", keyNameFromField(keyList[i]));
        } else {
            len = os_sprintf(ptr, ",%s", keyNameFromField(keyList[i]));
        }
        ptr = &(ptr[len]);
    }
}
开发者ID:diorahman,项目名称:opensplice,代码行数:37,代码来源:gapi_kernel.c

示例7: connect_callback

static void ICACHE_FLASH_ATTR connect_callback(void * arg)
{
	PRINTF("Connected\n");
	struct espconn * conn = (struct espconn *)arg;
	request_args * req = (request_args *)conn->reverse;

	espconn_regist_recvcb(conn, receive_callback);
	espconn_regist_sentcb(conn, sent_callback);

	const char * method = "GET";
	char post_headers[32] = "";

	if (req->post_data != NULL) { // If there is data this is a POST request.
		method = "POST";
		os_sprintf(post_headers, "Content-Length: %d\r\n", strlen(req->post_data));
	}

	char buf[69 + strlen(method) + strlen(req->path) + strlen(req->hostname) +
			 strlen(req->headers) + strlen(post_headers)];
	int len = os_sprintf(buf,
						 "%s %s HTTP/1.1\r\n"
						 "Host: %s:%d\r\n"
						 "Connection: close\r\n"
						 "User-Agent: ESP8266\r\n"
						 "%s"
						 "%s"
						 "\r\n",
						 method, req->path, req->hostname, req->port, req->headers, post_headers);

	if (req->secure)
		espconn_secure_sent(conn, (uint8_t *)buf, len);
	else
		espconn_sent(conn, (uint8_t *)buf, len);
	os_free(req->headers);
	req->headers = NULL;
	PRINTF("Sending request header\n");
}
开发者ID:guijianfeng,项目名称:esphttpclient,代码行数:37,代码来源:httpclient.c

示例8: connect_callback

static void ICACHE_FLASH_ATTR connect_callback(void * arg)
{
	HTTP_DEBUG("Connected\n");
	struct espconn * conn = (struct espconn *)arg;
	request_args * req = (request_args *)conn->reverse;

	espconn_regist_recvcb(conn, receive_callback);
	espconn_regist_sentcb(conn, sent_callback);

	const char * method = "GET";
	char post_headers[128] = "";

	if (req->post_data != NULL) { // If there is data this is a POST request.
		method = "POST";
		os_sprintf(post_headers,
				   "Content-Type: application/x-www-form-urlencoded\r\n"
				   "Content-Length: %d\r\n", strlen(req->post_data));
	}

	char buf[2048];
	int len = os_sprintf(buf,
						 "%s %s HTTP/1.1\r\n"
						 "Host: %s:%d\r\n"
						 "Connection: close\r\n"
						 "User-Agent: ESP8266\r\n"
						 "%s"
						 "\r\n",
						 method, req->path, req->hostname, req->port, post_headers);

	sint8 espsent_status = espconn_sent(conn, (uint8_t *)buf, len);
	if(espsent_status == ESPCONN_OK) {
		HTTP_DEBUG("Data sent, buf = %s\n", buf);
	} else {
		HTTP_DEBUG("Error while sending data.\n");
	}
	HTTP_DEBUG("Sending request header\n");
}
开发者ID:iotcafe,项目名称:esp8266-devkit,代码行数:37,代码来源:httpclient.c

示例9: cgiEnv

int ICACHE_FLASH_ATTR cgiEnv(HttpdConnData *connData) {
	char buff[2048];
	int len=0;

	httpdStartResponse(connData, 200);
	httpdHeader(connData, "Content-Type", "application/json");
	httpdHeader(connData, "Access-Control-Allow-Origin", "*");
	httpdEndHeaders(connData);

	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	//os_strcpy(buff, "Unknown");
	//os_strcpy(temp, "N/A");
	//os_strcpy(humi, "N/A");

	len=httpdFindArg(connData->getArgs, "param", buff, sizeof(buff));
	if (len>0) {
		if(os_strcmp(buff,"temp")==0) {
			len=os_sprintf(buff, "%d",tempF);
			httpdSend(connData, buff, -1);
			tempF = tempF - 2;
			hudP = hudP + 2;
			os_printf("\nTemp val = %d\n",tempF);
		}
		if(os_strcmp(buff,"hud")==0) {
			len=os_sprintf(buff, "%d",hudP);
			httpdSend(connData, buff, -1);
			hudP = hudP - 2;
			tempF = tempF + 2;
			os_printf("\nHud val = %d\n",hudP);
		}
	}
	return HTTPD_CGI_DONE;
}
开发者ID:richcj10,项目名称:USA-FW-IoT,代码行数:37,代码来源:env.c

示例10: tc_read

i2c_status ICACHE_FLASH_ATTR tc_read(i2c_config *config) {
	tc_config_data *config_data = (tc_config_data *)config->data;
	i2c_master_start();

	/* Send address */
	i2c_master_writeByte(config->address << 1 | 0);
	if (i2c_master_getAck()) {
		i2c_master_stop();
		return I2C_ADDRESS_NACK;
	}

	/* Send command */
	i2c_master_writeByte(0x21);
	if (i2c_master_getAck()) {
		i2c_master_stop();
		return I2C_DATA_NACK;	
	}

	i2c_master_stop();
	i2c_master_start();
	
	i2c_master_writeByte(config->address << 1 | 1);
	if (i2c_master_getAck()) {
		i2c_master_stop();
		return I2C_ADDRESS_NACK;
	}
	
	uint8 i;
	uint8 data[4];
	for (i=0; i < 4; i++) {
		data[i] = i2c_master_readByte();
		i2c_master_setAck(i == 3);
	}
	i2c_master_stop();
	
	if ((data[2] & 0x01) != 0) {
		return I2C_COMMUNICATION_FAILED;
	}
	
	sint16 d = data[3] * 256 + (data[2] & 0xFC);
	float tf = 0.0625 * d;
	int ti = tf;
	uint16 td = (tf - ti) * 100;
	
	config_data->temperature = d / 4;
	os_sprintf(config_data->temperature_str, "%d.%02d", ti, td);
	
	return I2C_OK;
}
开发者ID:zazolabs,项目名称:ESP8266,代码行数:49,代码来源:mod_tc_mk2.c

示例11: cgiPropLoad

int ICACHE_FLASH_ATTR cgiPropLoad(HttpdConnData *connData)
{
    PropellerConnection *connection = &myConnection;
    
    // check for the cleanup call
    if (connData->conn == NULL)
        return HTTPD_CGI_DONE;

    if (connection->state != stIdle) {
        char buf[128];
        os_sprintf(buf, "Transfer already in progress: state %s\r\n", stateName(connection->state));
        httpdSendResponse(connData, 400, buf, -1);
        return HTTPD_CGI_DONE;
    }
    connData->cgiData = connection;
    connection->connData = connData;

    os_timer_setfn(&connection->timer, timerCallback, connection);
    
    if (connData->post->len == 0) {
        httpdSendResponse(connData, 400, "No data\r\n", -1);
        abortLoading(connection);
        return HTTPD_CGI_DONE;
    }
    else if (connData->post->buffLen != connData->post->len) {
        httpdSendResponse(connData, 400, "Data too large\r\n", -1);
        return HTTPD_CGI_DONE;
    }
    
    if (!getIntArg(connData, "baud-rate", &connection->baudRate))
        connection->baudRate = flashConfig.loader_baud_rate;
    if (!getIntArg(connData, "final-baud-rate", &connection->finalBaudRate))
        connection->finalBaudRate = flashConfig.baud_rate;
    if (!getIntArg(connData, "reset-pin", &connection->resetPin))
        connection->resetPin = flashConfig.reset_pin;
    if (!getIntArg(connData, "response-size", &connection->responseSize))
        connection->responseSize = 0;
    if (!getIntArg(connData, "response-timeout", &connection->responseTimeout))
        connection->responseTimeout = 1000;
    
    DBG("load: size %d, baud-rate %d, final-baud-rate %d, reset-pin %d\n", connData->post->buffLen, connection->baudRate, connection->finalBaudRate, connection->resetPin);
    if (connection->responseSize > 0)
        DBG("  responseSize %d, responseTimeout %d\n", connection->responseSize, connection->responseTimeout);

    connection->file = NULL;
    startLoading(connection, (uint8_t *)connData->post->buff, connData->post->buffLen);

    return HTTPD_CGI_MORE;
}
开发者ID:ParaBump,项目名称:Parallax-ESP,代码行数:49,代码来源:cgiprop.c

示例12: ftoa

void ftoa(double val, char *buff) {
    char smallBuff[16];
    char smallBuff_tmp[16];
    int val1 = (int) val;
    int val2 = (int) (100.0 * val) % 100;
    unsigned int uval2;
    if (val < 0) {
        uval2 = (int) (-100.0 * val) % 100;
    } else {
        uval2 = (int) (100.0 * val) % 100;
    }
    if (uval2 < 10) {
        os_sprintf(smallBuff, "%i.0%u", val1, uval2);
    } else {
        os_sprintf(smallBuff, "%i.%u", val1, uval2);
    }

    if(val2 < 0 && val1 == 0) {
        os_sprintf(smallBuff_tmp, "-%s", smallBuff);
        strcat(buff, smallBuff_tmp);
    } else {
        strcat(buff, smallBuff);
    }
}
开发者ID:candale,项目名称:thermostat,代码行数:24,代码来源:helpers.c

示例13: mod_led_8x8_rgb_preferences_set

LOCAL void ICACHE_FLASH_ATTR mod_led_8x8_rgb_preferences_set() {
	char preferences[WEBSERVER_MAX_VALUE];
	os_sprintf(
		preferences, 
		"{"
			"\"cols\": %d, "
			"\"rows\": %d, "
			"\"Speed\": %d"
		"}",
		mod_led_8x8_cols,
		mod_led_8x8_rows,
		mod_led_8x8_speed
	);
	preferences_set(MOD_LED8x8RGB, preferences);
}
开发者ID:modSwap,项目名称:ESP8266,代码行数:15,代码来源:user_mod_led_8x8_rgb.c

示例14: debug_FlashSvExceptInfo

void ICACHE_FLASH_ATTR
debug_FlashSvExceptInfo(struct rst_info* pInfo)
{
	debug_FlashBufInit();
	uint8 InfoBuf[200];
	os_memset(InfoBuf,0,200);
	//os_sprintf("reason:%d,");
	uint8* ptmp = InfoBuf;
	
	os_sprintf(ptmp,"reset reason:%x\n", pInfo->reason);
	ptmp+=os_strlen(ptmp);
	
	if (pInfo->reason == REASON_WDT_RST ||
		pInfo->reason == REASON_EXCEPTION_RST ||
		pInfo->reason == REASON_SOFT_WDT_RST) {
		if (pInfo->reason == REASON_EXCEPTION_RST) {
			os_sprintf(ptmp,"Fatal exception (%d):\n", pInfo->exccause);
			ptmp += os_strlen(ptmp);
		}
		os_sprintf(ptmp,"debug_version:%d\r\n",FlashDebugBufParam.DebugVersion);
		ptmp+=os_strlen(ptmp);
		os_sprintf(ptmp,"epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\r\n",
				pInfo->epc1, pInfo->epc2, pInfo->epc3, pInfo->excvaddr, pInfo->depc);
		ptmp+=os_strlen(ptmp);
	}

	int len = os_strlen(InfoBuf);
	uint8 pad_len = 0;
	if(len%4 != 0){
		pad_len = 4 - (len%4);
	    os_memcpy(ptmp,"   ",pad_len);
	}
	len += pad_len;
		
	debug_PrintToFlash(InfoBuf,len);
}
开发者ID:StephanHaag,项目名称:esp8266-devkit,代码行数:36,代码来源:user_debug.c

示例15: WpaCore_StartWpsPIN

S32 WpaCore_StartWpsPIN(THandle hWpaCore)
{
	TWpaCore* pWpaCore = (TWpaCore*)hWpaCore;
	S8 cmd[100];

	pWpaCore->WpaSupplParams.WscMode = WSC_MODE_PIN;

#ifdef SUPPL_WPS_SUPPORT
	os_sprintf(cmd, "WPS_PIN any");

	IpcWpa_Command(pWpaCore->hIpcWpa, cmd, TRUE);
#endif
	
	return OK;
}
开发者ID:chambejp,项目名称:hardware,代码行数:15,代码来源:wpa_core.c


注:本文中的os_sprintf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。