A happy new year! I haven't written an article for a long time. I watch HAKONE EKIDEN, and at the same time, I write this article.
Last year, I changed a job and the technology I use has also changed. The OS changed from Windows to Redhat and CentOS, the virtual environment changed from Hyper-V to VMware Hypervisor, the development language changed from C # to Java, and the cloud environment changed from Azure to AWS. Recently, I have been playing with IncommingWebhook of Microsoft Teams with curl command.
Here are my resolutions for this year.
Write blogs regularly and publish technical information.
I haven't posted an article recently. I was busy because my environment has changed. I had used only SQL Server, but now I need to use Oracle at work. ( I had used symfo....lol, too. ) I try to connect Oracle because I can not do anything. I try to connect Oracle, Using tool below. a5m2.mmatsubara.com
I try to use a little, I think that A5:SQL Mk-2 has many function and useful. I want to get an information about Oracle, I try to find like dmv and dmf in SQL Server. It is V$ table. Execute below query, you will get list of V$.
SELECT
OBJECT_NAME
FROM
DBA_OBJECTS
WHERE
OBJECT_NAME LIKE'V$%'
If you want to get information of Executing query in Oracle, execute below query.
SELECT
vs.sid,
vsa.sql_text,
vs.serial#,
vs.status,
vs.machine,
vs.osuser,
vs.module,
vs.username,
vs.process
FROM
V$SESSION vs,
V$SQLAREA vsa
WHERE
vs.prev_hash_value = vsa.hash_value
AND vs.prev_sql_addr = vsa.address
AND vs.status = 'ACTIVE'
I would like to operate Nature Remo mini with C # referring to the blog above and the Nature Remo API. Based on the following sources used in the operation of Sony DSC-QX10, I will change it to Nature Remo mini version.
static async void DoPost()
{
string jsonparams = "{\"method\": \"actTakePicture\"," +
"\"params\": []," +
"\"id\": 1," +
"\"version\": \"1.0\"}"; string url = "http://10.0.0.1:10000/sony/camera";
var httpclient = new HttpClient();
var jsoncontent = new StringContent(jsonparams, Encoding.UTF8, "application/json");
httpclient.MaxResponseContentBufferSize = int.MaxValue;
var response = await httpclient.PostAsync(url, jsoncontent);
String text = await response.Content.ReadAsStringAsync();
}
It is a DVD deck to control. The remote controller is as shown below.
In order to control the device, you need to get the device id. It can be obtained by sending a request to Nature Remo mini using the code below. Please get the access token here.
static async void DoGet()
{
string token = "Bearer " + "{access token}";
string url = "https://api.nature.global/1/appliances";
var httpclient = new HttpClient();
httpclient.DefaultRequestHeaders.Add("Authorization", token);
var response = await httpclient.GetAsync(url);
}
Since you can get the device id, use that the device id to control the power of a DVD deck.
The acquired id ( e1ac8815-1480-4914-bd77-a42c5037659b) is specified as follows, and the source is rewritten for POST request. A status code is returned in 200, it will succeed. I think It is able to write the code of the GET code and the POST code beautifully by using HttpRequestMessage and SendAsync.
static async void DoPost()
{
string token = "Bearer " + "{access token}";
string url = "https://api.nature.global/1/signals/e1ac8815-1480-4914-bd77-a42c5037659b/send";
var httpclient = new HttpClient();
var httpreqmsg = new HttpRequestMessage(HttpMethod.Post, url);
httpreqmsg.Headers.Add("Authorization", token);
var response = await httpclient.SendAsync(httpreqmsg);
}
Because I want to make the sample source code as simple as possible, I do not specify HEADER information and other necessary information neatly. For full-fledged use, please refer carefully to the Nature Remo API specification.
A programming of device is fun. I noticed after Nature Remo mini arrived at my house, but the second generation of Nature Remo has humidity, human feeling, and light sensor. I should have bought the second generation of Nature Remo!