Prevent edit in arduino ide to prevent cheating - arduino

I'm developing web based game based on Wemos d1 Mini, and for users to enter their wifi address so that it connect to WiFi, I have to provide the arduino sketch.
To avoid cheating, is there way to disable section of code to be edited or lock some variables so that it cannot be changed in arduino IDE?
Thanks in advance.

No, but you can provide other means of entering configuration data.
ESP can emulate EPROM, or you can read from Serial/LittleFS/SPIFFS before you establish a WiFi connection.
If the user has access to your source code, there's no "cheating", that's improving your code. :)

There are many ways to not have your user edit the sketch to enter WIFI credentials.
To name the most obvious
have them entered via serial interface
have them provided via a file on a SD card for example
have them entered using some kind of user interface
use WPS
about the anti-cheat stuff I suggest you do some further research how things can be approached. this cannot be answered given the provided information

You start by creating an access point with set SSID/password users should receive from you and you also create a web server to accept user's credentials for their WiFi network. You can do that using a GET string or create a page with fields.
Once credentials entered by the user you store it in flash or EEPROM or whatever facilities exists, and you reboot the device.
When device starts it checks the credentials and tries to connect, if it fails you go back to the access point and web server stage.

Related

Failed to make requests to ESP8266 Webserver from an android app

So I have an ESP device that is connected to my WiFi network. It runs a web server and now I want to make requests to this webserver from my android app. So I tried a couple of things and none got satisfied.
Things I tried and why not suitable for me.
Setting up mDNS:
Can't use it since android doesn't really do mDNS it fails in the lookup.
Setting a Static IP:
This approach will fail if the routers' gateway is changed. (at least that's what I believe).
(Can anyone elaborate on this ^. AFAIK if you want to make a static IP you need to match the given gateway with your router's gateway, So if I configured esp board for my router, it might not work with someone else's router.)
Setting a WebSocket connection:
To do this also need the hostname which is IP again.
Asking IP from user:
Since this is going to be a product I can't ask the user to provide the IP address in the mobile application. It leads to a lack of user experience.
I still hope that there should be another way of handling this case which I'm not aware of. I'm actually dying to get this done and I need you guys to help me with this.
It sounds like you are over complicating stuff here.
Step 1. Connect esp board to your wifi (i guess you have figured this out)
step 2. check what lan address your board has connected to, for this is usually just use
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
step 3. start your wifiserver at port 80
WiFiServer(80);
step 4. in your android app, or any other platform(i recommend using browser in computer while simply testing if it works or not) type url: local_ip_address_that_you_got_above/mygetrequest?value1=1
step 5. Listen for incoming clients and intercept the get value that you will recieve in the header in fashion of "GET /mygetrequest?value1=1"
step 6. done :)
If you want to skip the process of implementing all of it from scratch you can get full source code of my example server described above at: https://spacerival.com/lounge/2614/arduino-server but i do highly suggest you to implement it on your own and not just copy paste that source code, since you wont learn much at all to be fair
So after trying all day long, I came with a solution. This is a bit of a workaround as I was lost. So What I did was I created a Soft AP with a small web server that returns the LocalIP. So my esp is working on both AP and STA modes right now.
How it works is simple
ESP runs with a small webserver with /getLocalIP endpoint.
ESP opens a SoftAP for the user to connect. The user connects with the
SoftAP.
The user will be asked to enter credentials for the desired
WiFi.
After connecting to the desired WiFi mobile app will request a
for 192.168.4.1/getLocalIP (AP's IP Address).
Since ESP is already connected to the WiFi this endpoint will send the WiFi.localIP() to the app.
So now the app has the LocalIP.

how get the images from the flying drone to the phone or cloud

we are doing a project on image processing using a camera,raspberry pi3 and a gsm module. Above mentioned things are with a flying drone. I can send a notification message to a mobile using gsm module if required object detected on the cam. But we store that image to view on a webpage or through a mobile app easily. while it's flying it can't connect to the internet. So can you suggest a solution to get those images when it is inside our home wifi range.(any how we can get the images from sd card but i need to get those as soon as possible it detected the wifi) . Thanks in advance
You could consider using "tethering", a.k.a. "Personal Hotspot" in Apple parlance, on your mobile phone.
Basically, you would enable the Personal Hotspot on your iPhone and allow your RPi to connect to it via Wifi. You would have to check your setup, but my iPhone takes IP address 172.20.10.1 for itself and dishes out IP addresses to clients which are the same but with the 1 replaced by a small number under 13.
You can see from here how to setup your RPi to automagically connect to your Hotspot whenever in range. You could also consider fixing a static IP address when on that network, so you know where the RPi will show up for sure.
You would then ensure that Apache, or maybe lighttpd which is lighter weight, is running on your RPi.
Then, your app on the RPi would store its image as image.jpg in Apache's DOCUMENT_ROOT directory, probably /var/www/html/image.jpg but check.
Now, on the iPhone, start Safari and browse to:
http://172.20.10.N/image.jpg
where N is a small number. You should see your image and be able to save it to DropBox or Photos or iCloud Drive for others to see.
Of course, once your RPi is connected to your iPhone's hotspot, it can FTP or ssh copy the image to any website or other server on the Internet it has access to itself.
I have understood your question also I have cheapest solution to build your project. you will be needing 3 modules
ESP8266 (Wifi module)
SD card logger
Camera module(go with your choice, try ESP8266(But I have not tried it))
Combining all these can get your work done. But most instructing part is When connected with wifi it should transmit video to webpage or app and when not connected should log video to SD card
Below is my try to solve your problem, if you have any doubts feel free to ask your question.
ESP8266 is an WiFi module, you can connect it with an hot-spot or an router, similar to any WiFi device's on successful connection it throws 200,OK failing will throw 404 or so. Technically just like any TCP devices it will work. You can connect, disconnect, send and receive data continuously using software(using code you write).
0-code for camera unit starts
1-try connecting WiFi && start the camera and start logging into SD card //InCase if WiFi module takes longer time than usual to connect, this will prevent data from losing
2-if connection failed - continue writing to SD card
3-else(connection made) - start streaming the data && stop the SD card logging and save the file and create a new empty file so that we can save on next connection out without wasting data.
4-check for connection status in regular interval (goto step2).
5-on any external inputs(like click an image)
most important thing: code for your camera interface should work independent from the flight controller code.
-NandhaFrost

HM-10/CC41 talk to BLE server

I've done a lot of searching but have yet to find any examples of the data format for accessing a simple BLE characteristic. I have a CC41 (HM-10 clone) that I have set to master mode and successfully connected to a BLE server device using a PC terminal program and the AT commands. I now want to send the proper data to access a service such as Immediate Alert (0x1802) and it's Alert Level characteristic (0x2A06). I know the full service and characteristic UUIDs and the data value for turning the alert on/off. I can do so from the nRF phone app but it doesn't tell me the data protocol that is actually sent from the app. I assume that the UUID needs to be sent as hex data, not a string, but nothing I've tried so far works. If the phone app can do it, then I would think that I can do it manually as well. Any ideas?

specifying connection on ESP8266 with AP and STA modes

I want to try to set up an ESP8266 (using the Arduino IDE) to occasionally connect to a wifi SSID to send telemetry back. I also would really like to be able to have it running a softAP for configuration/settings purposes. (i.e. so if you want to change internal settings in your code, you can connect directly to the device to access a web form to do so)
The problem is, I am not 100% sure how I know which is which when making an outgoing telemetry json query. I want it to go out on the STATION mode connection. Presumably in most cases the AP mode won't be connected, but there may be rare instances where both are connected at the same time. Thus how do I tell the device to specifically use the STA side of things when it needs to send data back over the internet?
I can't even seem to find any specific examples to ask if one or the other is connected. (you can poll WiFi.status() but - which one is it reporting?)
Any help is appreciated

GATT Profile for a BLE device (server) that switches on/off a LED

Not sure if to posted this on SO.
I'm looking at pretty simple BLE Device. It has a two LEDS (to simplify) that can be switched on or off.
While browsing the GATT profiles, i can't find which profile i should use. Most of them send something back (like a temerature) to the client (upon request).
I need the opposite: switch something on/off of the BLE decive (server). In my case, the client (a iPhone) would send a command to switch on/off LED-1 or LED -2.
What service profile i should use?
Thanks.
I'm using the nRF8001 development kit & nRF Studio for making the services.h
If the LED's are just to be turned on/off there probably isn't any specific profile that they belong to. You probably need to know the handle and write directly to the attribute some value that maps to on or off. Maybe you can figure it out by listing all attribute characteristics. (unfortunately I don't know how to do that specifically on the iPhone)
I noticed that you are using the nRF8001 development kit. So, first thing you need to check is whether the LEDs are connected to IO port of the micro-controller on the kit or directly connected to IO port on BLE chip.
If it connected to micro-controller on the kit then you need to program the kit to handle the received bluetooth data to control led. (It would have a high chance it is in this situation)
If it connected to BLE chip, it means you need to program the ble chip first.
Usually, useful GATT profiles are user specified. It means you need to define the profile yourself. And, I believe some part of the kit or the studio would allow you to do modifications to the profile.
There is only one default GATT profile you should use -- GAP which is to define the defaults like name of the ble device. The others usually are user self-defined profiles.

Resources