No peers provided by network with hyperledger app on android - java

With the Commercial paper tutorial, I continue to try to implement the java application to an Android emulator.
On Issue.java, when call Network network = gateway.getNetwork("mychannel"); an error occur : IllegalArgumentException: No peers provided.
Because of network argument by getChaincodeQueryPeersForOrganization(DefaultQueryHandlers.java:50), he don't give me a collection of peers and cause error on SingleQueryHandler.java:29.
I think about connection-org2.yaml file, but don't see what's wrong.
(Default Java app not work correctly)
How can I give the right network, with correct peers ?
Complete error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: iti.paper.ch.paper_test, PID: 9568
java.lang.IllegalArgumentException: No peers provided
at org.hyperledger.fabric.gateway.impl.query.SingleQueryHandler.<init>(SingleQueryHandler.java:29)
at org.hyperledger.fabric.gateway.DefaultQueryHandlers.lambda$static$0(DefaultQueryHandlers.java:30)
at org.hyperledger.fabric.gateway.-$$Lambda$DefaultQueryHandlers$A9xv6yy6Ls07YnjWxZKkScD7PTQ.create(Unknown Source:0)
at org.hyperledger.fabric.gateway.DefaultQueryHandlers.create(DefaultQueryHandlers.java:73)
at org.hyperledger.fabric.gateway.impl.NetworkImpl.<init>(NetworkImpl.java:54)
at org.hyperledger.fabric.gateway.impl.GatewayImpl.getNetwork(GatewayImpl.java:252)
at iti.paper.ch.paper_test.Issue.main(Issue.java:56)
at iti.paper.ch.paper_test.MainActivity$1.onClick(MainActivity.java:29)

Your SDK uses the connection-org2.yaml to populate the a view of the network to a large degree on the client side. The rest is taken care of by service discovery, should there be any changes subsequently.
Having said that, you should add your channel details in your connection profile (connection-org2.yaml) and specify the roles of the peers. The error that you are seeing is related to the fact that there are no peers defined with chaincode querying roles. You do that by modiying the connection profile and including details similar to this..
channels: //name if the channel
mychannel:
peers:
peer0.org2.example.com:
endorsingPeer: false //this is a role
chaincodeQuery: true //this is a role
discover: true // this is a role
peer1.org2.example.com:
endorsingPeer: false
chaincodeQuery: true
discover: true
Try this and restart your network. Bear in mind that the default scripts will also regenate any connection profles using the template.

Related

Connecting to Azure Iot Hub using TPM

I have successfully provisioned a device in Azure IoT using TPM authentication by following this sample and the following guide: https://learn.microsoft.com/en-us/azure/iot-dps/quick-enroll-device-tpm-java
Now that my device is provisioned I'm trying to figure out the simplest way to connect to the IoT Hub using the keys stored on the TPM chip. I've tried the following code snippet:
SecurityProviderTpm securityClientTPM = new SecurityProviderTPMHsm();
DeviceClient client = DeviceClient.createFromSecurityProvider("myhub.azure-devices.net", "my-device", securityClientTPM, IotHubClientProtocol.HTTPS);
but this fails with:
Exception in thread "main" java.io.IOException: com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException: activateIdentityKey first before signing
at com.microsoft.azure.sdk.iot.device.auth.IotHubSasTokenHardwareAuthenticationProvider.generateSasTokenSignatureFromSecurityProvider(IotHubSasTokenHardwareAuthenticationProvider.java:169)
at com.microsoft.azure.sdk.iot.device.auth.IotHubSasTokenHardwareAuthenticationProvider.<init>(IotHubSasTokenHardwareAuthenticationProvider.java:51)
at com.microsoft.azure.sdk.iot.device.DeviceClientConfig.<init>(DeviceClientConfig.java:192)
at com.microsoft.azure.sdk.iot.device.InternalClient.<init>(InternalClient.java:109)
at com.microsoft.azure.sdk.iot.device.DeviceClient.<init>(DeviceClient.java:284)
at com.microsoft.azure.sdk.iot.device.DeviceClient.createFromSecurityProvider(DeviceClient.java:250)
at samples.com.microsoft.azure.sdk.iot.SendEvent.main(SendEvent.java:88)
Caused by: com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException: activateIdentityKey first before signing
at com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderTPMHsm.signWithIdentity(SecurityProviderTPMHsm.java:371)
at com.microsoft.azure.sdk.iot.device.auth.IotHubSasTokenHardwareAuthenticationProvider.generateSasTokenSignatureFromSecurityProvider(IotHubSasTokenHardwareAuthenticationProvider.java:155)
... 6 more
Searching the SDK code shows that activateIdentityKey is only called during the provisioning process though.
Re-invoking the provisioning proceedure everytime I want to connect the client doesn't seem right. Is there a better way to connect the device to the IoT Hub once it's been provisioned?
I was able to work around this by removing the check in the signWithIdentity function and removing the need to pass the publicArea to the signData function.
The publicArea is only used to derive the hash algorithm which can be set to a constant given that we know how the key was created.
My updated signData function looks like:
private byte[] signData(Tpm tpm, byte[] tokenData) throws SecurityProviderException {
TPM_ALG_ID idKeyHashAlg = TPM_ALG_ID.SHA256;
...
This has been working well for us so far, but it would be nice to get some feedback from the library authors :)

