Plantronics Developer Connection - API https://developer.plantronics.com/blog/api en Radio Link Quality Data https://developer.plantronics.com/article/radio-link-quality-data <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><div>One use case for Radio Link Quality APIs is how third-party call quality diagnostics tools can be enhanced by knowing what’s going on at the first three feet. Specifically, how can IT troubleshoot the Bluetooth link between headset and USB adapter? <br />  </div> The Radio Link Quality API provides key information that can be used to gain true insights into the Bluetooth radio link: <ul> <li>Quality impairment score (QIS) is a measure of the user’s average call quality based on the percentage of packet errors and related data. The higher the impairment score, the lower the quality of the user’s average call experience. For example, a QIS of 0 for a given user would indicate that all calls were free from any detectable errors, while a QIS of 100 for a user would indicate that all calls suffered a complete loss of call audio. QIS is reported once for every call.</li> <li>Receive signal strength indication (RSSI) is a measure of the absolute strength of the Bluetooth signal at the headset. It measures the amount of power received at the headset antenna measured in dBm. dBm (sometimes dBmW or decibel-milliwatts) is an abbreviation for the power ratio in decibels (dB) of the measured power referenced to one milliwatt (mW). The RSSI is reported every four seconds during a call.</li> <li>Link figure of metric (LFOM) is a calculated guess on what the user is hearing based on the radio link quality. For each packet of data across the link there is an indication of any corruption in the data. This information is used to calculate sample error rates, which are then further processed over a period of time, creating the LFOM metric. Zero means that there were no valid data across the link; five means there were no errors. The LFOM is reported every four seconds during a call.</li> </ul> With more people working remotely, in locations such as coffee shops and airport lounges, these three measurements now make it possible to quickly determine if the environment and its associated interference on the Bluetooth radio link is the root cause of the user’s audio issues.  </div></div></div> Tue, 10 Apr 2018 17:26:50 +0000 jendeeda 1431 at https://developer.plantronics.com https://developer.plantronics.com/article/radio-link-quality-data#comments HubRESTSample – a new C++ REST API Sample for PDC https://developer.plantronics.com/article/hubrestsample-new-c-rest-api-sample-pdc <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/c-0" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">C++</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/rest" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">REST</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/hub" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Hub</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/manager-pro" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Manager Pro</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded">This new sample code illustrates seamless consumption of Plantronics out-of-proc REST API from C++ code!<br /> <br /> <strong>Location of full sample code:</strong> <a href="https://github.com/pltdev/pdc/tree/master/C%2B%2B%20REST%20Sample" target="_blank">https://github.com/pltdev/pdc/tree/master/C%2B%2B%20REST%20Sample</a><br />   <h3>Key Benefits</h3> <ol> <li><strong>Supports Plantronics Manager Pro configuration</strong> <ul> <li>Works with Plantronics Hub via “out-of-proc” REST API</li> </ul> </li> <li><strong>Supports multi-softphone &amp; multi-device configurations</strong></li> <li><strong>Same code for both Windows and Mac environments</strong></li> <li><strong>Follows same model as the other PDC samples for C#, Java, JavaScript, etc</strong> <ul> <li>Providing clear illustrations of basic call control</li> </ul> </li> <li><strong>Illustrates support for resilience to Hub restarting and device changing</strong></li> </ol> <h3>Design Overview</h3> The design of the sample uses a threaded (active) object called HubRESTLib, that handles all the REST HTTP requests and resilience (reconnects). It allows Hub SDK commands to be issued and events from Hub SDK to be received via the callbacks of the IHubRestLib interface.<br /> <br /> <div class="media media-element-container media-default"><div id="file-173" class="file file-image file-image-png"> <h2 class="element-invisible"><a href="/files/hubrestsample-1png">HubRESTSample 1.png</a></h2> <div class="content"> <img height="477" width="1115" class="media-element file-default img-responsive" typeof="foaf:Image" src="https://developer.plantronics.com/sites/default/files/HubRESTSample%201.png" alt="" /> </div> </div> </div><br /> <br /> *POCO Libraries were used in this sample for HTTP requests and JSON parsing functionality, but any libraries could be used<br />   <h3>The sample code in action…</h3> Note: with this integration sample it is just 1 line of C++ code to connect to Plantronics REST API (instantiate HubSDKConnector object), and 1 line of code to cleanup (delete the object).<br /> <br /> Once instantiated you are then able to submit API commands (e.g. IncomingCall, etc) to this object using a HubSDKAction object, as shown below. Some of the actions take parameters, e.g. callid, etc:<br /> <br /> <strong>Note: you will need the full sample code to use this</strong>, obtain from here: <a href="https://github.com/pltdev/pdc/tree/master/C%2B%2B%20REST%20Sample" target="_blank">https://github.com/pltdev/pdc/tree/master/C%2B%2B%20REST%20Sample</a><br />   <pre class="brush: cpp"> #include &lt;iostream&gt; #include &lt;string&gt; #include "HubSDKConnector.h" using namespace std; void ShowMenu() { cout &lt;&lt; endl; cout &lt;&lt; "plt sample menu" &lt;&lt; endl; cout &lt;&lt; "--" &lt;&lt; endl; cout &lt;&lt; "1 - ring/incoming call" &lt;&lt; endl; cout &lt;&lt; "2 - outgoing call" &lt;&lt; endl; cout &lt;&lt; "3 - answer call" &lt;&lt; endl; cout &lt;&lt; "4 - hold call" &lt;&lt; endl; cout &lt;&lt; "5 - resume call" &lt;&lt; endl; cout &lt;&lt; "6 - mute call" &lt;&lt; endl; cout &lt;&lt; "7 - unmute call" &lt;&lt; endl; cout &lt;&lt; "8 - end call" &lt;&lt; endl; cout &lt;&lt; "0 - quit" &lt;&lt; endl; cout &lt;&lt; endl; cout &lt;&lt; "&gt; "; } int GetCommand() { string cmdstr; int cmd; getline(std::cin, cmdstr); if (cmdstr.empty()) cmd = -1; else { try { cmd = atoi(cmdstr.c_str()); } catch (exception const &amp; e) { cout &lt;&lt; "error : " &lt;&lt; e.what() &lt;&lt; endl; cmd = -1; } } return cmd; } int main() { cout &lt;&lt; "C++ Plantronics Hub REST Sample" &lt;&lt; endl; bool quit = false; int callid = 0; HubSDKConnector * hubSDK = new HubSDKConnector(); // Connect to the Plantronics REST API while (!quit) { ShowMenu(); int cmd = GetCommand(); HubSDKAction action; switch (cmd) { case 1: callid++; // inform Plantronics my app has an incoming (ringing) call cout &lt;&lt; "Performing incoming call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_IncomingCall; action.callid = callid; // numeric id to uniquely identify each call action.contactname = "Bob%20Smith"; // optional contact name for display devices, e.g. Calisto 240, note: needs url encoding e.g. spaces are %20, etc. hubSDK-&gt;DoHubSDKAction(action); break; case 2: callid++; // inform Plantronics my app has an outgoing call cout &lt;&lt; "Performing outgoing call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_OutgoingCall; action.callid = callid; action.contactname = "Bob%20Smith"; hubSDK-&gt;DoHubSDKAction(action); break; case 3: // inform Plantronics my app has now answered an incoming (ringing) call cout &lt;&lt; "Answering call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_AnswerCall; action.callid = callid; hubSDK-&gt;DoHubSDKAction(action); break; case 4: // place call on hold cout &lt;&lt; "Holding call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_HoldCall; action.callid = callid; hubSDK-&gt;DoHubSDKAction(action); break; case 5: // resume the call cout &lt;&lt; "Resuming call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_ResumeCall; action.callid = callid; hubSDK-&gt;DoHubSDKAction(action); break; case 6: // mute the headset (note for wireless products, audio link must be active) cout &lt;&lt; "Setting headset mute = true"; action.ActionType = HubSDKActionType_SetMute; action.mutestate = true; hubSDK-&gt;DoHubSDKAction(action); break; case 7: // unmute the headset (note for wireless products, audio link must be active) cout &lt;&lt; "Setting headset mute = false"; action.ActionType = HubSDKActionType_SetMute; action.mutestate = false; hubSDK-&gt;DoHubSDKAction(action); break; case 8: // inform Plantronics my app has now terminated the call cout &lt;&lt; "Terminating call, id = " &lt;&lt; callid &lt;&lt; endl; action.ActionType = HubSDKActionType_TerminateCall; action.callid = callid; hubSDK-&gt;DoHubSDKAction(action); break; case 0: quit = true; break; default: cout &lt;&lt; "Unrecognised menu choice." &lt;&lt; endl; break; } } delete hubSDK; // Cleanup the Plantronics REST API return 0; } </pre>   <h4>View of the application running:</h4> It presents a menu allowing you to try out the basic call control commands, and see connection information and notifications from Plantronics Hub and the headset:<br /> <br /> <div class="media media-element-container media-default"><div id="file-179" class="file file-image file-image-png"> <h2 class="element-invisible"><a href="/files/hubrestsample-3png-2">HubRESTSample 3.png</a></h2> <div class="content"> <img height="745" width="917" class="media-element file-default img-responsive" typeof="foaf:Image" src="https://developer.plantronics.com/sites/default/files/HubRESTSample%203_2.png" alt="" /> </div> </div> </div><br />  </div></div></div> Tue, 06 Jun 2017 14:00:33 +0000 lcollins 546 at https://developer.plantronics.com https://developer.plantronics.com/article/hubrestsample-new-c-rest-api-sample-pdc#comments Advanced SDK Topic: Ensuring Resilience with Plantronics COM API https://developer.plantronics.com/article/advanced-sdk-topic-ensuring-resilience-plantronics-com-api <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/resilience" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">resilience</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/resilient" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">resilient</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/com" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">COM</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/plantronics" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">plantronics</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/sdk" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">SDK</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><strong>Author:</strong> Lewis Collins, Plantronics<br /> <br /> When using the Plantronics COM API how do you ensure the connection to the Plantronics Hub software is working? <ul> <li>What if the user accidentally shuts down Plantronics Hub (or it crashes), or user upgrades it which would also result in it shutting down and starting again. Would your software re-connect to the COM API automatically?</li> <li>What if Plantronics Hub is not installed, will your software still attempt to connect to it, resulting in long COM timeout? (Will this timeout impact your applications performance)?</li> </ul> On this page I present a solution to these problems that ensures resilience of connection to Plantronics COM API covering the scenarios mentioned above.<br /> <br /> The approach is as follows: <ol> <li>Move all the code that connects / interacts with Plantronics COM API into a seperate class with its own thread. Now Plantronics COM API interaction is done on its own thread it will not impact your application's performance even if a COM timeout / exception occurs. This class is called HubSDKConnector.</li> <li>In HubSDKConnector add a watchdog timer that polls (attempts to use) the COM API every 5 seconds. If the connection fails (exception occurs) it will attempt to re-establish connection. Note, this interval is slowed to 60 seconds if HubSDKConnector detects that a Plantronics Hub upgrade is in progress (Hub installer is running). This corner case allows user to upgrade Hub without your application attempting to request COM API again, which would respawn the Hub EXE before install operation completes, therefore requiring a reboot to complete install - this is not desirable</li> </ol> <strong><img alt="enlightened" height="23" src="http://developer.plantronics.com/profiles/apigee/libraries/ckeditor/plugins/smiley/images/lightbulb.png" title="enlightened" width="23" /> Code for this sample:</strong> <a href="https://github.com/plantronics/pdc/tree/master/Advanced/ResilientPLTDemo" target="_blank">click here&gt;&gt;</a> (note: you must be registered and signed in to access this).<br /> <br /> The code is functionally the same is as the basic C# sample (<a href="/article/get-started-code-samples">in Get Started, C# Tab</a>), with the integration code moved into HubSDKConnector.cs. The code is in C#, but the same concept could be implemented in C++ with the Plantronics COM API.<br /> <br /> Here is a screenshot of it running.<br /> <br /> <em><strong>What do you think of this solution?</strong></em> Let me know your feedback or questions using the form at the bottom of the page. Have fun! :-)<br /> Lewis.<br /> <br /> <div class="media media-element-container media-default"><div id="file-164" class="file file-image file-image-png"> <h2 class="element-invisible"><a href="/files/resilientpltdemopng-0">ResilientPLTDemo.png</a></h2> <div class="content"> <img height="832" width="1530" class="media-element file-default img-responsive" typeof="foaf:Image" src="https://developer.plantronics.com/sites/default/files/ResilientPLTDemo_0.png" alt="" /> </div> </div> </div><br /> <br />  </div></div></div> Thu, 27 Apr 2017 10:02:55 +0000 lcollins 507 at https://developer.plantronics.com https://developer.plantronics.com/article/advanced-sdk-topic-ensuring-resilience-plantronics-com-api#comments Implement Proximity Detection (Near/Far) with Voyager Focus UC/5200 UC and BT600 dongle https://developer.plantronics.com/article/implement-proximity-detection-nearfar-voyager-focus-uc5200-uc-and-bt600-dongle <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/proximity" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">proximity</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/near" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">near</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/far" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">far</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/sdk" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">SDK</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/integration" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">integration</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/5200" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">5200</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/uc" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">uc</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/focus" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">focus</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/voyager" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">voyager</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/bt600" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">bt600</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded">Greetings!<br /> <br /> The Plantronics SDK feature for receiving proximity events when headset is Near or Far from PC can still be used with the new line of products based on BT600 dongle (Voyager Focus UC, Voyager 5200 UC).<br /> <br /> <strong>**Full sample code for this article located here**:</strong> <a href="/system/files/FocusProximityExample.zip">/system/files/FocusProximityExample.zip</a><br /> (You must be logged in to download the file).<br /> <br /> You can register for Proximity with these devices using the latest SDK version 3.8.51454.38364, located here: <a href="http://developer.plantronics.com/windows">http://developer.plantronics.com/windows</a><br /> <br /> You need to register for DeviceListener HeadsetStateChanged events, like this:<br />   <pre class="prettyprint"> m_deviceListenerEvents.onHeadsetStateChanged += m_deviceListenerEvents_onHeadsetStateChanged;</pre> <br /> Then you register to receive proximity:<br />   <pre class="prettyprint"> m_hostCommandExt.EnableProximity(true); // enable proximity reporting for device m_hostCommandExt.RequestProximity(); // request to receive asyncrounous near/far proximity event to HeadsetStateChanged event handler. </pre> <br /> When you handle the HeadsetStateChanged events you can see if you are near or far:<br /> (Note, there are a couple of edge cases for the older legacy wireless products where you need to re-register for proximity on InRange and ProximityDisabled, these do not apply to BT600). <pre class="prettyprint"> private static void m_deviceListenerEvents_onHeadsetStateChanged(COMDeviceListenerEventArgs args) { switch (args.HeadsetStateChange) { case DeviceHeadsetStateChange.HeadsetStateChange_Near: Console.WriteLine("&gt;&gt;Headset NEAR (via deviceListener event)"); break; case DeviceHeadsetStateChange.HeadsetStateChange_Far: Console.WriteLine("&gt;&gt;Headset FAR (via deviceListener event)"); // this is NOT working. for now use workaround in m_deviceComEvents_onDataReceived below. break; case DeviceHeadsetStateChange.HeadsetStateChange_ProximityDisabled: // Immediately re-enable proximity RegisterForProximity(true); break; case DeviceHeadsetStateChange.HeadsetStateChange_InRange: // Immediately re-enable proximity RegisterForProximity(true); break; } } </pre> Finally, there is a known issue with the current SDK version that we need to workaround to get the "Far" event. (the "Far" event is not currently reported via DeviceListener, expected to be implemented in later SDK release 3.9).<br /> <br /> For the workaround register to receive "raw" headset data events:<br />   <pre class="prettyprint"> m_deviceComEvents = m_activeDevice as ICOMDeviceEvents_Event; m_deviceComEvents.onDataReceived += m_deviceComEvents_onDataReceived; </pre> <br /> Then when you receive raw data event, use the code below to work out when the device is "Far":<br />   <pre class="prettyprint"> private static string byteArrayToString(byte[] p) { StringBuilder b = new StringBuilder(); foreach (byte x in p) b.Append(x.ToString("X2")); return b.ToString(); } private static void m_deviceComEvents_onDataReceived(ref object report) { byte[] reportbuf = (byte[])report; string datareporthex = byteArrayToString(reportbuf); // use raw device data to implement proximity Far event string command = datareporthex.Substring(18, 4); switch (command) { case "0806": string nearfar = datareporthex.Substring(26, 2); if (nearfar == "00") // this workaround is required with 3.8 for now as Far is not done in Spokes SDK (will be in 3.9) { Console.WriteLine("&gt;&gt;Headset FAR (via raw device data event)"); } break; } } </pre> <br /> Here is a picture of the code in action:<br /> <div class="media media-element-container media-default"><div id="file-113" class="file file-image file-image-png"> <h2 class="element-invisible"><a href="/files/focus-proximity-examplepng">focus proximity example.png</a></h2> <div class="content"> <img height="277" width="917" class="media-element file-default img-responsive" typeof="foaf:Image" src="https://developer.plantronics.com/sites/default/files/focus%20proximity%20example.png" alt="" /> </div> </div> </div><br /> <br /> That's it! Have fun with proximity <img alt="laugh" height="23" src="http://developer.plantronics.com/profiles/apigee/libraries/ckeditor/plugins/smiley/images/teeth_smile.png" title="laugh" width="23" /><br /> Lewis.<br /> <br /> <strong>**Full sample code for this article located here**:</strong> <a href="/system/files/FocusProximityExample.zip">/system/files/FocusProximityExample.zip</a></div></div></div> Fri, 02 Sep 2016 13:32:28 +0000 lcollins 385 at https://developer.plantronics.com https://developer.plantronics.com/article/implement-proximity-detection-nearfar-voyager-focus-uc5200-uc-and-bt600-dongle#comments Integrate Plantronics REST API from Go https://developer.plantronics.com/article/integrate-plantronics-rest-api-go <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/go" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">go</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/sdk" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">SDK</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/rest" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">REST</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/plantronics" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">plantronics</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded">Greetings!<br /> <br /> I have recently created an example integrate from the Go language to the Plantronics REST API.<br /> <br /> It is still a work in progress but it is functional for receiving device, session and session manager events. (For further guidance on the REST Service API URLs you can use, check out the Java and JavaScript integration samples elsewhere on this site).<br /> <br /> Obtain Go language (golang) from here: <a href="https://golang.org/">https://golang.org/</a><br /> <br /> Obtain the sample code from here: <a href="/system/files/plt%20go%20sample.zip">http://developer.plantronics.com/system/files/plt%20go%20sample.zip</a><br /> <strong>Note: </strong>you must login to this site to download that file.<br /> <br /> Here is how you connect to Plantronics from Go (code snippet):<br />   <pre class="prettyprint"> func httpGetJSON(url string) (map[string]interface{}) {     var dat map[string]interface{}     resp, err := http.Get(url)     if err != nil {         log.Fatal(err)     }     defer resp.Body.Close()     if b, err2 := ioutil.ReadAll(resp.Body); err2 == nil {         if err := json.Unmarshal(b, &amp;dat); err != nil {             log.Fatal(err)         }     }     return dat } func connectToPlantronics() { fmt.Print("Connecting to Plantronics...\r\n") var jsondata map[string]interface{} = httpGetJSON("http://127.0.0.1:32017/Spokes/DeviceServices/Attach?uid=0123456789") fmt.Print("\r\nSession ID:\r\n\r\n"+jsondata["Result"].(string)+"\r\n\r\n") sessionId = jsondata["Result"].(string) var result string = httpGet("http://127.0.0.1:32017/Spokes/SessionManager/Register?name="+pluginName) fmt.Print("\r\nResult:\r\n\r\n"+result+"\r\n\r\n") pluginRegistered = true go eventsListenerThread(sessionId,pluginName) // start monitoring events after connect to api } </pre> <br /> Below is a picture of the code in action, having received a "Don" event (when I put on the Plantronics headset)...<br /> Have fun!<br /> Lewis.<br /> <br /> <div class="media media-element-container media-default"><div id="file-111" class="file file-image file-image-png"> <h2 class="element-invisible"><a href="/files/go-samplepng">go sample.png</a></h2> <div class="content"> <img height="798" width="915" class="media-element file-default img-responsive" typeof="foaf:Image" src="https://developer.plantronics.com/sites/default/files/go%20sample.png" alt="" /> </div> </div> </div></div></div></div> Thu, 01 Sep 2016 12:06:32 +0000 lcollins 384 at https://developer.plantronics.com https://developer.plantronics.com/article/integrate-plantronics-rest-api-go#comments Using Plantronics SDK from Java https://developer.plantronics.com/article/using-plantronics-sdk-java <div class="field field-name-field-keywords field-type-taxonomy-term-reference field-label-above"> <div class="field-label">Keywords:&nbsp;</div> <div class="field-items"> <span class="field-item even label label-default keyword-label"><a href="/blog/java" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Java</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/plantronics" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">plantronics</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/sdk" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">SDK</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/integration" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">integration</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/rest" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">REST</a></span> <span class="field-item odd label label-default keyword-label"><a href="/blog/service" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Service</a></span> <span class="field-item even label label-default keyword-label"><a href="/blog/api" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">API</a></span> </div> </div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><span style="color:#FF0000;">*Update 22nd Jan 2016*</span>: Since the SDK version 3.7.x, you can now optionally use https:// port <span style="color:#FF0000;"><strong>32018</strong></span> in addition to http:// on port <strong>32017</strong>! (however for https you may need to manually deploy the self-signed certificate if using Firefox or Java).<br /> <br /> <strong>Sample code:</strong><br /> <a href="/system/files/PlantronicsRESTDemo%20-%20Milestone%201%20full%20call%20control%20and%20events%20listening.zip">Download this sample code as a ZIP</a><br />   <pre class="brush: java"> String tmpResult =     RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/DeviceServices/Attach?uid=0123456789" );</pre> This code requires the convenience function SendRESTCommand (available <a href="/system/files/PlantronicsRESTDemo%20-%20Milestone%201%20full%20call%20control%20and%20events%20listening.zip">in the sample code ZIP</a>).<br /> <br /> 0123456789 is a magic uid which tells the REST Service API to attach to the "primary" Plantronics device (primary device is settable via the Plantronics Hub user interface, in the case you have more than one Plantroncis device attached to your PC).<br /> <br /> Now we can examine the tmpResult variable to see if the attach was a success. <pre class="brush: java"> int pos = tmpResult.indexOf("\"Result\":\""); if (pos&gt;-1) {     tmpResult = tmpResult.substring(pos+10);     pos = tmpResult.indexOf("\"");     if (pos&gt;-1)     {         tmpResult = tmpResult.substring(0, pos);         System.out.println("Session id is: " + tmpResult);         sessionid = tmpResult;     } }</pre> This code is extracting the sessionid from the HTTP response. We need that later for some of the other REST Service API commands. Note, the HTTP response is in fact JSON, so it would be better to parse with a JSON parser, but I haven't adopted a suitable JSON parser yet...<br /> <br /> After a short delay we can go ahead an register a REST Service API plugin. The plugin is needed for some of the call control commands. <pre class="brush: java"> try {     Thread.sleep(250); } catch (InterruptedException ex) {     Logger.getLogger(PlantronicsRESTDemo.class.getName()).log(Level.SEVERE, null, ex); }                                   if (sessionid.length()&gt;0) {     RESTConvenienceClass.SendRESTCommand(         "http://127.0.0.1:32017/Spokes/SessionManager/Register?name=My%20Java%20Plugin"     );                    pluginRegistered = true; }</pre> Now we are able to poll for device events using further REST Service API commands, like this:<br /> (Note: the sessid and plugin_name need to match what we registered earlier).<br /> The contents of the responses we get back tell us lots of information, such as when user has answered a call with headset, mutes a call, takes headset off, etc. <pre class="brush: java"> RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/DeviceServices/Events?sess="         + sessid         + "&amp;queue=0" ) RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/CallServices/Events" ); RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/CallServices/SessionManagerCallEvents?name="         + plugin_name );</pre> Finally we can control the headset by telling it when we are going on a call, for example:<br /> An incoming call (pass an integer callid, used to refer to this call during its lifecycle, and pass an optional caller name for Plantronics' display device products): <pre class="brush: java"> callid = callid + 1; caller_name = "Bob%20Smith"; RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/CallServices/IncomingCall?name=My%20Java%20Plugin&amp;callID=%7B%22Id%22%3A%22"         + callid         + "%22%7D&amp;contact=%7B%22Name%22%3A%22"         + caller_name         + "%22%7D&amp;tones=Unknown&amp;route=ToHeadset" );</pre> End the call: <pre class="brush: java"> RESTConvenienceClass.SendRESTCommand(     "http://127.0.0.1:32017/Spokes/CallServices/TerminateCall?name=My%20Java%20Plugin&amp;callID=%7B%22Id%22%3A%22"         + callid         + "%22%7D" );</pre> For more examples and to see a complete Java implementation, <a href="/system/files/PlantronicsRESTDemo%20-%20Milestone%201%20full%20call%20control%20and%20events%20listening.zip">download the sample code ZIP</a>.<br /> <br /> Here is a screeshot of the sample code in action running under <a href="https://netbeans.org/" target="_blank">NetBeans IDE</a>:<br /> <br /> false<br /> <br /> Have fun!<br /> <br /> <br /> <br /> <br /> <br />  </div></div></div> Thu, 05 Nov 2015 12:40:30 +0000 lcollins 162 at https://developer.plantronics.com https://developer.plantronics.com/article/using-plantronics-sdk-java#comments