Edit: I realize that the problem was with the certificate and I was not able to add it to this example. I switch to the esp_http_client, which has a certificate (that did not work for telegram), and in there I use the https examples. I had to change the certificate for it to work, I use the one is used in Universal Telegram Bot for Arduino, and then I was able to communicate with the page via GET, I'm trying to use POST now.
Edit 2: I was able to send the POST request. Here I let the example to communicate with a telegram bot.
I'm trying to communicate to my telegram bot using the https_request example in the ESP-IDF. On the long road I want the ESP32 to send data to the bot, but now I'am just trying to communicate with it. I believe I understand how the example works so I made these changes:
#define WEB_SERVER "https://api.telegram.org"
#define WEB_PORT "443"
#define WEB_URL "https://api.telegram.org/bot<your-bot-token>/getme"
The request from the example is:
static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n"
"Host: "WEB_SERVER"\r\n"
"User-Agent: esp-idf/1.0 esp32\r\n"
"\r\n";
It should respond something like:
{'id': 123456789, 'first_name': 'Test', 'is_bot': True, 'username': 'SlackOverflow', 'can_join_groups': True, 'can_read_all_group_messages': False, 'supports_inline_queries': True}
The error occurs in line 68, with esp_tls_conn_http_new:
E (3110) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2700
E (3120) esp-tls: Failed to open new connection
Note: I just find this example that does HTTPS GET using plain mbedTLS sockets, but don't know if it differs a lot from the example I used.
Note 2: to learn about the example I used these defines and everything worked fine:
#define WEB_SERVER "www.swapi.dev"
#define WEB_PORT "443"
#define WEB_URL "https://swapi.dev/api/people/1/"
Note 3: I have seen that some people use a certificate (like this and this) but I'am not sure what they are or how/when to use it, I believe it is something for https, but I'm not sure.
Thanks.
Related
I have problem with Adafruit_MQTT_Subscribe.
This is some of my code:
mqtt = Adafruit_MQTT_Client(&client, AIO_SERVER2, AIO_SERVERPORT2, aioUsername.getValue(), aioKey.getValue()); trigger = Adafruit_MQTT_Subscribe(&mqtt, feed);
When my feed = "username/feeds/trigger"
aioKey.getValue()); trigger = Adafruit_MQTT_Subscribe(&mqtt, "username/feeds/trigger");
everything is fine, but i want to change the username dynamically. I want to get it from wifiManager parameter.
String topic = String(aioUsername.getValue()) + "/feeds/trigger"; const char* feed = topic.c_str();
If i do that I see "MQTT ERROR: rejected, not a valid topic format" on AdafruitIO dashboard.
Please help.
You can try and use the example ConfigOnDRD_FS_MQTT_Ptr of my ESP_WiFiManager
/****************************************************************************************************************************
This example will open a Config Portal when there is no stored WiFi Credentials or when a DRD is detected.
You can reconfigure to use another pin, such as the convenience FLASH / BOOT button # PIN_D0;.
A password is required to connect to the Config Portal so that only who know the password can access the Config Portal.
The Credentials, being input via Config Portal, will then be saved into LittleFS / SPIFFS file, and be used to connect to
Adafruit MQTT Server at "io.adafruit.com" and publish a Temperature Topic
Based on original sketch posted by "Marko"(https://github.com/wackoo-arduino) on https://forum.arduino.cc/index.php?topic=692108
*****************************************************************************************************************************/
I'm currently trying to implement SASL/EXTERNAL auth for OpenLDAP client written in Golang.
By other words, I want to load the following data:
ldapsearch -Y EXTERNAL -H ldapi:// -s base -b 'olcDatabase={1}mdb,cn=config' olcSyncRepl
I'm using https://github.com/go-ldap/ldap library. Unfortunately, the library supports simple authentication only. I'm happy to implement SASL/EXTERNAL but I could not recognize how the protocol works? For example, there is https://ldap.com/ldapv3-wire-protocol-reference-bind/ CRAM-MD5 authentication process.
I want to get the same explanation for SASL/EXTERNAL.
I connected to the unix socket (ldapi://) successfully. But I don't understand what kind of commands need to send programmatically to complete authentication.
I found the solution.
First of all, you need to connect to the unix socket. Usually, the socket locates on /var/run/slapd/ldapi path.
Then you need to make a simple bind with two changes:
username should be empty
need specify that you want to use sasl authentication
pkt := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
pkt.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
pkt.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
saslAuth := ber.Encode(ber.ClassContext, ber.TypeConstructed, 3, "", "authentication")
saslAuth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "EXTERNAL", "SASL Mech"))
saslAuth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "SASL Cred"))
pkt.AppendChild(saslAuth)
This is the PR https://github.com/go-ldap/ldap/pull/232.
I am doing automation on Firefox OS on a feature phone using merionette in Python.
My problem is I am not able to simulate hardware keyevents for the navigation keys and other selection keys on some applications (in below case name is ApplicationName).
However I am able to use them on native apps.
Below is my code snippet:
#creating marionette client on port 2828
client = Marionette('localhost', port=2828)
client.start_session()
#import js script to launch app by name
js = os.path.abspath("/usr/local/script.js")
client.import_script(js)
result=client.execute_async_script("GaiaApps.launchWithName('%s')" % "ApplicationName")
client.switch_to_frame(result.get("frame"))
num = "123456"
client.find_element('css selector','input[type=text]').send_keys(num)
#Above code is working fine
#below code is not working on some thirdparty applications
client.execute_script("window.dispatchEvent(new KeyboardEvent('keydown', {key: 'ArrowDown', keyCode: 40}))")
#closing the client
client.close
What could be the cause?
Cobalt can default load the URL. We are investigating how to add the DIAL paring code to the URL. Maybe it needs a changeURL API for avoiding re-launching YouTube.
// Restrict navigation to a couple of whitelisted URLs by default.
const char kYouTubeTvLocationPolicy[] =
"h5vcc-location-src "
"https://www.youtube.com/tv "
"https://web-release-qa.youtube.com/tv "
[scenario]
launch YTTV with your remote controller
open YouTube app on your phone
try to pairing to TV
Cobalt currently doesn't implement DIAL smooth-pairing once launched, but it does support being launched with alternate query parameters via the --url= command-line parameter.
For example:
https://www.youtube.com/tv?...anything...
Will pass the navigation whitelist.
Full implementation of smooth-pairing support is planned for Q1 2017.
Is there a way to manually fire existing Xcode bots using shell scripts? I have a manual bot and I'd like to fire it based on certain custom logic criteria.
Yes.
You'll need to do a couple of things:
Firstly, I'm going to call your Xcode Server's IP address XCS_IP, usually localhost if you're on the machine where Xcode Server's running.
Find out the ID of the bot: in Terminal, run curl -k "https://XCS_IP:20343/api/bots". Copy the output to some editor and find the value for key _id for your bot, will be something like 6b3de48352a8126ce7e08ecf85093613. Let's call it BOT_ID.
Trigger an integration by running curl -k -X POST -u "username:password" "https://XCS_IP:20343/api/bots/BOT_ID/integrations" -i
Where username and password are credentials of a user that is allowed to create bots on the server, an admin will do.
If you're interested in more details, I have an app in Swift that uses that API and many more: https://github.com/czechboy0/Buildasaur/blob/master/BuildaCIServer/XcodeServer.swift#L324
And checkout my article on how to find Xcode Server's API "documentation": http://honzadvorsky.com/blog/2015/5/4/under-the-hood-of-xcode-server.
TL;DR? On your Mac, look at /Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcsd/routes/routes.js, where you can find the available APIs.
Hope this helped.
Apple has added documentation for the Xcode server API that you can use to trigger bots.
https://developer.apple.com/library/tvos/documentation/Xcode/Conceptual/XcodeServerAPIReference/index.html#//apple_ref/doc/uid/TP40016472-CH1-SW1
Below is some example code on how you can make a python script that triggers a bot.
import requests
xcodeIP = '1.2.3.4.5'
def main():
botName = "name of bot"
runBot(botName)
def runBot(botName):
requests.post(xcodeIP + '/api/bots/' + getBot(botName)["_id"] + '/integrations', auth=('username', 'password'), verify=False)
def getBot(botName):
botIDRequest = requests.get(xcodeIP + '/api/bots', auth=('username', 'password'), verify=False)
bots = botIDRequest.json()["results"]
for bot in bots:
if bot["name"] == botName:
return bot
if __name__ == "__main__":
main()