BMP280 ServiceSpecificException: I/O error (code 5)

I try to use AndroidThings to measure temperature with Raspberry Pi 3 and BMP280.
3,3V i have choosed because of specification of BMP280:
To power the board, give it the same power as the logic level of your microcontroller
Then i want to initialize sensor
mTemperatureSensorDriver = new Bmx280SensorDriver("I2C1");
And by execution i receive following exeption
Error configuring sensor
com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I/O error (code 5)
at com.google.android.things.pio.I2cDeviceImpl.readRegByte(I2cDeviceImpl.java:81)
at com.google.android.things.contrib.driver.bmx280.Bmx280.connect(Bmx280.java:215)
at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:193)
at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:180)
at com.google.android.things.contrib.driver.bmx280.Bmx280SensorDriver.<init>(Bmx280SensorDriver.java:55)
Also by 5V Power i receive the same exception.
I have found this. But i have no idea how to check, if the BMP280 is realy connected to Raspberry with adb.
By own testing the connectivity i receive by device.readRegByte(0xD0) the same exeption.
Does it mean, that BMP280 is not correctly connected?
If yes, how to correctly connect BMP280 with Raspberry?
Is some resistor needed by connection?
UPDATE
solved by soldering BMP280 with header strip.
Also to work with sensor is permission requiered that could be granded only in command line. ref
adb shell pm grant app.package com.google.android.things.permission.MANAGE_SENSOR_DRIVERS
Looking at your fritzing diagram you had SDO connected to BCM3?
From the datasheet the SDO pin is what determins the address of your sensor.
Connecting SDO to GND results in slave
address 1110110 (0x76); connection it to VDDIO results in slave address 1110111 (0x77)
Most importantly:
The SDO pin cannot be left floating; if left floating, the
I²C address will be undefined.
com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I/O error (code 5)
Therefore your problem is likely an undefined i2c address.
Looking at the code you are using for the Bmx280SensorDriver, it uses the address 0x77
https://github.com/androidthings/contrib-drivers/blob/master/bmx280/src/main/java/com/google/android/things/contrib/driver/bmx280/Bmx280.java#L48
Therefore you should ensure your SDO line is connected to 5V on your raspberry pi. This will ensure your sensor has the correct address.
Or alternatively connect SDO to Ground and use this constructor:
mTemperatureSensorDriver = new Bmx280SensorDriver("I2C1", 0x76);
If you want to understand what the sensor driver is doing "under the hood" there is a great blog post and repo to see that:
http://blog.blundellapps.co.uk/tut-android-things-temperature-sensor-i2c-on-the-rainbow-hat/
https://github.com/blundell/androidthings-i2c-input/blob/master/app/src/main/java/com/blundell/tut/MainActivity.java
;-)
Thanks for informations, for right connection
bmx280 = new Bmx280("I2C1",0x76); and SDO to gnd.
But read values is strange.
myweatherstation D/statie: temp: 186.83298 pres: -296.47287
Is possible to be sensor damaged?
TNX
Cris
To read data from IoT Device, the contact should be fixed without any loose connection.
This could be only reached with soldering of BMP280 with header strip
Only then the connection could be etablished

