summaryrefslogtreecommitdiff
path: root/bsp/w60x/oneshot/oneshot.c
blob: 21beeeb90dfb1bc1c9fdf8a89ccacbc26e88feec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author        Notes
 * 2019-01-25     winner micro
 */

#include <rtthread.h>
#include "oneshot.h"
#include "wm_wifi_oneshot.h"
#include "wm_wifi.h"

/* start oneshot */
int wm_oneshot_start(WM_ONESHOT_MODE mode, wm_oneshot_callback callback)
{
    tls_wifi_oneshot_callback_register(callback);
    if(mode == WM_UDP)
    {
        tls_wifi_set_oneshot_config_mode(0);
    }
    else if (mode == WM_APSOCKET)
    {
        tls_wifi_set_oneshot_config_mode(1);
    }
    else if(mode == WM_APWEB)
    {
        tls_wifi_set_oneshot_config_mode(2);
    }
    else
    {
        return -1;
    }
    tls_wifi_set_oneshot_flag(1);
    return 0;
}

/* stop oneshot */
int wm_oneshot_stop(void)
{
    tls_wifi_oneshot_callback_delete();
    tls_wifi_set_oneshot_flag(0);
    return 0;
}

/* get status */
int wm_oneshot_get(void)
{
    return tls_wifi_get_oneshot_flag();
}