コード例 #1
0
int main(void)
{
    /* Do system initialization, eg: hardware, nvdm, logging and random seed. */
    system_init();

    /* bsp_ept_gpio_setting_init() under driver/board/mt76x7_hdk/ept will initialize the GPIO settings
     * generated by easy pinmux tool (ept). ept_*.c and ept*.h are the ept files and will be used by
     * bsp_ept_gpio_setting_init() for GPIO pinumux setup.
     */
    bsp_ept_gpio_setting_init();

    int nvdm_deviceKey_len = sizeof(deviceKey);
    int nvdm_deviceId_len = sizeof(deviceId);
    int nvdm_host_len = sizeof(host);

    nvdm_write_data_item("common", "deviceId", NVDM_DATA_ITEM_TYPE_STRING, (uint8_t *)deviceId, nvdm_deviceId_len);
    nvdm_write_data_item("common", "deviceKey", NVDM_DATA_ITEM_TYPE_STRING, (uint8_t *)deviceKey, nvdm_deviceKey_len);
    nvdm_write_data_item("common", "host", NVDM_DATA_ITEM_TYPE_STRING, (uint8_t *)host, nvdm_host_len);

    wifi_connection_register_event_handler(WIFI_EVENT_IOT_INIT_COMPLETE , _wifi_event_handler);
    wifi_connection_register_event_handler(WIFI_EVENT_IOT_CONNECTED, _wifi_event_handler);
    wifi_connection_register_event_handler(WIFI_EVENT_IOT_PORT_SECURE, _wifi_event_handler);
    wifi_connection_register_event_handler(WIFI_EVENT_IOT_DISCONNECTED, _wifi_event_handler);

    wifi_config.opmode = WIFI_MODE_STA_ONLY;

    strcpy((char *)wifi_config.sta_config.ssid, Ssid);
    wifi_config.sta_config.ssid_length = strlen(Ssid);
    strcpy((char *)wifi_config.sta_config.password, Password);
    wifi_config.sta_config.password_length = strlen(Password);

    xTaskCreate(wifi_initial_task, "User app", 1024, NULL, 1, NULL);

    /* Initialize pwm */
    start_pwm();

    /* Initialize cli task to enable user input cli command from uart port.*/
#if defined(MTK_MINICLI_ENABLE)
    cli_def_create();
    cli_task_create();
#endif

    vTaskStartScheduler();

    /* If all is well, the scheduler will now be running, and the following line
    will never be reached.  If the following line does execute, then there was
    insufficient FreeRTOS heap memory available for the idle and/or timer tasks
    to be created.  See the memory management section on the FreeRTOS web site
    for more details. */
    for ( ;; );
}
コード例 #2
0
void AddVcard_cmd(int arg_cnt, char **args){
	Serial.println("Adding VCARD, please input some persional info, enter to skip or enter data");
	Serial.print("Please input your name(English only..):");
	String name = read_string();
	Serial.print("Please input your phone number:");
	String phone = read_string();
	Serial.print("Please input your EMAIL:");
	String email = read_string();
	Serial.print("Company Name?:");
	String company = read_string();
	Serial.print("Website?:");
	String website = read_string();
	
	Serial.print("linkedin url?:");
	String linkedin = read_string();
	Serial.print("facebook url?:");
	String facebook = read_string();
	Serial.print("twitter url?:");
	String twitter = read_string();
	

	String Vcard;
	Vcard += "BEGIN:VCARD\r\n";
	Vcard += "N:";Vcard += name;Vcard += "\r\n";
	if (company.length() != 0)
	{
		Vcard += "ORG:";Vcard += company;Vcard += "\r\n";
	}
	if (email.length() != 0)
	{
		Vcard += "EMAIL;type=INTERNET;type=WORK;type=pref:";Vcard += email;Vcard += "\r\n";
	}
	if (phone.length() != 0)
	{
		Vcard += "TEL;type=CELL:";Vcard += phone;Vcard += "\r\n";
	}
	if (website.length() != 0)
	{
		Vcard += "item1.URL:";Vcard += website;Vcard += "\r\n";
	}
	
	if (linkedin.length() != 0)
	{
		Vcard += "socialProfile;type=linkedin:";Vcard += linkedin;Vcard += "\r\n";
	}	
	if (facebook.length() != 0)
	{
		Vcard += "socialProfile;type=facebook:";Vcard += facebook;Vcard += "\r\n";
	}		
	if (twitter.length() != 0)
	{
		Vcard += "socialProfile;type=twitter:";Vcard += twitter;Vcard += "\r\n";
	}
	
	Vcard += "END:VCARD";


	Serial.println(Vcard);
	Serial.print("Total Length:");Serial.print(Vcard.length());Serial.println("Bytes");
	if (Vcard.length()>230)
	{
		Serial.println("Length too large, limit is 230 byte");
		return;
	}
	nvdm_status_t status;
    status = nvdm_write_data_item("VCARD", "VCARD",  NVDM_DATA_ITEM_TYPE_STRING , (uint8_t *)Vcard.c_str(),Vcard.length()+1);
    if (status != NVDM_STATUS_OK) {
        Serial.println("Write Error!");
    }
    status = nvdm_write_data_item("VCARD", "Name",  NVDM_DATA_ITEM_TYPE_STRING , (uint8_t *)name.c_str(),name.length()+1);
    if (status != NVDM_STATUS_OK) {
        Serial.println("Write Error!");
    }


}