Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
686516f9
Commit
686516f9
authored
10 years ago
by
Bill Owens
Committed by
Paul Sokolovsky
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
esp8266: Move scan from esp module to network
parent
ea2cc2b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
esp8266/modesp.c
+0
-29
0 additions, 29 deletions
esp8266/modesp.c
esp8266/modnetwork.c
+28
-0
28 additions, 0 deletions
esp8266/modnetwork.c
with
28 additions
and
29 deletions
esp8266/modesp.c
+
0
−
29
View file @
686516f9
...
...
@@ -509,34 +509,6 @@ void error_check(bool status, const char *msg) {
}
}
STATIC
void
esp_scan_cb
(
scaninfo
*
si
,
STATUS
status
)
{
//printf("in pyb_scan_cb: %d, si=%p, si->pbss=%p\n", status, si, si->pbss);
struct
bss_info
*
bs
;
if
(
si
->
pbss
)
{
STAILQ_FOREACH
(
bs
,
si
->
pbss
,
next
)
{
mp_obj_tuple_t
*
t
=
mp_obj_new_tuple
(
6
,
NULL
);
t
->
items
[
0
]
=
mp_obj_new_bytes
(
bs
->
ssid
,
strlen
((
char
*
)
bs
->
ssid
));
t
->
items
[
1
]
=
mp_obj_new_bytes
(
bs
->
bssid
,
sizeof
(
bs
->
bssid
));
t
->
items
[
2
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
channel
);
t
->
items
[
3
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
rssi
);
t
->
items
[
4
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
authmode
);
t
->
items
[
5
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
is_hidden
);
call_function_1_protected
(
MP_STATE_PORT
(
scan_cb_obj
),
t
);
}
}
}
STATIC
mp_obj_t
esp_scan
(
mp_obj_t
cb_in
)
{
MP_STATE_PORT
(
scan_cb_obj
)
=
cb_in
;
if
(
wifi_get_opmode
()
==
SOFTAP_MODE
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
"Scan not supported in AP mode"
));
}
wifi_station_scan
(
NULL
,
(
scan_done_cb_t
)
esp_scan_cb
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
esp_scan_obj
,
esp_scan
);
STATIC
mp_obj_t
esp_status
()
{
return
MP_OBJ_NEW_SMALL_INT
(
wifi_station_get_connect_status
());
}
...
...
@@ -596,7 +568,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_id_obj, esp_flash_id);
STATIC
const
mp_map_elem_t
esp_module_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_esp
)
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_scan
),
(
mp_obj_t
)
&
esp_scan_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_status
),
(
mp_obj_t
)
&
esp_status_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mac
),
(
mp_obj_t
)
&
esp_mac_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_getaddrinfo
),
(
mp_obj_t
)
&
esp_getaddrinfo_obj
},
...
...
This diff is collapsed.
Click to expand it.
esp8266/modnetwork.c
+
28
−
0
View file @
686516f9
...
...
@@ -71,6 +71,33 @@ STATIC mp_obj_t esp_disconnect() {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
esp_disconnect_obj
,
esp_disconnect
);
STATIC
void
esp_scan_cb
(
scaninfo
*
si
,
STATUS
status
)
{
struct
bss_info
*
bs
;
if
(
si
->
pbss
)
{
STAILQ_FOREACH
(
bs
,
si
->
pbss
,
next
)
{
mp_obj_tuple_t
*
t
=
mp_obj_new_tuple
(
6
,
NULL
);
t
->
items
[
0
]
=
mp_obj_new_bytes
(
bs
->
ssid
,
strlen
((
char
*
)
bs
->
ssid
));
t
->
items
[
1
]
=
mp_obj_new_bytes
(
bs
->
bssid
,
sizeof
(
bs
->
bssid
));
t
->
items
[
2
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
channel
);
t
->
items
[
3
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
rssi
);
t
->
items
[
4
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
authmode
);
t
->
items
[
5
]
=
MP_OBJ_NEW_SMALL_INT
(
bs
->
is_hidden
);
call_function_1_protected
(
MP_STATE_PORT
(
scan_cb_obj
),
t
);
}
}
}
STATIC
mp_obj_t
esp_scan
(
mp_obj_t
cb_in
)
{
MP_STATE_PORT
(
scan_cb_obj
)
=
cb_in
;
if
(
wifi_get_opmode
()
==
SOFTAP_MODE
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
"Scan not supported in AP mode"
));
}
wifi_station_scan
(
NULL
,
(
scan_done_cb_t
)
esp_scan_cb
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
esp_scan_obj
,
esp_scan
);
STATIC
const
mp_map_elem_t
mp_module_network_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_network
)
},
// MicroPython "network" module interface requires it to contains classes
...
...
@@ -80,6 +107,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_WLAN
),
(
mp_obj_t
)
&
get_module_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_connect
),
(
mp_obj_t
)
&
esp_connect_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_disconnect
),
(
mp_obj_t
)
&
esp_disconnect_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_scan
),
(
mp_obj_t
)
&
esp_scan_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
mp_module_network_globals
,
mp_module_network_globals_table
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment