Dear Vimala,
BLE operations is success !!! (Android <==> Arduino)
Thank for your kindly response.
Best regards,
Roy Kang.
2016-01-07 19:10 GMT+09:00 Vimala Vishwanathan <vimala.v at samsung.com>:
> Hi Roy,
>
>
>
> The issue happens when there is a two way communication between Android
> and
>
> Arduino. That is, when Arduino is sending response for find resource,
> Android
>
> is initiating another "find resource" request. The same scenario with
> Tizen and
>
> arduino is working fine. Looks like there is an issue with Android BLE.
>
>
>
> Quick fix is to send only one request by modifying SimpleClient.java file
> as below:
>
> private void startSimpleClient() {
>
> ...
>
> OcPlatform.findResource("",
> requestUri,
> EnumSet.of(OcConnectivityType.CT_DEFAULT),
> this
> );
> sleep(1);
>
> // msg("Finding all resources of type \"core.light\" for the
> second time");
> //
> OcPlatform.findResource("",
> <- Comment the second Find resource
> // requestUri,
> // EnumSet.of(OcConnectivityType.CT_DEFAULT),
> // this
> // );
>
> }
>
>
>
> Thanks and Regards,
>
> Vimala
>
>
>
> ------- *Original Message* -------
>
> *Sender* : Roy Kang<roykang75 at gmail.com>
>
> *Date* : Jan 06, 2016 22:42 (GMT+05:30)
>
> *Title* : Re: [dev] [2015/12/28 UPDATE] [QUESTION] Communication problem
> between arduino and android via BLE.
>
>
> Dear all,
>
> Is there any "Arduino BLE" manager in Iotivity-dev who knows?
> I need his help.
>
> Best regards,
> Roy Kang.
>
> 2015-12-28 16:38 GMT+09:00 Roy Kang <roykang75 at gmail.com>:
>
>>
>> Dear All,
>>
>> I was debugging issue that device is disconnected.
>>
>> I guess that root cause is below log. (Refer to *RED* color)
>>
>> ==================================================
>> INFO: ocresource: Extracting params from rt=core.light
>> INFO: ocresource: Extracted params
>> *FATAL: OCStack: Generate UUID for Server Instance failed!*
>> INFO: ocresource: /oic/ad not ACTIVE or DISCOVERABLE
>> INFO: ocresource: /oic/d does not contain rt=core.light.
>> ==================================================
>>
>> Error code is as below.
>> <Iotivity>/resource/csdk/stack/src/ocstack.c
>> <Iotivity>/resource/csdk/security/src/doxmeresource.c const OicUuid_t*
>> OCGetServerInstanceID(void)
>> {
>> static bool generated = false;
>> static OicUuid_t sid;
>> if (generated)
>> {
>> return &sid;
>> }
>>
>> if (*GetDoxmDeviceID*(&sid) != OC_STACK_OK)
>> {
>> OC_LOG(FATAL, TAG, "Generate UUID for Server Instance failed!");
>> return NULL;
>> }
>> generated = true;
>> return &sid;
>> } ==> /**
>> * This method returns the SRM device ID for this device.
>> *
>> * @retval OC_STACK_OK for Success, otherwise some error value
>> */
>> OCStackResult *GetDoxmDeviceID*(OicUuid_t *deviceID)
>> {
>> if(deviceID && *gDoxm*)
>> {
>> *deviceID = gDoxm->deviceID;
>> return OC_STACK_OK;
>> }
>> return OC_STACK_ERROR;
>> }
>> gDoxm is NULL.
>> So, errro occurs.
>>
>> gDoxm creation flow is as below.
>>
>> <Iotivity>/resource/csdk/stack/src/ocstack.c
>> <Iotivity>/resource/csdk/stack/src/ocstack.c
>> <Iotivity>/resource/csdk/security/src/securesourcemanager.c
>> <Iotivity>/resource/csdk/security/src/securesourcemanager.c OCStackResult
>> *OCInit1*(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags
>> clientFlags)
>> {
>> ?????
>> //Update Stack state to initialized
>> stackState = OC_STACK_INITIALIZED;
>>
>> // Initialize resource
>> if(myStackMode != OC_CLIENT)
>> {
>> result = initResources();
>> }
>> ?????
>> } ==> OCStackResult *initResources*()
>> {
>> ?????
>> #ifndef WITH_ARDUINO
>> if (result == OC_STACK_OK)
>> {
>> result = SRMInitSecureResources();
>> }
>> #endif
>> ?????
>> } ==> OCStackResult *SRMInitSecureResources*()
>> {
>> // TODO: temporarily returning OC_STACK_OK every time until default
>> // behavior (for when SVR DB is missing) is settled.
>> InitSecureResources();
>>
>> #if defined(__WITH_DTLS__)
>> CARegisterDTLSCredentialsHandler(GetDtlsPskCredentials);
>> #endif // (__WITH_DTLS__)
>> #if defined(__WITH_X509__)
>> CARegisterDTLSX509CredentialsHandler(GetDtlsX509Credentials);
>> CARegisterDTLSCrlHandler(GetDerCrl);
>> #endif // (__WITH_X509__)
>>
>> return OC_STACK_OK;
>> } ==> /**
>> * Initialize all secure resources ( /oic/sec/cred, /oic/sec/acl,
>> /oic/sec/pstat etc).
>> *
>> * @retval OC_STACK_OK for Success, otherwise some error value
>> */
>> OCStackResult *InitSecureResources*( )
>> {
>> OCStackResult ret;
>> /*
>> * doxm resource should be initialized first as it contains the
>> DeviceID
>> * which MAY be used during initialization of other resources.
>> */
>> ret = InitDoxmResource();
>> Because condition of "#ifndef WITH_ARDUINO" code. gDoxm doesn't created.
>> (Refer to GREEN color on "Step 2" )
>>
>> WITH ARDUINO has been defined in
>> "<Iotivity>/resource/csdk/arduinomega.properties".
>>
>> So, ((OCDiscoveryPayload*)payload)->sid is NULL.
>>
>> <Iotivity>/resource/csdk/stack/src/ocresource.c static OCStackResult
>> HandleVirtualResource (OCServerRequest *request, OCResource* resource)
>> {
>> ?????
>> if (discoveryResult == OC_STACK_OK)
>> {
>> payload = (OCPayload*)OCDiscoveryPayloadCreate();
>>
>> if(payload)
>> {
>> ((OCDiscoveryPayload*)payload)->sid =
>> (uint8_t*)OICCalloc(1, UUID_SIZE);
>> memcpy(((OCDiscoveryPayload*)payload)->sid,
>> OCGetServerInstanceID(), UUID_SIZE);
>>
>> bool foundResourceAtRD = false;
>> ?????
>> }
>> I guess that sid is very important.
>> Client sent discovery message and then receive response.
>> But client cannot finish about this flow because sid is NULL (or garbage)
>> on response message.
>>
>> I'm not sure my opinion is correct.
>> I will plan continue debugging.
>>
>> Please let me know if you have any other comments.
>>
>> Best regards,
>> ST Kang
>>
>> 2015-12-28 0:46 GMT+09:00 Roy Kang <roykang75 at gmail.com>:
>>
>>> Dear All,
>>>
>>> I am very interested Iotivity Project.
>>> So, i try test between Arduino mega and Anrdroid via BLE using master
>>> branch(20151227)
>>> (example: SimpleClientServer)
>>>
>>> Arduino environment: Arduino Mega 2560 + RedBearLab BLE Shield v2.1.
>>> Android environment: Andorid 5.0.2 (LG G PAD)
>>>
>>> Step 1) Run arduino.
>>> Step 2) Run SimpleClient app on Android and then click "START".
>>>
>>> When viewing the log, device found.
>>> After server sent response to client, devices is disconnected.
>>>
>>> ==================================================================
>>> data transmmit success! Length: 20 Data Credit available: 1
>>> Pipe Number: 3
>>> Pipe Number: 3
>>> Pipe Number: 3
>>> Evt Disconnected/Advertising timed out
>>> Advertising started
>>> data transmmit success! Length: 2 Data Credit available: 1
>>> ACI Evt Pipe Error: Pipe #:4 Pipe Error Code: 0x83
>>> Data Credit available: 2
>>> ==================================================================
>>>
>>> I don't know why occurs this problem.
>>> Could anybody help me ?
>>>
>>> Full log is attached.
>>>
>>> Best regards.
>>> ST Kang.
>>>
>>
>>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160109/5bfde8d3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 201601071539357_BEI0XT4N.gif
Type: image/gif
Size: 13168 bytes
Desc: not available
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160109/5bfde8d3/attachment.gif>