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
cd021bfe
Commit
cd021bfe
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Fix build issues with (old) CC3000 driver.
Addresses issue #825.
parent
779794a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
stmhal/pybwlan.c
+20
-14
20 additions, 14 deletions
stmhal/pybwlan.c
with
20 additions
and
14 deletions
stmhal/pybwlan.c
+
20
−
14
View file @
cd021bfe
...
...
@@ -47,7 +47,7 @@
#include
"cc3k/wlan.h"
#include
"cc3k/nvmem.h"
mp_obj_t
pyb_wlan_connect
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
pyb_wlan_connect
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
const
char
*
ap
;
const
char
*
key
;
if
(
n_args
==
2
)
{
...
...
@@ -61,11 +61,13 @@ mp_obj_t pyb_wlan_connect(uint n_args, const mp_obj_t *args) {
int
ret
=
wlan_connect
(
WLAN_SEC_WPA2
,
ap
,
strlen
(
ap
),
NULL
,
(
byte
*
)
key
,
strlen
(
key
));
return
mp_obj_new_int
(
ret
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
pyb_wlan_connect_obj
,
0
,
2
,
pyb_wlan_connect
);
mp_obj_t
pyb_wlan_disconnect
(
void
)
{
STATIC
mp_obj_t
pyb_wlan_disconnect
(
void
)
{
int
ret
=
wlan_disconnect
();
return
mp_obj_new_int
(
ret
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_wlan_disconnect_obj
,
pyb_wlan_disconnect
);
mp_obj_t
decode_addr
(
unsigned
char
*
ip
,
int
n_bytes
)
{
char
data
[
64
]
=
""
;
...
...
@@ -76,7 +78,7 @@ mp_obj_t decode_addr(unsigned char *ip, int n_bytes) {
}
else
if
(
n_bytes
==
32
)
{
snprintf
(
data
,
64
,
"%s"
,
ip
);
}
return
mp_obj_new_str
(
(
byte
*
)
data
,
strlen
(
data
),
false
);
return
mp_obj_new_str
(
data
,
strlen
(
data
),
false
);
}
void
decode_addr_and_store
(
mp_obj_t
object
,
qstr
q_attr
,
unsigned
char
*
ip
,
int
n_bytes
)
{
...
...
@@ -85,7 +87,7 @@ void decode_addr_and_store(mp_obj_t object, qstr q_attr, unsigned char *ip, int
static
mp_obj_t
net_address_type
=
MP_OBJ_NULL
;
mp_obj_t
pyb_wlan_get_ip
(
void
)
{
STATIC
mp_obj_t
pyb_wlan_get_ip
(
void
)
{
tNetappIpconfigRetArgs
ipconfig
;
netapp_ipconfig
(
&
ipconfig
);
...
...
@@ -113,9 +115,10 @@ mp_obj_t pyb_wlan_get_ip(void) {
return
net_addr
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_wlan_get_ip_obj
,
pyb_wlan_get_ip
);
uint32_t
last_ip
=
0
;
// XXX such a hack!
mp_obj_t
pyb_wlan_get_host
(
mp_obj_t
host_name
)
{
STATIC
mp_obj_t
pyb_wlan_get_host
(
mp_obj_t
host_name
)
{
const
char
*
host
=
mp_obj_str_get_str
(
host_name
);
uint32_t
ip
;
if
(
gethostbyname
(
host
,
strlen
(
host
),
&
ip
)
<
0
)
{
...
...
@@ -134,8 +137,9 @@ mp_obj_t pyb_wlan_get_host(mp_obj_t host_name) {
ip_data
[
3
]
=
((
ip
>>
24
)
&
0xff
);
return
decode_addr
(
ip_data
,
4
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_wlan_get_host_obj
,
pyb_wlan_get_host
);
mp_obj_t
pyb_wlan_http_get
(
mp_obj_t
host_name
,
mp_obj_t
host_path
)
{
STATIC
mp_obj_t
pyb_wlan_http_get
(
mp_obj_t
host_name
,
mp_obj_t
host_path
)
{
int
port
;
if
(
mp_obj_is_integer
(
host_name
))
{
last_ip
=
(
192
<<
24
)
|
(
168
<<
16
)
|
(
0
<<
8
)
|
(
mp_obj_get_int
(
host_name
));
...
...
@@ -259,7 +263,7 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) {
vstr_add_strn
(
vstr
,
buf
,
ret
);
}
mp_ret
=
mp_obj_new_str
(
(
byte
*
)
vstr
->
buf
,
vstr
->
len
,
false
);
mp_ret
=
mp_obj_new_str
(
vstr
->
buf
,
vstr
->
len
,
false
);
}
closesocket
(
sd
);
...
...
@@ -267,8 +271,9 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) {
return
mp_ret
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
pyb_wlan_http_get_obj
,
pyb_wlan_http_get
);
mp_obj_t
pyb_wlan_serve
(
void
)
{
STATIC
mp_obj_t
pyb_wlan_serve
(
void
)
{
printf
(
"serve socket
\n
"
);
int
sd
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
printf
(
"serve socket got %d
\n
"
,
sd
);
...
...
@@ -340,6 +345,7 @@ mp_obj_t pyb_wlan_serve(void) {
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_wlan_serve_obj
,
pyb_wlan_serve
);
//*****************************************************************************
//
...
...
@@ -415,12 +421,12 @@ void pyb_wlan_init(void) {
wlan_init
(
CC3000_UsynchCallback
,
sendWLFWPatch
,
sendDriverPatch
,
sendBootLoaderPatch
,
ReadWlanInterruptPin
,
WlanInterruptEnable
,
WlanInterruptDisable
,
WriteWlanPin
);
mp_obj_t
m
=
mp_obj_new_module
(
QSTR_FROM_STR_STATIC
(
"wlan"
));
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"connect"
),
mp_
make_function_var
(
0
,
pyb_wlan_connect
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"disconnect"
),
mp_
make_function_n
(
0
,
pyb_wlan_disconnect
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"ip"
),
mp_
make_function_n
(
0
,
pyb_wlan_get_ip
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"get_host"
),
mp_
make_function_n
(
1
,
pyb_wlan_get_host
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"http_get"
),
mp_
make_function_n
(
2
,
pyb_wlan_http_get
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"serve"
),
mp_
make_function_n
(
0
,
pyb_wlan_serve
)
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"connect"
),
(
mp_
obj_t
)
&
pyb_wlan_connect
_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"disconnect"
),
(
mp_
obj_t
)
&
pyb_wlan_disconnect
_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"ip"
),
(
mp_
obj_t
)
&
pyb_wlan_get_ip
_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"get_host"
),
(
mp_
obj_t
)
&
pyb_wlan_get_host
_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"http_get"
),
(
mp_
obj_t
)
&
pyb_wlan_http_get
_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"serve"
),
(
mp_
obj_t
)
&
pyb_wlan_serve
_obj
);
mp_store_name
(
QSTR_FROM_STR_STATIC
(
"wlan"
),
m
);
}
...
...
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