Ejemplo n.º 1
0
bool system_fileTransfer(system_file_transfer_t* tx, void* reserved)
{
    bool status = false;
    Stream* serialObj = tx->stream;

    if (NULL != Ymodem_Serial_Flash_Update_Handler)
    {
        status = Ymodem_Serial_Flash_Update_Handler(serialObj, tx->descriptor, NULL);
        SPARK_FLASH_UPDATE = 0;
        TimingFlashUpdateTimeout = 0;

        if (status == true)
        {
            if (tx->descriptor.store==FileTransfer::Store::FIRMWARE) {
                serialObj->println("Restarting system to apply firmware update...");
                HAL_Delay_Milliseconds(100);
                HAL_Core_System_Reset();
            }
        }
    }
    else
    {
        serialObj->println("Firmware update using this terminal is not supported!");
        serialObj->println("Add #include \"Ymodem/Ymodem.h\" to your sketch and try again.");
    }
    return status;
}
Ejemplo n.º 2
0
/**
 * Do what is needed to finalize the connection.
 * @return
 */
wlan_result_t wlan_connect_finalize()
{
    // enable connection from stored profiles
    HAL_Delay_Milliseconds(1000);
    HAL_NET_notify_connected();
    INFO("Virtual WLAN connected");
    HAL_NET_notify_dhcp(true);
    return 0;
}
Ejemplo n.º 3
0
void USB_USART_LineCoding_BitRate_Handler(void (*handler)(uint32_t bitRate))
{
    //Init USB Serial first before calling the linecoding handler
    USB_USART_Init(9600);

    HAL_Delay_Milliseconds(1000);

    //Set the system defined custom handler
    SetLineCodingBitRateHandler(handler);
}
Ejemplo n.º 4
0
bool wlan_smart_config_finalize()
{
    if (current_softap_handle) {
        softap_stop(current_softap_handle);
        wlan_disconnect_now();  // force a full refresh
        HAL_Delay_Milliseconds(5);
        wlan_activate();
        current_softap_handle = NULL;
    }
    // if wifi creds changed, then indicate the system should enter listening mode on failed connect
    return wifi_creds_changed;
}
Ejemplo n.º 5
0
/**
 * Waits indefinitely for the given thread to finish.
 * @param thread    The thread to wait for.
 * @return 0 if the thread has successfully terminated. non-zero if the thread handle is not valid.
 */
os_result_t os_thread_join(os_thread_t thread)
{
#if PLATFORM_ID!=10
    while (xTaskIsTaskFinished(thread) != pdTRUE)
    {
        HAL_Delay_Milliseconds(10);
    }
    return 0;
#else
    return -1;
#endif
}
void NeopixelAnimationContext::wait(uint32_t ms, bool *abort) {
    uint32_t start = millis();

    // Provide a default for the abort pointer
    bool dontAbort = false;
    if (!abort) {
        abort = &dontAbort;
    }

    do {
        if (process) {
            process();
        }
        HAL_Delay_Milliseconds(1);
    } while(!(*abort) && millis() - start < ms);
}