Change Accelerometer Range to 16G - movesense

Can anyone help please!
I am trying to change the accelerometer range for the Movesense Sensor in Android Studio from the standard 8G to 16G.
I keep getting the 'Bad Request' error. I have had no problem with using PUT requests for other things (e.g. switching the LED on/off) but for some reason I can't change the accelerometer range. I have tried changing the format of the contract part of the request but this has not solved the problem. I am new to programming the Movesense. Thank you.
My code is:
private final String LINEAR_CONFIG_PATH = "/Meas/Acc/Config";
private final String range = "{\"GRange\":";
private final String rangeValue = "16";
Mds.builder().build(this).put(MdsRx.SCHEME_PREFIX +
MovesenseConnectedDevices.getConnectedDevice(0).getSerial()+
LINEAR_CONFIG_PATH , range + rangeValue +"}", new
MdsResponseListener() {

the API (yaml) document of the /Meas/Acc/Config states:
put:
description: |
Set linear acceleration measurement configuration.
parameters:
- name: config
in: body
description: New configurations for the accelerometer.
required: true
schema:
$ref: '#/definitions/AccConfig'
The name of the parameter is "config". so the JSON you put to the request should be:
{
"config":{"GRange":16}
}
i.e it has to be wrapped to a property with the name of the put parameter (in some API's there are multiple parameters so this is the way to set them all).
Full Disclosure: I work for the Movesense team

Related

Prisma 2: Setting Minimum & Maximum Length of a String type

I am creating a model using Prisma 2 and want to set a minimum and maximum length for one of the fields. I.e., something like this:
model Post {
...
title String #min(3) #max(240)
...
}
I just made up the above syntax. I am wondering if something like that exists in Prisma and, if so, how to do it.
Any ideas?
Thanks.
Annotation #db.VarChar
You can set the maximum length using the annotation #db.VarChar:
model Post {
...
title String #db.VarChar(240)
...
}
There is no support for adding the minimum length as for now.

Restrict Countries and Cites in Flutter using session token

the following string of url correctly gives me locations within my country:
String autocompleteURL="https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$placeName&key=$mapKey&sessiontoken=1234567890&components=country:my";` //no Error
'my' gives all cities in Malaysia.
However, I want to restrict it to malacca within malaysia.I don't know how to use components for a particular city using session token.I searched the autocomplete documentation from google developers website.
After that, I changed the above code into:
String autocompleteURL= "https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=$placeName&types=establishment&location=2.25386,-102.27273&radius=500&key=$mapKey"; //error after change.
However, only this line gives me error after change.
Here, long and latitude values are the values for Malacca.
I am using my program in flutter.
change your output type from xml to json :
String autocompleteURL= "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$placeName&types=establishment&location=2.25386,-102.27273&radius=500&key=$mapKey"; //error after change.

how to solve actions on google-Api.ai error

Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.
Short answer - check here for screenshots http://imgur.com/a/tVBlD
Long answer - You have two options
1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter
2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.
If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.
Note the second route is what I did to solve a similar issue.
You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.
Python regex search example
baseurl = "http://mywebsite.com:9001/"
# Parse the document
# Build the URL + File Path and Parse the Document
url = baseurl + 'Data'
xmlLink = urllib.request.urlopen(url)
xmlData = etree.parse(xmlLink)
xmlLink.close()
# Find the number of elements to cycle through
numberOfElements = xmlData.xpath("count(//myData/data)")
numberOfElements = int(numberOfElements)
types = xmlData.xpath("//myData/data")
# Search the string
i = 0
while numberOfElements > i:
listSearch= types[i].text
match = re.search(parameter, listSearch, re.IGNORECASE)
if match is None:
i += 1
else:
# Grab the ID
elementID = types[i].get('id')
i = 0
break
An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.

Apply Command to String-type custom fields with YouTrack Rest API

and thanks for looking!
I have an instance of YouTrack with several custom fields, some of which are String-type. I'm implementing a module to create a new issue via the YouTrack REST API's PUT request, and then updating its fields with user-submitted values by applying commands. This works great---most of the time.
I know that I can apply multiple commands to an issue at the same time by concatenating them into the query string, like so:
Type Bug Priority Critical add Fix versions 5.1 tag regression
will result in
Type: Bug
Priority: Critical
Fix versions: 5.1
in their respective fields (as well as adding the regression tag). But, if I try to do the same thing with multiple String-type custom fields, then:
Foo something Example Something else Bar P0001
results in
Foo: something Example Something else Bar P0001
Example:
Bar:
The command only applies to the first field, and the rest of the query string is treated like its String value. I can apply the command individually for each field, but is there an easier way to combine these requests?
Thanks again!
This is an expected result because all string after foo is considered a value of this field, and spaces are also valid symbols for string custom fields.
If you try to apply this command via command window in the UI, you will actually see the same result.
Such a good question.
I encountered the same issue and have spent an unhealthy amount of time in frustration.
Using the command window from the YouTrack UI I noticed it leaves trailing quotations and I was unable to find anything in the documentation which discussed finalizing or identifying the end of a string value. I was also unable to find any mention of setting string field values in the command reference, grammer documentation or examples.
For my solution I am using Python with the requests and urllib modules. - Though I expect you could turn the solution to any language.
The rest API will accept explicit strings in the POST
import requests
import urllib
from collections import OrderedDict
URL = 'http://youtrack.your.address:8000/rest/issue/{issue}/execute?'.format(issue='TEST-1234')
params = OrderedDict({
'State': 'New',
'Priority': 'Critical',
'String Field': '"Message to submit"',
'Other Details': '"Fold the toilet paper to a point when you are finished."'
})
str_cmd = ' '.join(' '.join([k, v]) for k, v in params.items())
command_url = URL + urllib.urlencode({'command':str_cmd})
result = requests.post(command_url)
# The command result:
# http://youtrack.your.address:8000/rest/issue/TEST-1234/execute?command=Priority+Critical+State+New+String+Field+%22Message+to+submit%22+Other+Details+%22Fold+the+toilet+paper+to+a+point+when+you+are+finished.%22
I'm sad to see this one go unanswered for so long. - Hope this helps!
edit:
After continuing my work, I have concluded that sending all the field
updates as a single POST is marginally better for the YouTrack
server, but requires more effort than it's worth to:
1) know all fields in the Issues which are string values
2) pre-process all the string values into string literals
3) If you were to send all your field updates as a single request and just one of them was missing, failed to set, or was an unexpected value, then the entire request will fail and you potentially lose all the other information.
I wish the YouTrack documentation had some mention or discussion of
these considerations.

JIRA SOAP Client - return invalid field value

I have a problem using JIRA SOAP client. When I use RemoteIssue.getResolution() or RemoteIssue.getStatus() I get number values. For example let say we have an issue that has resolution = fixed. When I call client.getIssueFromJqlSearch(token, "issuetype = Bug AND resolution = fixed", 10) this will return an array of type RemoteIssue[]. Now if I call issues[i].getResolution() (where issues[] is the result from previous call getIssuesFromJqlSearch) this will return a value "5" instead of "fixed". How to solve this? Is there any way to get the value "fixed" for that issue and not a custom value "5"?
Thank you in advance.
If you call getResolutions() on the SOAP API you'll get an array of all the resolutions defined in the instance, including their Ids. You can then use this to work out which resolution the Id you've got refers to.