-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Bluetooth LE #45
Comments
I just had a look into the current active branch and into the pull request #44 In the current active branch it will be difficult to add the BLE functionality as everything is somehow mixed into the main code. But with the pull request #44 it should be straight forward to write a BleClient module and use it instead of the Telnet/Websocket client. Regarding BLE and WiFi active at the same time, that will most likely not work. I got both working (with some additional functionality) only on a ESP32 Wrover module with additional 4MB PSRAM. A ESP32 Wroom modules do not have enough RAM to run both + the main application. Therefor dynamically switching between BLE and WiFi will be not an easy task. For the start I would make the selection of BLE or WiFi static (compiler option ???) to be able to implement a BLE client module and test it. Once it works the next step would be to select the client with a Basically replace setupWiFi();
setupMDNS();
setupSD();
setupSPIFFS();
setupHTTPSever();
setupTelnet();
setupWebSocket(); With #define WiFiClient 0
#define BleClient 1
Preferences preferences;
preferences.begin("Settings", false);
uint8_t clientType = preferences.getShort("c_type", WiFiClient ); // defaults to WiFi if preference is not set
setupClient(clientType); And then initialize the requested clients within setupClient(). |
Thanks for your thoughts and input on this, it seems like a sensible approach. If I understand correctly, ultimately It could be possible to switch the Wifi off/ BlueTooth on from within the Wifi/web interface? To switch the Bluetooth off/ wifi on from the Android/BlueTooth interface? Either action would trigger a reboot? I can see that some kind of credential/ password system would be nice for changing the mode, otherwise, my carefully calibrated Bluetooth solar node could be turned to Wifi by a third party and battery run down. |
Yes, I recall reading about this limitation.
Adding a build flag would be easy. And could be handled similarly to LoRa pins and OLED pins are with config.h and platformio.ini in the refactor.
This also looks good. Creating a user preferences system is in the plans, and this would be a great reason to start working on it.
@samuk I believe you are correct. You can compile and flash both WiFi +BLE to an ESP32 Wroom, you just can't run both at the same time. So if we have a way of editing the user preferences from either the web gui, android app, or telnet/console interface, it should be possible to trigger a reboot after changing preferences and boot back up into BLE or WiFi mode. |
Good news. I am seeing all messages sent from one node to the other node on the BLE terminal and I can send messages to the other node as well with e.g. Before I dig into the Android application, a few questions: |
hi all, I have been watching this project from afar for awhile now and I am not sure that bluetooth is the correct frequency to use for a "disaster". also if this is only a radio for disaster it wouldn't make sense to try and use it for other things. when disaster comes the first people on the scene are "first responders" but I like to think of them as lifeguards sometimes. the Earth is different all over, I don't believe one single frequency will ever cover the entire planet, and I worry that it is a bad idea to attempt this. I have a handful of ideas about which frequencies would be best for lifeguard.fm and additionally which protocols & modulation scheme but I believe the topic requires further study. I'd be happy to compare notes some time :) |
think about the sharks in the ocean, they use the electromagnetic spectrum, if you muddy up their senses you might get bit! |
@rhodey This is not an approach to replace the LoRa for the communication between nodes. It is an approach to have an alternative to the WiFi connection between the LoRa node and the phone (where you type your messages) by using a BLE connection. BLE is using way less energy, so the batteries of the phone and the LoRa node can last longer. |
I don’t claim to know any of the knitty gritty details, but I do see that you’re trying to make use of the electromagnetic spectrum & y’all seem to be moving too fast to be honest.
the animals did not split up the audio spectrum in one day or one year, slowly over time everyone found a place for themselves.
Humans have no idea where they belong in the electromagnetic spectrum because often we think we got here first. false.
I have thought carefully about this for a number of years and I still do not have all the answers, but they continue to reveal themselves in time.
take care,
— rhodey
…On Tue, Feb 4, 2020 at 6:50 AM, Bernd Giesecke ***@***.***> wrote:
***@***.***(https://github.com/rhodey)
You are misunderstanding what this issue is about.
This is not an approach to replace the LoRa for the communication between nodes.
It is an approach to have an alternative to the WiFi connection between the LoRa node and the phone (where you type your messages) by using a BLE connection. BLE is using way less energy, so the batteries of the phone and the LoRa node can last longer.
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#45?email_source=notifications&email_token=AA2IHLLNGN72CPJ7XJ7WBDDRBFJATA5CNFSM4KKXXTC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKXKRXQ#issuecomment-581871838), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AA2IHLIOFYI5VRIOJK5GSVTRBFJATANCNFSM4KKXXTCQ).
|
@beegee-tokyo sounds like you are making good progress! To address your questions,
This is a point of some contention and confusion as it stands. You can read into this in issue #48.
However, the refactored code works in Strings which creates some difficulty using the real The mesh information you are seeing is probably the routing table, the message structure for that is documented here, https://github.com/sudomesh/disaster-radio/wiki/Protocol#routing-table-packets and could be used to display the routing table in the Android app.
I believe that is the current status because of the aforementioned String-struct issue, that routing table is entirely binary data, whose meaning is lost when converted to a String.
That would be a great start! Yes, currently we just broadcast to all neighboring nodes. The logic exists to route packets. A routed packet extends the header by appending the next hop of the packet to the end of the LoRaLayer2 header. This is documented here, https://github.com/sudomesh/disaster-radio/wiki/Protocol#routed-packets. Unfortunately, the chat app has not been updated to be able to handle routed packets. I have been meaning to revisit the routed packet logic to make it usable in more than the simulation environment. I started writing an update to address #48 but got sidetracked by conceptual issues. I hope to make some progress on it this weekend. |
I have a first version now ready. I need to clean up the source codes now (both ESP32 and Android) and then I will push a merge request for the ESP32 part. I was thinking to put the BLE stuff in a new branch for now. |
Merge request is up #53. Needs more testing. I have a strange error in the callback. When drBleClient.startServer([](BleDrClient *drBleClient) {
radio->connect(new WelcomeMessage())
->connect(new HistoryReplay(history))
->connect(drBleClient); Is called, the client in WelcomeMessage is NULL, but is correct in HistoryReplay and in connect(drBleClient). No idea why. |
Great stuff! I just had a go with it and can confirm it works on the TTG0 V2 boards. My platformio.ini looks like
If anyone fancies installing an unsigned .APK from a random on the internet then there is one here: https://archive.org/download/app-release_202002/app-release.apk The power consumption for these on the TTGO with Bluetooth is now in the region of 100mA, peaking to 160mA when packets are transmitted. This is a ~100mA improvement over the WiFi. |
I will put a signed version of the Android app on Google Play store tomorrow. Please keep me updated with your tests, I had some problems with the BLE connection, but it was very random and seldom. |
Android app is live in Google Play Store DisasterRadio BLE Chatbox. For the power consumption, if you do not need long range, you can try to play with the Right now it is set to maximum TX power, but you can test with lower settings. Possible values: /**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12, /*!< Backward compatibility! Setting to -14dbm will actually result to -12dbm */
ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9, /*!< Backward compatibility! Setting to -11dbm will actually result to -9dbm */
ESP_PWR_LVL_N8 = ESP_PWR_LVL_N6, /*!< Backward compatibility! Setting to -8dbm will actually result to -6dbm */
ESP_PWR_LVL_N5 = ESP_PWR_LVL_N3, /*!< Backward compatibility! Setting to -5dbm will actually result to -3dbm */
ESP_PWR_LVL_N2 = ESP_PWR_LVL_N0, /*!< Backward compatibility! Setting to -2dbm will actually result to 0dbm */
ESP_PWR_LVL_P1 = ESP_PWR_LVL_P3, /*!< Backward compatibility! Setting to +1dbm will actually result to +3dbm */
ESP_PWR_LVL_P4 = ESP_PWR_LVL_P6, /*!< Backward compatibility! Setting to +4dbm will actually result to +6dbm */
ESP_PWR_LVL_P7 = ESP_PWR_LVL_P9, /*!< Backward compatibility! Setting to +7dbm will actually result to +9dbm */
} esp_power_level_t; |
Great work, thanks! |
Yes, can be done. Next version will show active nodes, hops and metrics as well. But I can only test with two nodes, so the list always contains only one node. |
@paidforby a) The routing table sent is not destroyed. But it has a strange format: b) Map information |
a) Interesting. It is good to know that the routing table packet survives the conversion to a string. I believe those additional bytes are due to the msg_id workaround that came with the refactor. See here. Since the routing table comes from LoRaLayer2, it is pushed through same buffer as the chat messages. The refactor treats those messages the same, hence the added bytes. I'm still not sure how that pipe is getting in there since there is no pipe in the routing table message. I need to rewrite the client-server communication so it is consistent across applications. b) You'll love the answer to this. Neither of those are "correct." The first one, The second one, The actual disaster radio mapping web app is stored here https://github.com/sudomesh/disaster-radio-map, that was written by @Juul and I honestly have no idea of the format message are expected in. Based on this snippet, it looks like it may be a json object containing |
👅 I put an issue with a question on the repo of @Juul . For the routing table I might be wrong, because the delimiter sometimes changes from "-" to a 0x81 value. I can catch this in the Android app but if it is really corrupted a refactoring from String to byte[] array might be better. Right now working on a map solution to show known nodes with their location (if they reports them) in the Android app with the BLE connection. Today I succeeded to show my own location on the map, the next days I will add positions of other nodes that report their location. |
Great stuff! Exciting to hear about progress with a map. A further feature request would be to add some (optional) notification sounds, so If I lose BT connection I get a beep, if someone @mentions my nick I get a beep. No idea how hard that is to do? |
Sounds are no big problem I think. It's just some effort to make them user-configurable, but for a start I can stick to the default notification sound of the Android system (which is different on each phone/manufacturer). |
Done. The coordinates are sent every 1 minute if the node is connected to the Android phone via BLE. Sounds are done as well. If someone sends a message with @<YOUR_NICK_NAME>, a notification sound will be played. Need to do some clean-up and then I will update the repo and release a new version on Google Play. |
Oh, and there are more things I need to add. |
Might be interesting to use this map base layer at some point. https://wiki.openstreetmap.org/wiki/Humanitarian_map_style |
Good idea, I forgot about OpenStreetMap. Will check tomorrow. |
Rolled out new version with map functionality and sound notification. The sound notification uses the default notification sound of the phone for messages that start with The map functionality works only with nodes that use the BLE client at the moment as the GPSClient is not implemented yet. As the location message format is not finally defined yet I assumed it is as The maps view is based on OpenStreetMap osmdroid API. By default the app will load the required maps online based on usage. To use an offline map, you have to create a map that is compatible with OSM. You can use e.g. Mobile Atlas Creator (MOBAC) and create a map covering the region you need. At the moment only one map is supported. Read the osmdroid Wiki which map formats are supported, how to create a map and where to store it on your phone. The Wiki says to put the maps into |
Nice, love the new map stuff, very cool. Using the latest from Play store I did get an error when first trying to connect to the TTGO which crashed the app. It was resolved once I installed the OSMdroid app and saved a map to the /storage/emulated path. |
@samuk, good finding. I need to check this. The app should not depend on OSMdroid installed. |
@beegee-tokyo The latest version works for me. Thanks for your work on this, I'll close this ticket now as it's been merged into master. The switching function between BT/ Wifi would be nice to have at some point, but I think this feature request is complete. |
It would be interesting to me to have an Android app that could communicate with Disaster Radio nodes using Bluetooth LE and could:
This App.apk could be distributed locally from the SD card over the Wifi
In the future when the OLED works to read messages, it might be interesting to use a mini bluetooth keyboard to enter messages directly to the device with no phone involved. I don't know if this is feasible, or should influence design decisions now, but I thought I'd mention it.
Presumably, you could only have one Bluetooth 'mode' working at any one time?
The text was updated successfully, but these errors were encountered: