A python tool for at command

costaud
Posts: 138
Joined: Fri Oct 24, 2014 7:40 pm

A python tool for at command

Postby costaud » Sat Jan 03, 2015 3:38 am

This is a python tool which contains the basic at command.
tools_script.rar
(7.57 KiB) Downloaded 600 times


You can use the at command just like a object operation instead of entering serial command each time.

And since it has a class encapsulation, we can control several at object at the same time and interact between these objects.

usage:
step1:run python and import this lib
step2:define a AT object, which is decided by the uart port.
step3:run a single command

This is a ipython sample case:

Code: Select all

In [1]: import at_class as at  #import lib

In [2]: t2=at.at_esp8266(2) #define an instance

In [3]: t2.at_scan_ap()  # use the method
AT+CWLAP
Out[3]:
['+CWLAP:(4,"michael",-82,"78:a1:06:56:7a:0a",1)',
 '+CWLAP:(4,"TP-LINK_1E3B5C",-73,"ec:17:2f:1e:3b:5c",1)',
 '+CWLAP:(0,"ESP_97D3B4",-66,"1a:fe:34:97:d3:b4",1)',
 '+CWLAP:(4,"TP-LINK_648874",-83,"d8:5d:4c:64:88:74",1)',
 '+CWLAP:(4,"han",-92,"f4:3e:61:4f:f6:47",1)',
 '+CWLAP:(3,"NETGEAR",-62,"74:44:01:40:25:f6",11)',
 '+CWLAP:(4,"TP-LINK_3E392E",-45,"94:0c:6d:3e:39:2e",11)',
 '+CWLAP:(4,"TP-LINK_yuzhe",-86,"5c:63:bf:69:3c:fc",6)',
 '+CWLAP:(4,"TP-LINK_C854",-41,"14:75:90:ff:c8:54",11)']

In [4]: t2.at_conn_ap('TP-LINK_3E392E','19881215')
AT+CWJAP="TP-LINK_3E392E",""
conn TP-LINK_3E392E OK
Out[4]: True

In [5]: t2.at_set_mode(3)
AT+CWMODE=3
cur mode 3
set mode--->3 OK
Out[5]: True

In [6]: t2.at_get
t2.at_get_ip          t2.at_get_mode        t2.at_get_softap_info
t2.at_get_mac         t2.at_get_mux

In [6]: t2.at_get_ip(0)
Out[6]: '192.168.1.109'

In [7]: t2.at_get_ip(1)
Out[7]: '192.168.4.1'

In [8]: t2.at
t2.at_conn_ap           t2.at_ipsend            t2.at_set_mode
t2.at_get_ip            t2.at_ipserver          t2.at_set_mux
t2.at_get_mac           t2.at_ipstart           t2.at_set_softap
t2.at_get_mode          t2.at_ipstatus          t2.at_set_tcp_server
t2.at_get_mux           t2.at_quit_ap           t2.at_tcp_client_signle
t2.at_get_softap_info   t2.at_rst               t2.at_udp_client_signle
t2.at_gmr               t2.at_scan_ap           t2.at_udp_server_multi
t2.at_ipclose           t2.at_set_ipmode        t2.at_udp_server_signle


or you can run it directly in the script:

Code: Select all

if __name__ == '__main__':
    at_test = at_esp8266(2)
    at_test.at_set_mode(1)
    at_test2 = at_esp8266(5)
    at_test2.at_set_mode(3)


This script is just an example, you can change it to fit your application.

Have fun!

milesstone
Posts: 143
Joined: Mon Apr 26, 2021 4:50 pm

Re: A python tool for at command

Postby milesstone » Tue May 31, 2022 8:14 pm

I recommend you to download this FM WhatsApp and make your official WhatsApp use even more better.

Uchiha
Posts: 4
Joined: Wed Dec 29, 2021 4:58 pm

Re: A python tool for at command

Postby Uchiha » Mon Sep 05, 2022 9:38 am

Enjoy this classic card game. spider solitaire 2 suit is a very fun card game, I really love the card games on this site, it's always updated with the best new games for you

thiagogo
Posts: 5
Joined: Mon Jan 10, 2022 11:42 am

Re: A python tool for at command

Postby thiagogo » Tue Sep 06, 2022 2:58 pm

This is so amazing, great minds think alike I just wrote a similar post on this topic! You should check it out. run 3

Who is online

Users browsing this forum: No registered users and 3 guests