Originate call to sip trunk via asterisk manager api java

So I am a total newbie in asterisk and managing call lines in general but I managed to install Asterisk Now 13 distro, I have connected 2 sip phones with pjsip and configured a sip trunk which works when I dial an external number with the corresponding prefix. Now I have to programmaticly originate calls and connect them to local extensions which I have no idea how to achieve and I cant seem to find much information about it on the internet after hours of searching.
I managed to connect 2 local sip phones with the asterisk manager api and OriginateAction in the following way:
originateAction = new OriginateAction();
originateAction.setChannel(ConnectionType+"/"+extCaller);
originateAction.setContext(context);
originateAction.setCallerId(idCaller);
originateAction.setExten(tDestination);
originateAction.setPriority(priority);
originateAction.setTimeout(timeoutCall);
managerConnection.login();
originateResponse = managerConnection.sendAction(originateAction, timeoutRequest);
I also tried this channel originate pjsip/201 extension number#from-ptsn and channel originate local/201#from-local extension number#trunkName .
The context of the PJSIP trunk is from-pstn,I tried using that in various ways without luck both in asterisk cli and the application.
How do I make it use the PJSIP trunk when originating the call and make a call out of the office?
EDIT: I originated an outgoing call using a number that completes with the trunk outgoing route requisites and the "from-internal" context like this:
channel originate Local/201#from-internal extension (prefix)numberToCall#from-internal
I still do not understand why this works and if it is the correct answer to my question.
So the answer is in the edit of the question. The only way to generate an outgoing call that I could find is to originate that call "internaly" (with the context "from-internal" which happens to be the same context that is used when originating internal calls) introducing a target number value that completes with the sip trunk's route pattern requirements.
Example:
I have a route configured for the sip trunk( trunk1 ) with a pattern(RegEx): [0]{1}/number/ that means that with a 0 infront of any nubmer it will be a valid value for that route and it will try to call using trunk1.
In the case of AsteriskNow CentOS installation it happens to be with the context "from-internal". Since the asterisk configuration files are owned by the FreePBX it is recomended to use the FreePBX GUI instead of configuring the .conf files of asterisk manualy.
That concludes to :
channel originate Local/201#from-internal extension (0)[numberToCall]#from-internal
Which will make the extension 201 ring first and when picked up it will try to use the sip trunk to dial that [numberToCall] because the route with the 0 is "called".
In order to send that command to asterisk using asterisk-java I wrote the following code:
ManagerConnectionFactory factory = new
ManagerConnectionFactory("serverIp", "username",
"passwd");
ManagerConnection managerConnection=factory.createManagerConnection()
OriginateAction originateAction=new OriginateAction();
final String randomUUID=java.util.UUID.randomUUID().toString();
System.out.println("ID random:_"+randomUUID);
originateAction.setChannel([connectionType]+"/"+[callerExtension]);<-- SIP or PJSIP / 201(the phone that will ring first)
originateAction.setContext("from-internal"); <-- Default FreePBX context
originateAction.setCallerId([callerId]); // what will be showed on the phone screen (in most cases your phone)
originateAction.setExten([targetExten]); //where to call.. the target extension... internal extension or the outgoing number.. the 0[nomberToCall]
originateAction.setPriority([priority]);// priority of the call
originateAction.setTimeout(timeoutCall); // the time that a pickup event will be waited for
originateAction.setVariable("UUID", randomUUID); // asigning a unique ID in order to be able to hangup the call.

Trying to connect multiple devices via Bluetooth LE to android device

