simple example of scanning wifi AP and sending to geolocation resolver on cloud
Dependencies: mbed-http lr1110 sx12xx_hal
test Wifi geolocation with resolving using HTTP POST.
Use with mbed board with internet access and arduino form factor.
With HTTPS, the RAM requirement is minimum 128Kbytes.
and, use with radio shield for europe
or radio shield for USA
which is programmed with trx
firmware from updater tool.
This project presents to user mbed STDIO serial port at 115200bps, which lets you perform wifi access point scan on LR1110 and send the resulting access point list to a geolocation provider on the cloud.
Use the project by itself to run wifi scan on the serial terminal (at 115200bps), or use with lr1110_wifi_geolocation_device to receive wifi list from remote device (over LoRa) to resolve location of that device using gelocation provider on cloud.
On serial terminal, use ?
question mark to see list of commands. ws
to run wifi scan, or ws p
to wifi scan and resolve location with cloud provider via HTTP POST.
project setup
Edit main.h
to uncomment which geolocation provider you wish to use, and get API key from them:
- google geolocation
- combain geolocation
TODO
others?
(choose one) Put your API key for geolocation provider into the URL in geolocation source file (such asgoogle_geolocation.cpp
orcombain.cpp
)
notice
This project is not using LoRaWAN, instead just LoRa transceiver directly to geolocation provider
network-helper.h@1:4a05f91c9c38, 2021-02-09 (annotated)
- Committer:
- Wayne Roberts
- Date:
- Tue Feb 09 10:49:02 2021 -0800
- Revision:
- 1:4a05f91c9c38
add source files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wayne Roberts |
1:4a05f91c9c38 | 1 | #ifndef _MBED_HTTP_EXAMPLE_H_ |
Wayne Roberts |
1:4a05f91c9c38 | 2 | #define _MBED_HTTP_EXAMPLE_H_ |
Wayne Roberts |
1:4a05f91c9c38 | 3 | |
Wayne Roberts |
1:4a05f91c9c38 | 4 | #include "mbed.h" |
Wayne Roberts |
1:4a05f91c9c38 | 5 | #include "NetworkInterface.h" |
Wayne Roberts |
1:4a05f91c9c38 | 6 | |
Wayne Roberts |
1:4a05f91c9c38 | 7 | /** |
Wayne Roberts |
1:4a05f91c9c38 | 8 | * Connect to the network using the default networking interface, |
Wayne Roberts |
1:4a05f91c9c38 | 9 | * you can also swap this out with a driver for a different networking interface |
Wayne Roberts |
1:4a05f91c9c38 | 10 | * if you use WiFi: see mbed_app.json for the credentials |
Wayne Roberts |
1:4a05f91c9c38 | 11 | */ |
Wayne Roberts |
1:4a05f91c9c38 | 12 | NetworkInterface *connect_to_default_network_interface() { |
Wayne Roberts |
1:4a05f91c9c38 | 13 | printf("[NWKH] Connecting to network...\n"); |
Wayne Roberts |
1:4a05f91c9c38 | 14 | |
Wayne Roberts |
1:4a05f91c9c38 | 15 | NetworkInterface* network = NetworkInterface::get_default_instance(); |
Wayne Roberts |
1:4a05f91c9c38 | 16 | |
Wayne Roberts |
1:4a05f91c9c38 | 17 | if (!network) { |
Wayne Roberts |
1:4a05f91c9c38 | 18 | printf("[NWKH] No network interface found, select an interface in 'network-helper.h'\n"); |
Wayne Roberts |
1:4a05f91c9c38 | 19 | return NULL; |
Wayne Roberts |
1:4a05f91c9c38 | 20 | } |
Wayne Roberts |
1:4a05f91c9c38 | 21 | |
Wayne Roberts |
1:4a05f91c9c38 | 22 | nsapi_error_t connect_status = network->connect(); |
Wayne Roberts |
1:4a05f91c9c38 | 23 | |
Wayne Roberts |
1:4a05f91c9c38 | 24 | if (connect_status != NSAPI_ERROR_OK) { |
Wayne Roberts |
1:4a05f91c9c38 | 25 | printf("[NWKH] Failed to connect to network (%d)\n", connect_status); |
Wayne Roberts |
1:4a05f91c9c38 | 26 | return NULL; |
Wayne Roberts |
1:4a05f91c9c38 | 27 | } |
Wayne Roberts |
1:4a05f91c9c38 | 28 | |
Wayne Roberts |
1:4a05f91c9c38 | 29 | printf("[NWKH] Connected to the network\n"); |
Wayne Roberts |
1:4a05f91c9c38 | 30 | printf("[NWKH] IP address: %s\n", network->get_ip_address()); |
Wayne Roberts |
1:4a05f91c9c38 | 31 | return network; |
Wayne Roberts |
1:4a05f91c9c38 | 32 | } |
Wayne Roberts |
1:4a05f91c9c38 | 33 | |
Wayne Roberts |
1:4a05f91c9c38 | 34 | #endif // _MBED_HTTP_EXAMPLE_H_ |