I keep getting this error on my iOS webrtc app using the webrtc when I take the sdp and try to set it as remote description. I've tried adjusting the sdp cause I thought it wasn't able to parse the string but it didn't work.
peerConnection = prepareNewConnection();
peerConnection.setRemoteDescription(sdp) { (Error) in
if Error != nil{
print("sdp creation error: \(String(describing: Error!.localizedDescription))")
}
}
In a production setup, randomly a opensips error comes up indicating tls_read failed due to SSL_error_SSL error.
Opensips fails the tls/tcp session and a new session is created and it works fine.
Please provide any pointers on why tls_read would fail with ssl_error_ssl return code.
Opensips code invokes,
ssl = c->extra_data;
ret = SSL_read(ssl, buf, len);
if (ret >0)
{
}
else
{
err = SSL_get_error(ssl, ret);
switch (err) {
case SSL_ERROR_ZERO_RETURN:
LM_INFO("TLS connection to %s:%d closed cleanly\n",
ip_addr2a(&c->rcv.src_ip), c->rcv.src_port);
/*
* mark end of file
*/
c->state = S_CONN_EOF;
return 0;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
return 0;
case SSL_ERROR_SYSCALL:
LM_ERR("SYSCALL error -> (%d) <%s>\n",errno,strerror(errno));
default:
LM_ERR("TLS connection to %s:%d read failed\n", ip_addr2a(&c->rcv.src_ip), c->rcv.src_port);
LM_ERR("TLS read error: %d\n",err);
c->state = S_CONN_BAD;
tls_print_errstack();
return -1;
}
I want to highlight that TLS connection was established fine and a message is successfully received and send. When the second message is received and SSL_read is invoked there is below error,
2018-05-11T11:23:16.000-04:00 [local2] [err] ffd-alpha-zone1-ccm1.ipc.com /usr/sbin/opensipsInternal[10325]: ERROR:core:_tls_read: TLS connection to 10.204.34.62:51519 read failed
2018-05-11T11:23:16.000-04:00 [local2] [err] ffd-alpha-zone1-ccm1.ipc.com /usr/sbin/opensipsInternal[10325]: ERROR:core:_tls_read: TLS read error: 1
2018-05-11T11:23:16.000-04:00 [local2] [err] ffd-alpha-zone1-ccm1.ipc.com /usr/sbin/opensipsInternal[10325]: ERROR:core:tls_print_errstack: TLS errstack: error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned
In the pcap, there is re-transmission of every tls packet both sides and when this packet is read, there seems the packet is the second portion of fragemented packet.
Thanks,
I tried modifying the basic Arduino code from here in order to send HTTP Requests to AWS API Gateway. While the example code from the link worked, I was not able to get a successful connection with AWS API Gateway.
I have tried a combination of things such as removing the https:// from server[], changing the port to 443 instead of 80, removing the /beta from server[], using client.connectSSL instead of client.connect, but none of these have worked so far.
The line:
int err = client.connect(server, 80);
returns me a value of 0.
There are no certificates set up with the AWS API Gateway, so I don't think it's a problem with that. Wifi works perfectly.
Any help would be greatly appreciated!
#include <SPI.h>
#include <WiFi101.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or
use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
char server[] = "https://**********.execute-api.us-west-2.amazonaws.com/beta"; // name address for Google (using DNS)
WiFiClient client;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWiFiStatus();
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
int err = client.connect(server, 80);
Serial.println(err);
if (err) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /beta HTTP/1.1");
client.println("Host: https://**********.execute-api.us-west-2.amazonaws.com");
client.println("Connection: close");
client.println();
}
}
void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.write(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.stop();
// do nothing forevermore:
while (true);
}
}
void printWiFiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
Tips:
(1) client.connect(fqdn, port) is expecting an FQDN for the first parameter
The example in the docs is client.connect("Arduino.cc", 80) this seems to work well in my tests. The docs say "URL" but they mean FQDN.
(2) If you need SSL then you MUST load up your certs using the firmware updater
first. If you are using non-standard pins for the WiFi101 board then you MUST use wifi.setPins() to set the pins or the firmware updater will fail. Adafruit Feather M0 1500 owners will know what I am talking about here.
Reference: https://www.arduino.cc/en/Reference/WiFi101ClientConnect
I hope this helps.
I am trying the sample for the GPS driver with a raspberry pi 3 and the Ultimate GPS V3 breakout board.
Here is the full source code: https://github.com/androidthings/drivers-samples/tree/master/gps
The GPS board is connected following this schematics:
When launching the sample app, I get the following error:
com.example.androidthings.driversamples E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.driversamples, PID: 1299
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:508)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:142)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.processBuffer(NmeaGpsModule.java:178)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.readUartBuffer(NmeaGpsModule.java:160)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.access$000(NmeaGpsModule.java:35)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule$1.onUartDeviceDataAvailable(NmeaGpsModule.java:139)
at com.google.android.things.pio.UartDevice$UartDeviceCallbackDispatch.dispatchInterruptEvent(UartDevice.java:507)
at com.google.android.things.pio.CallbackDispatch.onFileDescriptorEvents(CallbackDispatch.java:127)
at android.os.MessageQueue.dispatchEvents(MessageQueue.java:282)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Update 1
After enabling the debug in the contrib-driver project, I see a new error: W/NmeaParser: Invalid checksum (62), expected 108
12-28 17:53:28.638 1378-1378/com.example.androidthings.driversamples D/XXX: Debug version used
12-28 17:53:29.451 1378-1378/com.example.androidthings.driversamples I/Choreographer: Skipped 34 frames! The application may be doing too much work on its main thread.
12-28 17:53:29.862 1378-1378/com.example.androidthings.driversamples W/NmeaParser: Invalid checksum (62), expected 108
12-28 17:53:29.862 1378-1378/com.example.androidthings.driversamples D/XXX: Buffer reset
12-28 17:53:30.427 1378-1378/com.example.androidthings.driversamples D/AndroidRuntime: Shutting down VM
12-28 17:53:30.428 1378-1378/com.example.androidthings.driversamples E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.driversamples, PID: 1378
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:508)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:142)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.processBuffer(NmeaGpsModule.java:179)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.readUartBuffer(NmeaGpsModule.java:161)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule.access$000(NmeaGpsModule.java:35)
at com.google.android.things.contrib.driver.gps.NmeaGpsModule$1.onUartDeviceDataAvailable(NmeaGpsModule.java:140)
at com.google.android.things.pio.UartDevice$UartDeviceCallbackDispatch.dispatchInterruptEvent(UartDevice.java:507)
at com.google.android.things.pio.CallbackDispatch.onFileDescriptorEvents(CallbackDispatch.java:127)
at android.os.MessageQueue.dispatchEvents(MessageQueue.java:282)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
12-28 17:53:30.439 1378-1378/com.example.androidthings.driversamples I/Process: Sending signal. PID: 1378 SIG: 9
Update 2
After increasing the buffer size by 4, I was able to get few messages in. I see some messages have some junk that would explain the overflow:
12-28 23:38:17.393 2366-2366/? D/XXX: message: ��GPGGA,233817.000,3742.1931,N,12208.3976,W,1,04,1.96,164.3,M,-25.5,M,,*58
12-28 23:38:17.394 2366-2366/? D/XXX: Buffer reset
12-28 23:38:17.394 2366-2366/? D/XXX: message: GPGSA,A,3,23,03,26,22,,,,,,,,,2.20,1.96,1.00*0B
12-28 23:38:17.395 2366-2366/? D/XXX: Buffer reset
12-28 23:38:17.544 2366-2366/com.example.androidthings.driversamples D/XXX: message: GP��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������RMC,233817.000,A��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������,3742.1931,N,12208.3976,W,0.42,205.67,281216,,,A*71
12-28 23:38:17.545 2366-2366/com.example.androidthings.driversamples D/XXX: Buffer reset
12-28 23:38:17.545 2366-2366/com.example.androidthings.driversamples D/XXX: message: GPVTG,205.67,T,,M,0.42,N,0.78,K,A*32
12-28 23:38:17.546 2366-2366/com.example.androidthings.driversamples D/XXX: Buffer reset
I have no idea where that junk could come from...
In some cases processBuffer() will process the whole buffer (512 bytes) regardless of how many bytes are read from the UART. If it happens to miss a start or end character you can end up with a lot of '0' in the message buffer. You can modify this to be like this:
int count;
while ((count = uart.read(buffer, buffer.length)) > 0) {
processBuffer(buffer, count);
}
then modify this to be more like this:
private void processBuffer(byte[] buffer, int length) {
for (int i = 0; i < length; i++) {
if (mParser.getFrameStart() == buffer[i]) {
handleFrameStart();
} else if (mParser.getFrameEnd() == buffer[i]) {
handleFrameEnd();
} else {
//Insert all other characters into the buffer
mMessageBuffer.put(buffer[i]);
}
}
}
Then you won't be filling the message buffer with garbage if an end character gets dropped. I noticed this happening in a project I'm working on that uses this source code. The readUartBuffer() method can read split messages, i.e., the start or end of a message. If it does, bad things happen.
Looking at the demo code https://github.com/androidthings/drivers-samples/blob/master/gps/src/main/java/com/example/androidthings/driversamples/GpsActivity.java#L35 the Baud rate is set correctly as per the data sheet: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps.pdf
And looking at the contrib-driver for NmeaGpsModule the message buffer length is twice the size of the buffer read from the driver https://github.com/androidthings/contrib-drivers/blob/master/gps/src/main/java/com/google/android/things/contrib/driver/gps/NmeaGpsModule.java#L169 so it can't overflow with just one read.
A theory for the issue could be that the message buffer is not being cleared after it receives data - therefore you get a BufferOverflowException after a few packets.
The buffer is reset in 2 places:
When a new frame starts:
https://github.com/androidthings/contrib-drivers/blob/master/gps/src/main/java/com/google/android/things/contrib/driver/gps/NmeaGpsModule.java#L187
Or when a frame ends:
https://github.com/androidthings/contrib-drivers/blob/master/gps/src/main/java/com/google/android/things/contrib/driver/gps/NmeaGpsModule.java#L209
I don't have the hardware to debug your issue, however I can recommend how you could do it:
This goes for anyone wanting to debug a contrib-driver
Fork / Make a copy of this android library: https://github.com/androidthings/contrib-drivers/tree/master/gps
Edit the build.gradle to add this dependency: https://github.com/novoda/bintray-release (follow the README for instructions).
Once you add that dependency the build.gradle will look like this:
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release' // new code
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
minSdkVersion 24
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.4.0' // new code
}
}
dependencies {
compile 'com.android.support:support-annotations:24.2.0'
provided 'com.google.android.things:androidthings:0.1-devpreview'
}
publish { // new code
userOrg = 'google'
groupId = 'com.google.android.things.contrib'
artifactId = 'driver-gps'
publishVersion = '0.1-DEBUG'
}
Now you can release your own version of the GPS driver for debugging, but first:
Edit the java files, to add logging. In the NmeaGpsModule.java of your fork/copy, make two changes:
private void init(UartDevice device, int baudRate, Handler handler) throws IOException {
Log.d("XXX", "MY VERSION BEING USED"); // new code
mDevice = device;
mDevice.setBaudrate(baudRate);
mDevice.registerUartDeviceCallback(mCallback, handler);
mParser = new NmeaParser();
}
and
private void resetBuffer() {
Log.d("XXX", "BUFFER BEING RESET"); // new code
mMessageBuffer.clear();
mFrameFlag = false;
}
To release this version run this command in a terminal from the same folder as the build.gradle:
./gradlew clean build bintrayUpload -PdryRun=true
Now you have released a dependency!
Back in your application (in this case the driver-samples) https://github.com/androidthings/drivers-samples/blob/master/gps/build.gradle#L39:
Change the build.gradle to have a different dependency:
compile 'com.google.android.things.contrib:driver-gps:0.1'
becomes
compile 'com.google.android.things.contrib:driver-gps:0.1-DEBUG'
and tell it to look locally for this dependency:
repositories {
mavenLocal()
jcenter()
}
Now rerun the application and you should see your logs! First the sanity log to prove it worked "MY VERSION BEING USED" then the buffer being reset "BUFFER BEING RESET" if the buffer isn't being reset .. you need to check your hard wiring or add more logs to figure out why.
I am trying to emulate a HandsFree device from Mac OS X.
I advertise correctly my SDP service as Handsfree
I can pair my Android phone to my computer which is seen as "HandsFree" device
I can send a couple of AT Commands (AT+BRST, CIND, CMER) to establish a service level connection
I then install an Audio Driver to route all incoming/outgoing sound to/from the device
Unfortunately, it seems that the SCO channel is never opened. My android phone still emits sound (i.e.: when pressing dial pad) on its own speaker.
When going in the sound preferences of Mac OS X, I can see my device as an input/output device but the sound level never change.
Here is my code :
(void)rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel data:(void *)dataPointer length:(size_t)dataLength
{
... STATE MACHINE GOES HERE and SEND AT COMMANDS ...
... AT CMER OK RECEIVED ...
ret = IOBluetoothAddSCOAudioDevice([[rfcommChannel getDevice] getDeviceRef], NULL);
if (ret != kIOReturnSuccess ){
IOBluetoothRemoveSCOAudioDevice([[rfcommChannel getDevice] getDeviceRef]);
NSLog(#"%#", #"Deleting previously audio device");
ret = IOBluetoothAddSCOAudioDevice([[rfcommChannel getDevice] getDeviceRef], NULL);
if (ret != kIOReturnSuccess) {
NSLog(#"%#", #"Can't install Audio Driver");
}
}
Any idea on why the Audio Driver is installed and reported by the system but can't open an SCO connection ?