The Problem
I am trying to connect multiple Bluetooth LE devices (heart rate monitors) to my android device. I am able to scan, and connect to them. They stream just fine, just that when I output the notifications it jumps between one sensor's data to another.
I basically used this GitHub source code for a majority of this project. In the project, they use ONE service (called BluetoothLeService). In my project I have created TWO services, pretty much duplicates of each other except one handles calls for one user, the other one handles for the other user.
I'm getting this output onto the console:
07-27 21:14:01.786 9062-9062/com.example.android.aware D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a37-0000-1000-8000-00805f9b34fb enable: true
07-27 21:14:01.786 9062-9062/com.example.android.aware D/BluetoothLeService2: Trying to use an existing mBluetoothGatt for connection. THIS ERROR IS FROM BLS2
07-27 21:14:01.796 9062-10009/com.example.android.aware D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=E3:64:43:37:D2:AA
07-27 21:14:01.796 9062-10009/com.example.android.aware I/BluetoothLeService2: Disconnected from GATT server.
07-27 21:14:01.796 9062-9062/com.example.android.aware D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a37-0000-1000-8000-00805f9b34fb enable: true
07-27 21:14:01.816 9062-9062/com.example.android.aware D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection. THIS ERROR IS FROM BLS1
07-27 21:14:01.826 9062-10009/com.example.android.aware D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=00:22:D0:41:CA:B6
07-27 21:14:01.826 9062-10009/com.example.android.aware I/BluetoothLeService: Disconnected from GATT server.
Attempts
I've tried to add a new CLIENT_CHARACTERISTIC_CONFIG (called it CLIENT_CHARACTERISTIC_CONFIG2) string in the SampleGattAttributes class, this comes to play in the following code snippet (from the service classes):
BluetoothGattDescriptor descriptor = characteristic
.getDescriptor(UUID
.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
I think the problem, like the consoles says, has something to do with the variable in both Services called mBluetoothGatt (which is a BluetoothGatt type object). My thinking is like this:
If I have two services running synchronously, then if I create two different BluetoothGatt objects in each, why am I being told that the same BluetoothGatt object is being used?
I was not see the source code you referred but did you stored the different BluetoothGattCallback or return values for each connection? I mean how did you judge the two devices?
The connectGatt will return a BluetoothGattCallback instance to notify the status or you can use this instance to do further operations, e.g. know the connect status etc.
I solved this problem by outputting data based on address of the device.
So instead of just spitting out the notifications, I put a condition (is the DisplayData() method) that said, "Hey, only output here if this is the device whose output we're looking for here."
Sure, the devices were not time-synched, but when you log using the time, that helps.

Unknown Move Destination: STORESCP

I have just installed dcm4chee4-4.4.0.Beta1, following INSTALL.md instructions and everything works fine except movescu test.
When I run this test I can see an error in standalone/log/server.log (previously I launched in another console storescp -b11115). This is the error:
2015-09-13 12:48:49,105 INFO [org.dcm4che3.net.Association] (pool-6-thread-7) DCM4CHEE<-MOVESCU(7): processing 1:C-MOVE-RQ[pcid=1, prior=0
cuid=1.2.840.10008.5.1.4.1.2.2.2 - Study Root Query/Retrieve Information Model - MOVE
tsuid=1.2.840.10008.1.2 - Implicit VR Little Endian failed. Caused by: org.dcm4che3.net.service.DicomServiceException: Unknown Move Destination: STORESCP#localhost:11115
at org.dcm4chee.archive.retrieve.scp.CMoveSCP.calculateMatches(CMoveSCP.java:184) [dcm4chee-arc-retrieve-scp-4.4.0.Beta1.jar:]
I think this is because of configuration, maybe I have to add STORESCP as acceptedAET or similar, but I can find info on how to do it. I search through ldap using Apache Directory Studio, but I didn't find anything.
Thanks in advance.
Using dcm4che3, it goes like this if you're implementing an SCP and need to define which other SCPs are allowed to C-STORE things to you.
// Usual calamity creating Connection, ApplicationEntity and Device
...
ApplicationEntity ae = new ApplicationEntity("MYAETITLE");
String[] acceptedAETs = { "STORESCP", "GEPACS" }; // etc...
ae.setAcceptedCallingAETitles(acceptedAETs);
I assume that your favourite SCP (STORESCP) may need to know where to find the SCP known by MYAETITLE; identified by IP address and port. Typically you connect to an SCP as a SCU, issuing a C-MOVE (in the scenario laid out here) instructing the SCP to do a C-STORE to the AET identified in the C-MOVE.
I'm a bit confused by your choice of AE Title in your question (STORESCP) because that indicates that you kind of mix up the two SCPs involved here; the one receiving the C-MOVE (which should not be called STORESCP :) and the one implementing the C-STORE behaviour. The answer I gave above, is aimed at the SCP implementing the C-STORE behaviour.

Categories

Resources