示例#1
0
static int wlan_connect(const char *ssid, const char *pass, unsigned char sec_type)
{
    SlSecParams_t secParams = {0};
    long lRetVal = 0;

    secParams.Key = (signed char*)pass;
    secParams.KeyLen = strlen(pass);
    secParams.Type = sec_type;

    lRetVal = sl_WlanConnect((signed char*)ssid, strlen(ssid), 0, &secParams, 0);
    ASSERT_ON_ERROR(lRetVal);

    while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus)))
        _SlNonOsMainLoopTask();   

    SlDateTime_t dateTime= {0};
    dateTime.sl_tm_day =   1;          // Day of month (DD format) range 1-13
    dateTime.sl_tm_mon =   1;          // Month (MM format) in the range of 1-12
    dateTime.sl_tm_year =  1970;       // Year (YYYY format)
    dateTime.sl_tm_hour =  0;          // Hours in the range of 0-23
    dateTime.sl_tm_min =   0;          // Minutes in the range of 0-59
    dateTime.sl_tm_sec =   1;          // Seconds in the range of  0-59

    lRetVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
              sizeof(SlDateTime_t),(unsigned char *)(&dateTime));
    ASSERT_ON_ERROR(lRetVal);

    return 0;
}
示例#2
0
void startApplication(void *pvParameters) {
    // TODO: Change to your SSID and password
    signed char ssid[] = "<wifi ssid>";
    signed char key[] = "<wifi password>";
    SlSecParams_t keyParams;
    keyParams.Type = SL_SEC_TYPE_WPA;
    keyParams.Key = key;
    keyParams.KeyLen = strlen((char *)key);

    initNetwork(ssid, &keyParams);

    // TODO: Set to current date/time (within an hour precision)
    SlDateTime_t dateTime;
    memset(&dateTime, 0, sizeof(dateTime));
    dateTime.sl_tm_year = 2015;
    dateTime.sl_tm_mon = 3;
    dateTime.sl_tm_day = 20;
    dateTime.sl_tm_hour = 12;
    sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (unsigned char *)&dateTime);

    UART_PRINT("\r\n");
    UART_PRINT("[QuickStart] Start application\r\n");
    UART_PRINT("\r\n");

    // TODO: Add Parse code here
}
void wlan_set_current_time (uint32_t seconds_since_2000) {
    timeutils_struct_time_t tm;
    timeutils_seconds_since_2000_to_struct_time(seconds_since_2000, &tm);

    SlDateTime_t sl_datetime = {0};
    sl_datetime.sl_tm_day  = tm.tm_mday;
    sl_datetime.sl_tm_mon  = tm.tm_mon;
    sl_datetime.sl_tm_year = tm.tm_year;
    sl_datetime.sl_tm_hour = tm.tm_hour;
    sl_datetime.sl_tm_min  = tm.tm_min;
    sl_datetime.sl_tm_sec  = tm.tm_sec;
    sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (_u8 *)(&sl_datetime));
}
示例#4
0
static int set_time()
{
    long retVal;

    g_time.tm_day = DATE;
    g_time.tm_mon = MONTH;
    g_time.tm_year = YEAR;
    g_time.tm_sec = HOUR;
    g_time.tm_hour = MINUTE;
    g_time.tm_min = SECOND;

    retVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
                          SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
                          sizeof(SlDateTime),(unsigned char *)(&g_time));

    ASSERT_ON_ERROR(retVal);
    return SUCCESS;
}
示例#5
0
文件: main.c 项目: bmxrt/CC3100
/*!
    \brief This updates the date and time of CC3100

    \param[in]      None

    \return         0 for success, negative otherwise

    \note

    \warning
*/
static _i32 SetTime()
{
    _i32 retVal = -1;
    SlDateTime_t dateTime= {0};

    dateTime.sl_tm_day = DATE;
    dateTime.sl_tm_mon = MONTH;
    dateTime.sl_tm_year = YEAR;
    dateTime.sl_tm_hour = HOUR;
    dateTime.sl_tm_min = MINUTE;
    dateTime.sl_tm_sec = SECOND;

    retVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
                       sizeof(SlDateTime_t),(_u8 *)(&dateTime));
    ASSERT_ON_ERROR(retVal);

    return SUCCESS;
}
示例#6
0
文件: WiFi.cpp 项目: LCPINAGE/Energia
/* This function takes uint16_t arguments for compactness on MSP430 w/ CC3100, but actual SlDateTime_t members are uint32_t.
 */
boolean WiFiClass::setDateTime(uint16_t month, uint16_t day, uint16_t year, uint16_t hour, uint16_t minute, uint16_t second)
{
    if (day < 1 || day > 31 || month < 1 || month > 12 || hour > 23 || minute > 59 || second > 59)
        return false;

    SlDateTime_t dt;
    dt.sl_tm_day = (uint32_t)day;
    dt.sl_tm_mon = (uint32_t)month;
    dt.sl_tm_year = (uint32_t)year;
    dt.sl_tm_hour = (uint32_t)hour;
    dt.sl_tm_min = (uint32_t)minute;
    dt.sl_tm_sec = (uint32_t)second;

    int32_t i = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
                          sizeof(SlDateTime_t), (uint8_t *)&dt);
    if (i != 0)
        return false;
    return true;
}
示例#7
0
//*****************************************************************************
//! setDeviceTimeDate
//!
//! Gets the device time and date
//!
//! Returns: On success, zero is returned. On error, -1 is returned
//!
//****************************************************************************
int setDeviceTimeDate()
{
	int iretVal;
	iretVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (_u8 *)(&dateTime));
	return iretVal;
}
void setBoardTimeDate(SlDateTime_t *dateTime) {
    sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (unsigned char *)dateTime);
}